标签:iris datasets target True names print data sklearn
sklearn.datasets
.load_iris()
参数:
- return_X_y ; bool, default=False :If True, returns
(data, target)
instead of a Bunch object. See below for more information about thedata
andtarget
object. - as_frame ; bool, default=False :If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric). The target is a pandas DataFrame or Series depending on the number of target columns. If
return_X_y
is True, then (data
,target
) will be pandas DataFrames or Series as described below.
返回:
- data{ndarray, dataframe} of shape (150, 4)
-
The data matrix. If
as_frame=True
,data
will be a pandas DataFrame.
- target: {ndarray, Series} of shape (150,)
-
The classification target. If
as_frame=True
,target
will be a pandas Series.
- feature_names: list
-
The names of the dataset columns.
- target_names: list
-
The names of target classes.
- frame: DataFrame of shape (150, 5)
-
Only present when
as_frame=True
. DataFrame withdata
andtarget
.New in version 0.23.
- DESCR: str
-
The full description of the dataset.
- filename: str
-
The path to the location of the data.
- (data, target) tuple if
return_X_y
is True
例子:
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
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。