Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use make_blobs in sklearn

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report