From 48d9e9a6dd7ea979dd7b1935aa1e209fd0113468 Mon Sep 17 00:00:00 2001 From: Vladimir Protsenko Date: Mon, 6 Sep 2021 19:29:25 +0000 Subject: [PATCH] Update lab2.md --- lab2.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lab2.md b/lab2.md index 1084ab6..fad73e1 100644 --- a/lab2.md +++ b/lab2.md @@ -148,9 +148,7 @@ print (km.labels_) # MiniBatchKMeans from sklearn.cluster import MiniBatchKMeans -mbk = MiniBatchKMeans(init='random', -n_clusters=num_clusters) #(init='k-means++', -‘random’ or an ndarray) +mbk = MiniBatchKMeans(init='random', n_clusters=num_clusters) #(init='k-means++',‘random’ or an ndarray) mbk.fit_transform(tfidf_matrix) mbk.fit(tfidf_matrix) miniclusters = mbk.labels_.tolist() @@ -210,20 +208,17 @@ dist = 1 - cosine_similarity(tfidf_matrix) dist.shape # Метод главных компонент - PCA from sklearn.decomposition import IncrementalPCA -icpa = IncrementalPCA(n_components=2, -batch_size=16) +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 = 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() ax = fig.add_subplot(111, projection='3d') @@ -232,4 +227,4 @@ ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') plt.show() -``` \ No newline at end of file +```