How to use make_blobs in sklearn
This article is about how to use make_blobs in sklearn. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The make_blobs function in sklearn is mainly used to generate datasets, as shown below:
1. The usage of calling make_blobsfrom sklearn.datasets import make_blobs2.make_blobs data, label = make_blobs (n_features=2, n_samples=100, centers=3, random_state=3, cluster_std= [0.8,2,5])
N_features indicates how many eigenvalues are in each sample.
N_samples indicates the number of samples
Centers is the number of cluster centers, which can be understood as the number of species of label.
Random_state is a random seed, which can fix the generated data.
Cluster_std sets the variance for each category
The following examples are given:
'' create a training dataset''from sklearn.datasets import make_blobsdata, label = make_blobs (n_features=2, n_samples=100, centers=2, random_state=2019, cluster_std= [0.6, 0.7])
Take a look at the generated dataset:
Data has 2 features (n_features=2), and the number of samples is 100 (n_samples=100).
Then take a look at the generated label:
Label has only 0 or 1 (centers=2), and the dimension is 100
Random_state given a value, each generated dataset is fixed, convenient for later reproduction, the default is each random generation, should pay attention to!
All right, so we have a dataset we want, and then we can start some follow-up work!
Thank you for reading! This is the end of the article on "how to use make_blobs in sklearn". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!