Created
April 25, 2021 05:01
-
-
Save Reznov9185/756875c58cd1a7b141bdbe3456060436 to your computer and use it in GitHub Desktop.
GDM_functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prinf("hello") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#concataning eigenvectors & eigenvectorsNeg eigenvectorsConcat = np.concatenate((eigenvectors, eigenvectorsNeg), axis=0)
#concataning targets y & yNeg y = np.repeat(1, 78) yNeg = np.repeat(0, 78) yConcat = np.concatenate((y, yNeg), axis=0)
# creating a dataframe using eigenvectorsConcat & yConcat embeddings = [] for id in range(156): embedding = eigenvectorsConcat[id] #club = KG.nodes[id]['club'] embeddings.append([embedding[0], embedding[1], embedding[2], embedding[3], yConcat[id]]) df = pd.DataFrame(embeddings, columns=['x_a', 'x_b', 'x_c', 'x_d', 'y']) df
`features = ['x_a', 'x_b', 'x_c', 'x_d']
X = dfDataframe[features]
#X
y = dfDataframe['y']
y
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.34, stratify=y, random_state=1)`
`from sklearn.neural_network import MLPClassifier
classifier = 'MLPClassifier'
clf = MLPClassifier(random_state=1, max_iter=390).fit(X_train, y_train)
#print(classifier+ ' classifier for ' +dataset+ ' dataset')
print(classifier+ ' Run Time:')
%timeit clf.fit(X_train, y_train)
print(f"Train score: {clf.score(X_train, y_train)}")
print(f"Test score: {clf.score(X_test, y_test)}")
clf.score(X_test, y_test)
print('Accuracy for ' +classifier+ ' classifier: %.2f' % clf.score(X_test, y_test))
from sklearn import metrics
predicted = clf.predict(X_test)
print(f"Classification report for classifier MLPClassifier:\n"
f"{metrics.classification_report(y_test, predicted)}\n")`
`import seaborn as sns
cols = ['x_a','x_b','x_c','x_d','y']
correlation_coefficient = np.corrcoef(df[cols].values.T)
print(correlation_coefficient)
sns.heatmap(correlation_coefficient, annot=True,
yticklabels = cols, xticklabels=cols)
plt.show()`