-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_random_generated_classification_dataset.py
38 lines (28 loc) · 1.52 KB
/
plot_random_generated_classification_dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Plot randomly generated classification dataset
# Plot several randomly generated 2D classification datasets. This example illustrates the datasets.make_classification function.
# Three binary and two multi-class classification datasets are generated, with different numbers of informative features and clusters per class.
print(__doc__)
import matplotlib.pyplot as plt
from sklearn.datasets import make_classification
plt.figure(figsize=(8, 6))
plt.subplots_adjust(bottom=.05, top=.9, left=.05, right=.95)
plt.subplot(221)
plt.title("One informative feature, one cluster", fontsize='small')
X1, Y1 = make_classification(n_features=2, n_redundant=0, n_informative=1,
n_clusters_per_class=1)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
plt.subplot(222)
plt.title("Two informative features, one cluster", fontsize='small')
X1, Y1 = make_classification(n_features=2, n_redundant=0, n_informative=2,
n_clusters_per_class=1)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
plt.subplot(223)
plt.title("Two informative features, two clusters", fontsize='small')
X2, Y2 = make_classification(n_features=2, n_redundant=0, n_informative=2)
plt.scatter(X2[:, 0], X2[:, 1], marker='o', c=Y2)
plt.subplot(224)
plt.title("Multi-class, two informative features, one cluster", fontsize='small')
X1, Y1 = make_classification(n_features=2, n_redundant=0, n_informative=2,
n_clusters_per_class=1, n_classes=3)
plt.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)
plt.show()