|
|
|
@ -206,18 +206,21 @@ from sklearn.metrics.pairwise import
|
|
|
|
|
cosine_similarity
|
|
|
|
|
dist = 1 - cosine_similarity(tfidf_matrix)
|
|
|
|
|
dist.shape
|
|
|
|
|
|
|
|
|
|
# Метод главных компонент - PCA
|
|
|
|
|
from sklearn.decomposition import IncrementalPCA
|
|
|
|
|
icpa = IncrementalPCA(n_components=2, batch_size=16)
|
|
|
|
|
icpa.fit(dist)
|
|
|
|
|
demo2 = icpa.transform(dist)
|
|
|
|
|
xs, ys = demo2[:, 0], demo2[:, 1]
|
|
|
|
|
|
|
|
|
|
# PCA 3D
|
|
|
|
|
from sklearn.decomposition import IncrementalPCA
|
|
|
|
|
icpa = IncrementalPCA(n_components=3,batch_size=16)
|
|
|
|
|
icpa.fit(dist)
|
|
|
|
|
ddd = icpa.transform(dist)
|
|
|
|
|
xs, ys, zs = ddd[:, 0], ddd[:, 1], ddd[:, 2]
|
|
|
|
|
|
|
|
|
|
#Можно сразу примерно посмотреть, что получится в итоге
|
|
|
|
|
from mpl_toolkits.mplot3d import Axes3D
|
|
|
|
|
fig = plt.figure()
|
|
|
|
|