码迷,mamicode.com
首页 > 其他好文 > 详细

mglearn初探

时间:2019-05-17 13:25:52      阅读:312      评论:0      收藏:0      [点我收藏+]

标签:info   numpy   sel   image   select   color   数据   test   atp   

这个是取自于《python机器学习基础教程》16页

代码:

# import numpy as np 
# import matplotlib.pyplot as plt
# import pandas as pd
# import mglearn

# from sklearn.datasets import load_iris
# from sklearn.model_selection import train_test_split
# iris_dataset = load_iris()
# X_train,X_test,y_train,y_test = train_test_split(iris_dataset[‘data‘],iris_dataset[‘target‘],random_state=0)
# # 利用X_train中的数据创建DataFrame
# # # 利用iris_dataset.feature_names中的字符串对数据列进行标记
# iris_dataframe = pd.DataFrame(X_train,columns=iris_dataset.feature_names)

# grr = pd.plotting.scatter_matrix(iris_dataframe,c=y_train,figsize=(15,15),marker=‘o‘,hist_kwds={‘bins‘:20},s=60,alpha=8,cmap=mglearn.cm3)

# grr.show()

import mglearn
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.datasets import load_iris
iris_dataset = load_iris()
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test = train_test_split(iris_dataset[‘data‘],iris_dataset[‘target‘],random_state=0)
iris_dataframe=pd.DataFrame(X_train,columns=iris_dataset.feature_names)
grr = pd.plotting.scatter_matrix(iris_dataframe,marker=‘o‘,c = y_train,hist_kwds={‘bins‘:20},cmap=mglearn.cm3)

plt.show()

效果:

技术图片

因果:母鸡

mglearn初探

标签:info   numpy   sel   image   select   color   数据   test   atp   

原文地址:https://www.cnblogs.com/hardykay/p/10880604.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!