Python | Create Test DataSets using Sklearn

Configurare noua (How To)

Situatie

Python’s Sklearn library provides a great sample dataset generator which will help you to create your own custom dataset. It’s fast and very easy to use. Following are the types of samples it provides.

For all the above methods you need to import sklearn.datasets.samples_generator.

Solutie

Pasi de urmat

# importing libraries
from sklearn.datasets.samples_generator

# matplotlib for ploting
from matplotlib import pyplot as plt
from matplotlib import style

# Creating Test DataSets using sklearn.datasets.make_blobs
from sklearn.datasets.samples_generator import make_blobs
from matplotlib import pyplot as plt
from matplotlib import style

style.use(“fivethirtyeight”)

X, y = make_blobs(n_samples = 100, centers = 3,
cluster_std = 1, n_features = 2)

plt.scatter(X[:, 0], X[:, 1], s = 40, color = ‘g’)
plt.xlabel(“X”)
plt.ylabel(“Y”)

plt.show()
plt.clf()

Output:

Tip solutie

Permanent

Voteaza

(16 din 30 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?