importer
import scipy as sp
import sklearn.base
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
import pandas as pd
Lire les données
data = 'table_rdf.csv'
df = pd.read_csv(data,index_col=0).dropna(axis=1)
Exécution de t-SNE
X_reduced = TSNE(n_components=2, random_state=0).fit_transform(df)
Paramètres de codage couleur Lire les données
data_2 = 'y_rdf.csv'
df_2 = pd.read_csv(data_2,index_col=0).dropna(axis=1)
Trier dans la direction de la colonne (direction verticale)
df2_s = df_2.sort_index()
df2_s.head()
fusionner
df_merge = pd.merge(df, df_2, how='left',right_index=True,left_index=True)
df_merge.head()
Impression
plt.scatter(X_reduced[:, 0], X_reduced[:, 1], c=df_merge['target'])
plt.colorbar()
Faire PCA
from sklearn.decomposition import PCA
pca = PCA(n_components=2).fit(df)
values = pca.transform(df)
fig = plt.figure()
plt.scatter(values[:,0], values[:,1], c=df_merge['target'])
plt.xlabel("value1")
plt.ylabel("value2")
plt.colorbar()
plt.show()
Recommended Posts