added some examples

This commit is contained in:
mhjensen
2019-10-24 13:59:10 +02:00
parent aecd18f3f7
commit 63659da7d8
40 changed files with 830 additions and 520 deletions
+7 -3
View File
@@ -14,7 +14,6 @@ correlation_matrix = cancerpd.corr().round(1)
# use the heatmap function from seaborn to plot the correlation matrix
# 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)
@@ -35,6 +34,11 @@ X_test_scaled = scaler.transform(X_test)
logreg.fit(X_train_scaled, y_train)
print("Test set accuracy scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
#thereafter we do a PCA with Scikit-learn
from sklearn.decomposition import PCA
pca = PCA(n_components = 2)
X2D_train = pca.fit_transform(X_train_scaled)
X2D_test = pca.fit_transform(X_test_scaled)
logreg.fit(X2D_train,y_train)
print("Test set accuracy scaled data: {:.2f}".format(logreg.score(X2D_test,y_test)))