DeprecationWarning in sklearn MiniBatchKMeans
Question: 
    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


Answer: ## Temporarily Suppressing Warnings

The best option to suppress this warning has been described in python's
documentation for the
[warnings](https://docs.python.org/3/library/warnings.html#temporarily-
suppressing-warnings) module.

In this case you can just wrap the clusterizer fitting method using _with_
statement like this:

    
    
    import warnings
    ....
    min_kmeans = MiniBatchKMeans(...)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        min_kmeans.fit(vectors)
    # Rest part of the code
    

