python随机划分数据集_Python之机器学习-sklearn生成随机数据
sklearn-生成隨機數(shù)據(jù)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
from sklearn import datasets
%matplotlib inline
font = FontProperties(fname='/Library/Fonts/Heiti.ttc')
多標簽分類數(shù)據(jù)
X1, y1 = datasets.make_multilabel_classification(
n_samples=1000, n_classes=4, n_features=2, random_state=1)
datasets.make_multilabel_classification()
plt.scatter(X1[:, 0], X1[:, 1], marker='*', c=y1)
plt.show()
生成分類數(shù)據(jù)
import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize=(10, 10))
plt.subplot(221)
plt.title("One informative feature, one cluster per class", fontsize=12)
X1, y1 = datasets.make_classification(n_samples=1000, random_state=1, n_features=2, n_redundant=0, n_informative=1,
n_clusters_per_class=1)
plt.scatter(X1[:, 0], X1[:, 1], marker='*', c=y1)
plt.subplot(222)
plt.title("Two informative features, one cluster per class", fontsize=12)
X1, y1 = datasets.make_classification(n_samples=1000, random_state=1, n_features=2, n_redundant=0, n_informative=2,
n_clusters_per_class=1)
plt.scatter(X1[:, 0], X1[:, 1], marker='*', c=y1)
plt.subplot(223)
plt.title("Two informative features, two clusters per class", fontsize=12)
X1, y1 = datasets.make_classification(
n_samples=1000, random_state=1, n_features=2, n_redundant=0, n_informative=2)
plt.scatter(X1[:, 0], X1[:, 1], marker='*', c=y1)
plt.subplot(224)
plt.title("Multi-class, two informative features, one cluster",
fontsize=12)
X1, y1 = datasets.make_classification(n_samples=1000, random_state=1, n_features=2, n_redundant=0, n_informative=2,
n_clusters_per_class=1, n_classes=4)
plt.scatter(X1[:, 0], X1[:, 1], marker='*', c=y1)
plt.show()
圖像數(shù)據(jù)集
# 圖像數(shù)據(jù)集
china = datasets.load_sample_image('china.jpg')
plt.axis('off')
plt.title('中國頤和園圖像', fontproperties=font, fontsize=20)
plt.imshow(china)
plt.show()
總結(jié)
以上是生活随笔為你收集整理的python随机划分数据集_Python之机器学习-sklearn生成随机数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux安装winetim简单教程,[
- 下一篇: 操作系统 --- [笔记]功能、组成