mglearn初探
Posted hardykay
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mglearn初探相关的知识,希望对你有一定的参考价值。
这个是取自于《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初探的主要内容,如果未能解决你的问题,请参考以下文章