importieren
import scipy as sp
import sklearn.base
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
import pandas as pd
Daten lesen
data = 'table_rdf.csv'
df = pd.read_csv(data,index_col=0).dropna(axis=1)
Ausführung von t-SNE
X_reduced = TSNE(n_components=2, random_state=0).fit_transform(df)
Farbcodierungseinstellungen Daten lesen
data_2 = 'y_rdf.csv'
df_2 = pd.read_csv(data_2,index_col=0).dropna(axis=1)
In Spaltenrichtung sortieren (vertikale Richtung)
df2_s = df_2.sort_index()
df2_s.head()
verschmelzen
df_merge = pd.merge(df, df_2, how='left',right_index=True,left_index=True)
df_merge.head()
plt.scatter(X_reduced[:, 0], X_reduced[:, 1], c=df_merge['target'])
plt.colorbar()
PCA machen
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