From 050b64e9bf9395376a113a421ffe783361af44b1 Mon Sep 17 00:00:00 2001 From: mhjensen Date: Thu, 17 Oct 2019 15:42:08 +0200 Subject: [PATCH] added small feature to PCA slides --- doc/pub/DimRed/html/._DimRed-bs007.html | 5 +++++ doc/pub/DimRed/html/DimRed-reveal.html | 5 +++++ doc/pub/DimRed/html/DimRed-solarized.html | 5 +++++ doc/pub/DimRed/html/DimRed.html | 5 +++++ doc/pub/DimRed/ipynb/DimRed.ipynb | 5 +++++ doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz | Bin 191 -> 191 bytes doc/pub/DimRed/pdf/DimRed-minted.pdf | Bin 203641 -> 203641 bytes doc/src/DimRed/DimRed.do.txt | 5 +++++ doc/src/DimRed/PCAcancer.py | 19 +++---------------- 9 files changed, 33 insertions(+), 16 deletions(-) diff --git a/doc/pub/DimRed/html/._DimRed-bs007.html b/doc/pub/DimRed/html/._DimRed-bs007.html index 4005925d3..0334cf680 100644 --- a/doc/pub/DimRed/html/._DimRed-bs007.html +++ b/doc/pub/DimRed/html/._DimRed-bs007.html @@ -182,6 +182,11 @@ correlation_matrix = cancerpd# annot = True to print the values inside the square sns.heatmap(data=correlation_matrix, annot=True) plt.show() + +#print eigvalues of correlation matrix +EigValues, EigVectors = np.linalg.eig(correlation_matrix) +print(EigValues) + #split into train and test and then scale thereafter X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) diff --git a/doc/pub/DimRed/html/DimRed-reveal.html b/doc/pub/DimRed/html/DimRed-reveal.html index c8b2d434c..9fa26b993 100644 --- a/doc/pub/DimRed/html/DimRed-reveal.html +++ b/doc/pub/DimRed/html/DimRed-reveal.html @@ -459,6 +459,11 @@ correlation_matrix = cancerpd.corr().round(1 # annot = True to print the values inside the square sns.heatmap(data=correlation_matrix, annot=True) plt.show() + +#print eigvalues of correlation matrix +EigValues, EigVectors = np.linalg.eig(correlation_matrix) +print(EigValues) + #split into train and test and then scale thereafter X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) diff --git a/doc/pub/DimRed/html/DimRed-solarized.html b/doc/pub/DimRed/html/DimRed-solarized.html index bca2cf49d..6b682f7ea 100644 --- a/doc/pub/DimRed/html/DimRed-solarized.html +++ b/doc/pub/DimRed/html/DimRed-solarized.html @@ -442,6 +442,11 @@ correlation_matrix = cancerpd.corr().round(1 # annot = True to print the values inside the square sns.heatmap(data=correlation_matrix, annot=True) plt.show() + +#print eigvalues of correlation matrix +EigValues, EigVectors = np.linalg.eig(correlation_matrix) +print(EigValues) + #split into train and test and then scale thereafter X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) diff --git a/doc/pub/DimRed/html/DimRed.html b/doc/pub/DimRed/html/DimRed.html index 53607192d..5b3216924 100644 --- a/doc/pub/DimRed/html/DimRed.html +++ b/doc/pub/DimRed/html/DimRed.html @@ -447,6 +447,11 @@ correlation_matrix = cancerpd# annot = True to print the values inside the square sns.heatmap(data=correlation_matrix, annot=True) plt.show() + +#print eigvalues of correlation matrix +EigValues, EigVectors = np.linalg.eig(correlation_matrix) +print(EigValues) + #split into train and test and then scale thereafter X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) diff --git a/doc/pub/DimRed/ipynb/DimRed.ipynb b/doc/pub/DimRed/ipynb/DimRed.ipynb index 8bf7e3023..f9d4059e1 100644 --- a/doc/pub/DimRed/ipynb/DimRed.ipynb +++ b/doc/pub/DimRed/ipynb/DimRed.ipynb @@ -330,6 +330,11 @@ "# annot = True to print the values inside the square\n", "sns.heatmap(data=correlation_matrix, annot=True)\n", "plt.show()\n", + "\n", + "#print eigvalues of correlation matrix\n", + "EigValues, EigVectors = np.linalg.eig(correlation_matrix)\n", + "print(EigValues)\n", + "\n", "#split into train and test and then scale thereafter\n", "X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)\n", "print(X_train.shape)\n", diff --git a/doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz b/doc/pub/DimRed/ipynb/ipynb-DimRed-src.tar.gz index 927742fa6b9f1a5d8eee5fac2400195dc970494e..2d3fa6507d75ebb65d9ee2911f3e13c41836a484 100644 GIT binary patch literal 191 zcmV;w06_mAiwFReZ>U`W1MSbv3c@f92k@Qu6nTP?ZfkcI=D~v?!x!jS=c=xqZ3ph{ z-3RDN@iIi{@A4-kgrwMR^8Ge)cNeS%5m}nTlo_LQV!YHdLMV`g(imCB#s-okVHg0e zchXC59XI1C%~>cb)Z4jntgb)oSzdu>{)uBFE$j}1YqSETohY@wKrY)tRFUikRYIkO tomybTt(QgsR|D{>l1^&HuVH8O$?(=j;jf?ZJkRsK_5hJy)=mHj003B;T&Ms5 literal 191 zcmV;w06_mAiwFS3W2jvK1MSbv3c@f92k@Qu6nTP?ZtHdy=D~v?!x!ji=c=xqZ3ph{ z-3RDN@iIi{@A4-kgrwYViv2cncNeS%5wkRfDf5iZiSbg;2%$g{N@L7Ojwv8X5=sKV z^-g-}tz%|9r8x^_g?c+Tj@9*tJ7yZoM=Dm>Pg_E}hhhUBk}klVPom!e2k*d7kHe?ExihtZM)W002WgS$O~e diff --git a/doc/pub/DimRed/pdf/DimRed-minted.pdf b/doc/pub/DimRed/pdf/DimRed-minted.pdf index 906b00f9f6cf87c0868b2a448b07c53c4317d0ce..6bbfbdce6ef9a0fb28207f6faf0fd3479fdbe8eb 100644 GIT binary patch delta 136 zcmeyljpye!o`x327N#xC_qa4nO$?1Kv<-~Z4Gh#Zx%7SWQ(O{DQWZ2@tc(l{Ee#C} z%?-gywzF|FpXPHmb+mAHG_){sG%+$XH8ip`b2D_aFmN$8a5ghFvM@EWQ?MbVWV?tI Hb1EYM$SxsQ delta 136 zcmeyljpye!o`x327N#xC_qa4nObrc9v<-~Z4Gh#Zx%7SWQ(O{DQWZ2@tc(l{Ee#C} z%?-gywzF|FpXPIRb~UnaF*CO`G_!Daa&a^@H86B`G;=mGb~H9IHghwzQ?MbVWV?tI Hb1EYM+AAU1 diff --git a/doc/src/DimRed/DimRed.do.txt b/doc/src/DimRed/DimRed.do.txt index 26cdddd72..536a45c0f 100644 --- a/doc/src/DimRed/DimRed.do.txt +++ b/doc/src/DimRed/DimRed.do.txt @@ -287,6 +287,11 @@ correlation_matrix = cancerpd.corr().round(1) # annot = True to print the values inside the square sns.heatmap(data=correlation_matrix, annot=True) plt.show() + +#print eigvalues of correlation matrix +EigValues, EigVectors = np.linalg.eig(correlation_matrix) +print(EigValues) + #split into train and test and then scale thereafter X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) diff --git a/doc/src/DimRed/PCAcancer.py b/doc/src/DimRed/PCAcancer.py index b4983907e..c0b2f2219 100644 --- a/doc/src/DimRed/PCAcancer.py +++ b/doc/src/DimRed/PCAcancer.py @@ -8,22 +8,6 @@ import pandas as pd cancerpd = pd.DataFrame(cancer.data, columns=cancer.feature_names) -fig, axes = plt.subplots(15,2,figsize=(10,20)) -malignant = cancer.data[cancer.target == 0] -benign = cancer.data[cancer.target == 1] -ax = axes.ravel() - -for i in range(30): - _, bins = np.histogram(cancer.data[:,i], bins =50) - ax[i].hist(malignant[:,i], bins = bins, alpha = 0.5) - ax[i].hist(benign[:,i], bins = bins, alpha = 0.5) - ax[i].set_title(cancer.feature_names[i]) - ax[i].set_yticks(()) -ax[0].set_xlabel("Feature magnitude") -ax[0].set_ylabel("Frequency") -ax[0].legend(["Malignant", "Benign"], loc ="best") -fig.tight_layout() -plt.show() import seaborn as sns correlation_matrix = cancerpd.corr().round(1) @@ -31,6 +15,9 @@ correlation_matrix = cancerpd.corr().round(1) # annot = True to print the values inside the square sns.heatmap(data=correlation_matrix, annot=True) plt.show() +EigValues, EigVectors = np.linalg.eig(correlation_matrix) +print(EigValues) + X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0) print(X_train.shape) print(X_test.shape)