Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import tensorflow as tf | |
import numpy as np | |
#For 3D Plot | |
import pandas as pd | |
import plotly.express as px | |
#For PCA | |
from sklearn.decomposition import PCA |
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
#For 2D | |
x_train_tranformed_2d = umap.UMAP(n_neighbors=5, n_components=2).fit(x_train).embedding_ | |
x_test_tranformed_2d = umap.UMAP(n_neighbors=5, n_components=2).fit(x_test).embedding_ | |
#For 3D | |
x_train_tranformed_3d = umap.UMAP(n_neighbors=5, n_components=3).fit(x_train).embedding_ | |
x_test_tranformed_3d = umap.UMAP(n_neighbors=5, n_components=3).fit(x_test).embedding_ |
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
#For 2D | |
x_train_transformed_2d = TSNE(n_components=2).fit_transform(x_train) | |
x_test_transformed_2d = TSNE(n_components=2).fit_transform(x_test) | |
#For 3D | |
x_train_transformed_3d = TSNE(n_components=3).fit_transform(x_train) | |
x_test_transformed_3d = TSNE(n_components=3).fit_transform(x_test) |
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
x_train_transformed=PCA(n_components=8).fit_transform(x_train) | |
x_test_transformed=PCA(n_components=8).fit_transform(x_test) | |
#For 2D | |
x_train_transformed_3d = x_train_transformed | |
x_test_transformed_3d = x_test_transformed | |
#For 3D (Same to 2d) | |
x_train_transformed_2d = x_train_transformed | |
x_test_transformed_2d = x_test_transformed |
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
df_train=pd.DataFrame(x_train_transformed_3d[:, 0:3],columns=list("XYZ")) | |
df_train["label"]=np.array(y_train) | |
df_train['purpose'] = np.full(y_train.shape, "train") | |
df_test=pd.DataFrame(x_test_transformed_3d[:, 0:3],columns=list("XYZ")) | |
df_test["label"]=np.array(y_test) | |
df_test['purpose'] = np.full(y_test.shape, "test") | |
df_merged = pd.concat([df_train, df_test]) | |
fig = px.scatter_3d(df_merged, x='X', y='Y', z='Z', color='label', symbol='purpose', size_max=4, opacity=0.7) |
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
plt.scatter(x_train_transformed_2d[:,0],x_train_transformed_2d[:,1],s=20,c=y_train,cmap='tab10', marker="o", alpha=0.3) | |
plt.scatter(x_test_transformed_2d[:,0],x_test_transformed_2d[:,1],s=20,c=y_test,cmap='tab10', marker="x", alpha=0.3) | |
plt.colorbar() |
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
import tensorflow as tf | |
import numpy as np | |
#For 3D Plot | |
import pandas as pd | |
import plotly.express as px | |
#For PCA | |
from sklearn.decomposition import PCA |
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
from tensorflow.keras.datasets import mnist | |
from sklearn.manifold import TSNE | |
import pandas as pd | |
import plotly.express as px | |
#load and adjust mnist data | Mnistのデータをロード | |
(_, _), (x_test, y_test) = mnist.load_data() | |
_, x_test = np.array(x_train, np.float32), np.array(x_test, np.float32) | |
_, x_test = x_train / 255., x_test / 255. |
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
import pandas as pd | |
import plotly.express as px | |
#x_test.shape : (1000, 3) | |
df=pd.DataFrame(x_test,columns=list("XYZ")) | |
#y_test.shape : (1000,) | |
df["label"]=np.array(y_test) | |
#plot here | |
fig = px.scatter_3d(df, x='X', y='Y', z='Z', color='label', size_max=4, opacity=0.7) |
NewerOlder