added small feature to PCA slides
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user