Skip to content

Commit

Permalink
updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
KARTHEEKCIC committed Aug 9, 2021
1 parent 3af2616 commit 012012a
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: dab5c77040d718b25e532551623570bb
config: 82633e0620d612db95f8a2e1acfe652d
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion _downloads/79dda51f6f77b894ece477ed9c8a01d4/example2.py
Expand Up @@ -84,7 +84,7 @@ def runCMRC(phi, loss):
********************** \n\n')

print('\t\t 1. Using 0-1 loss and relu feature mapping \n\n')
runCMRC(phi='relu', loss='0-1')
runCMRC(phi='linear', loss='0-1')

print('\t\t 2. Using log loss and relu feature mapping \n\n')
runCMRC(phi='relu', loss='log')
2 changes: 1 addition & 1 deletion _downloads/cffe955e48c6ac5c42cd9ae87562553d/example2.ipynb
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import time\n\nimport numpy as np\nfrom sklearn import preprocessing\nfrom sklearn.model_selection import StratifiedKFold\n\nfrom MRCpy import CMRC\n# Import the datasets\nfrom MRCpy.datasets import *\n\n# Data sets\nloaders = [load_mammographic, load_haberman, load_indian_liver,\n load_diabetes, load_credit]\ndataName = [\"mammographic\", \"haberman\", \"indian_liver\", \"diabetes\", \"credit\"]\n\n\ndef runCMRC(phi, loss):\n\n random_seed = 0\n res_mean = np.zeros(len(dataName))\n res_std = np.zeros(len(dataName))\n np.random.seed(random_seed)\n\n # Iterate through each of the dataset and fit the MRC classfier.\n for j, load in enumerate(loaders):\n\n # Loading the dataset\n X, Y = load(return_X_y=True)\n r = len(np.unique(Y))\n n, d = X.shape\n\n # Print the dataset name\n print(\" ############## \\n\" + dataName[j] + \" n= \" + str(n) +\n \" , d= \" + str(d) + \", cardY= \" + str(r))\n\n clf = CMRC(phi=phi, loss=loss, use_cvx=True,\n solver='MOSEK', max_iters=10000, s=0.3)\n\n # Generate the partitions of the stratified cross-validation\n cv = StratifiedKFold(n_splits=10, random_state=random_seed,\n shuffle=True)\n\n np.random.seed(random_seed)\n cvError = list()\n auxTime = 0\n\n # Paired and stratified cross-validation\n for train_index, test_index in cv.split(X, Y):\n\n X_train, X_test = X[train_index], X[test_index]\n y_train, y_test = Y[train_index], Y[test_index]\n\n # Normalizing the data\n std_scale = preprocessing.StandardScaler().fit(X_train, y_train)\n X_train = std_scale.transform(X_train)\n X_test = std_scale.transform(X_test)\n\n # Save start time for computing training time\n startTime = time.time()\n\n clf.fit(X_train, y_train)\n\n # Calculate the training time\n auxTime += time.time() - startTime\n\n y_pred = clf.predict(X_test)\n\n cvError.append(np.average(y_pred != y_test))\n\n res_mean[j] = np.average(cvError)\n res_std[j] = np.std(cvError)\n\n print(\" error= \" + \":\\t\" + str(res_mean[j]) + \"\\t+/-\\t\" +\n str(res_std[j]) + \"\\navg_train_time= \" + \":\\t\" +\n str(auxTime / 10) + ' secs' + \"\\n ############## \\n\\n\\n\")\n\n\nif __name__ == '__main__':\n\n print('******************** \\\n Example 2 (CMRC with the additional marginal constraints) \\\n ********************** \\n\\n')\n\n print('\\t\\t 1. Using 0-1 loss and relu feature mapping \\n\\n')\n runCMRC(phi='relu', loss='0-1')\n\n print('\\t\\t 2. Using log loss and relu feature mapping \\n\\n')\n runCMRC(phi='relu', loss='log')"
"import time\n\nimport numpy as np\nfrom sklearn import preprocessing\nfrom sklearn.model_selection import StratifiedKFold\n\nfrom MRCpy import CMRC\n# Import the datasets\nfrom MRCpy.datasets import *\n\n# Data sets\nloaders = [load_mammographic, load_haberman, load_indian_liver,\n load_diabetes, load_credit]\ndataName = [\"mammographic\", \"haberman\", \"indian_liver\", \"diabetes\", \"credit\"]\n\n\ndef runCMRC(phi, loss):\n\n random_seed = 0\n res_mean = np.zeros(len(dataName))\n res_std = np.zeros(len(dataName))\n np.random.seed(random_seed)\n\n # Iterate through each of the dataset and fit the MRC classfier.\n for j, load in enumerate(loaders):\n\n # Loading the dataset\n X, Y = load(return_X_y=True)\n r = len(np.unique(Y))\n n, d = X.shape\n\n # Print the dataset name\n print(\" ############## \\n\" + dataName[j] + \" n= \" + str(n) +\n \" , d= \" + str(d) + \", cardY= \" + str(r))\n\n clf = CMRC(phi=phi, loss=loss, use_cvx=True,\n solver='MOSEK', max_iters=10000, s=0.3)\n\n # Generate the partitions of the stratified cross-validation\n cv = StratifiedKFold(n_splits=10, random_state=random_seed,\n shuffle=True)\n\n np.random.seed(random_seed)\n cvError = list()\n auxTime = 0\n\n # Paired and stratified cross-validation\n for train_index, test_index in cv.split(X, Y):\n\n X_train, X_test = X[train_index], X[test_index]\n y_train, y_test = Y[train_index], Y[test_index]\n\n # Normalizing the data\n std_scale = preprocessing.StandardScaler().fit(X_train, y_train)\n X_train = std_scale.transform(X_train)\n X_test = std_scale.transform(X_test)\n\n # Save start time for computing training time\n startTime = time.time()\n\n clf.fit(X_train, y_train)\n\n # Calculate the training time\n auxTime += time.time() - startTime\n\n y_pred = clf.predict(X_test)\n\n cvError.append(np.average(y_pred != y_test))\n\n res_mean[j] = np.average(cvError)\n res_std[j] = np.std(cvError)\n\n print(\" error= \" + \":\\t\" + str(res_mean[j]) + \"\\t+/-\\t\" +\n str(res_std[j]) + \"\\navg_train_time= \" + \":\\t\" +\n str(auxTime / 10) + ' secs' + \"\\n ############## \\n\\n\\n\")\n\n\nif __name__ == '__main__':\n\n print('******************** \\\n Example 2 (CMRC with the additional marginal constraints) \\\n ********************** \\n\\n')\n\n print('\\t\\t 1. Using 0-1 loss and relu feature mapping \\n\\n')\n runCMRC(phi='linear', loss='0-1')\n\n print('\\t\\t 2. Using log loss and relu feature mapping \\n\\n')\n runCMRC(phi='relu', loss='log')"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion _sources/auto_examples/example2.rst.txt
Expand Up @@ -108,7 +108,7 @@ Example of using CMRC with some of the common classification datasets.
********************** \n\n')
print('\t\t 1. Using 0-1 loss and relu feature mapping \n\n')
runCMRC(phi='relu', loss='0-1')
runCMRC(phi='linear', loss='0-1')
print('\t\t 2. Using log loss and relu feature mapping \n\n')
runCMRC(phi='relu', loss='log')
Expand Down
2 changes: 1 addition & 1 deletion auto_examples/example2.html
Expand Up @@ -253,7 +253,7 @@
<span class="s1"> ********************** </span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>

<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\t\t</span><span class="s1"> 1. Using 0-1 loss and relu feature mapping </span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">runCMRC</span><span class="p">(</span><span class="n">phi</span><span class="o">=</span><span class="s1">&#39;relu&#39;</span><span class="p">,</span> <span class="n">loss</span><span class="o">=</span><span class="s1">&#39;0-1&#39;</span><span class="p">)</span>
<span class="n">runCMRC</span><span class="p">(</span><span class="n">phi</span><span class="o">=</span><span class="s1">&#39;linear&#39;</span><span class="p">,</span> <span class="n">loss</span><span class="o">=</span><span class="s1">&#39;0-1&#39;</span><span class="p">)</span>

<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\t\t</span><span class="s1"> 2. Using log loss and relu feature mapping </span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">runCMRC</span><span class="p">(</span><span class="n">phi</span><span class="o">=</span><span class="s1">&#39;relu&#39;</span><span class="p">,</span> <span class="n">loss</span><span class="o">=</span><span class="s1">&#39;log&#39;</span><span class="p">)</span>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 012012a

Please sign in to comment.