vectors = model.syn0
n_clusters_kmeans = 20 # more for visualization 100 better for clustering
min_kmeans = MiniBatchKMeans(init='k-means++', n_clusters=n_clusters_kmeans, n_init=10)
min_kmeans.fit(vectors)
X_reduced = TruncatedSVD(n_components=50, random_state=0).fit_transform(vectors)
X_embedded = TSNE(n_components=2, perplexity=40, verbose=2).fit_transform(X_reduced)
fig = plt.figure(figsize=(10, 10))
ax = plt.axes(frameon=False)
plt.setp(ax, xticks=(), yticks=())
plt.subplots_adjust(left=0.0, bottom=0.0, right=1.0, top=0.9, wspace=0.0, hspace=0.0)
plt.scatter(X_embedded[:, 0], X_embedded[:, 1], c=None, marker="x")
plt.show()
I want to plot vectors. I am using sklearn.cluster MiniBatchKMeans. Above code is giving me following deprecation error:
/usr/local/lib/python3.5/site-packages/sklearn/cluster/k_means_.py:1328: DeprecationWarning: This function is deprecated. Please call randint(0, 99 + 1) instead 0, n_samples - 1, self.batch_size)
Any suggestions are appreciated. Thanks
How do I ignore warning in Sklearn? If you wish to squelch deprecation warnings, you can start Python with -Wi::Deprecation . This sets all deprecation warnings to ignored. There is also an Scikit-beam-specific ~scikit-beam.
Read more in the User Guide. Parameters: n_clustersint, default=8. The number of clusters to form as well as the number of centroids to generate.
This is a known issue and a fix has already been merged for this. Please refer to gh:scikit-learn#6863.
Statistically the next release should be released around Oct. 2016. Till then following are the options:
--> Suppress as mentioned in frist's answer on this question
import warnings
....
min_kmeans = MiniBatchKMeans(...)
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
min_kmeans.fit(vectors)
# Rest part of the code
--> Install scikit-learn from master:
pip install git+git://github.com/scikit-learn/scikit-learn.git
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With