sklearn.datasets
阿新 • • 發佈:2022-01-28
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))
因上求緣,果上努力~~~~ 作者:cute_Learner,轉載請註明原文連結:https://www.cnblogs.com/BlairGrowing/p/15852435.html