其他分享
首页 > 其他分享> > sklearn.datasets

sklearn.datasets

作者:互联网

 

 

sklearn.datasets.load_iris()

参数:

返回:

The data matrix. If as_frame=Truedata will be a pandas DataFrame.

The classification target. If as_frame=Truetarget will be a pandas Series.

The names of the dataset columns.

The names of target classes.

Only present when as_frame=True. DataFrame with data and target.

New in version 0.23.

The full description of the dataset.

The path to the location of the data.

例子:

from sklearn import  datasets

iris_data = datasets.load_iris()
print(iris_data.data) #返回样本数据
print(iris_data.data.shape) #返回样本数据形状
print(iris_data.target) #返回样本数据的label
print(iris_data.target.shape) #返回样本数据lable形状
print(iris_data.target[[0,50,149]]) #返回样本数据 x_0,x_50 ,x_149 的label
print(iris_data.target_names) #返回lable 名称
print(iris_data.target_names[0:4])
print(iris_data.target_names[[0,1,2]])
print(iris_data.feature_names) #返回特征名称
print(iris_data.feature_names[0:2]) #返回特征名称
print(iris_data.DESCR) #数据描述
print(iris_data.filename) #返回数据存放位置
X ,y = datasets.load_iris(return_X_y=True) 
print(X.shape)
print(y.shape)
iris_data = datasets.load_iris(as_frame=True)
print(type(iris_data))

 

标签:iris,datasets,target,True,names,print,data,sklearn
来源: https://www.cnblogs.com/BlairGrowing/p/15852435.html