load_wine#
- sklearn.datasets.load_wine(*, return_X_y=False, as_frame=False)[source]#
加载并返回葡萄酒数据集(分类)。
版本 0.18 新增。
The wine dataset is a classic and very easy multi-class classification dataset.
类别数
3
每类的样本数
[59,71,48]
样本总数
178
维度
13
特征值范围
real, positive
The copy of UCI ML Wine Data Set dataset is downloaded and modified to fit standard format from: https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data
Read more in the User Guide.
- 参数:
- return_X_ybool, default=False
如果为 True,则返回
(data, target)而不是 Bunch 对象。有关data和target对象的更多信息,请参阅下文。- as_framebool, default=False
如果为 True,则数据是包含具有相应 dtypes(数字)的列的 pandas DataFrame。目标是 pandas DataFrame 或 Series,具体取决于目标列数。如果
return_X_y为 True,则 (data,target) 将是如下所述的 pandas DataFrames 或 Series。0.23 版本新增。
- 返回:
- data
Bunch Dictionary-like object, with the following attributes.
- data{ndarray, dataframe} of shape (178, 13)
数据矩阵。如果
as_frame=True,data将是一个 pandas DataFrame。- target: {ndarray, Series} of shape (178,)
分类目标。如果
as_frame=True,target将是一个 pandas Series。- feature_names: list
数据集列的名称。
- target_names: list
The names of target classes.
- frame: DataFrame of shape (178, 14)
仅当
as_frame=True时存在。包含data和target的 DataFrame。0.23 版本新增。
- DESCR: str
The full description of the dataset.
- (data, target)tuple if
return_X_yis True A tuple of two ndarrays by default. The first contains a 2D array of shape (178, 13) with each row representing one sample and each column representing the features. The second array of shape (178,) contains the target samples.
- data
示例
Let’s say you are interested in the samples 10, 80, and 140, and want to know their class name.
>>> from sklearn.datasets import load_wine >>> data = load_wine() >>> data.target[[10, 80, 140]] array([0, 1, 2]) >>> list(data.target_names) [np.str_('class_0'), np.str_('class_1'), np.str_('class_2')]