Wine Dataset

A function that loads the Wine dataset into NumPy arrays.

from mlxtend.data import wine_data

Overview

The Wine dataset for classification.

Samples 178
Features 13
Classes 3
Data Set Characteristics: Multivariate
Attribute Characteristics: Integer, Real
Associated Tasks: Classification
Missing Values None
column attribute
1) Class Label
2) Alcohol
3) Malic acid
4) Ash
5) Alcalinity of ash
6) Magnesium
7) Total phenols
8) Flavanoids
9) Nonflavanoid phenols
10) Proanthocyanins
11) Color intensity
12) Hue
13) OD280/OD315 of diluted wines
14) Proline
class samples
0 59
1 71
2 48

References

%load_ext autoreload
%autoreload 2
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

Example 1 - Dataset overview

from mlearner.data import wine_data
X, y = wine_data()

print('Dimensions: %s x %s' % (X.shape[0], X.shape[1]))

print('\n1st row')
print(X.iloc[0])
Dimensions: 178 x 12

1st row
alcohol                            1.71
malic acid                         2.43
ash                               15.60
ash alcalinity                   127.00
magnesium                          2.80
total phenols                      3.06
flavanoids                         0.28
nonflavanoid phenols               2.29
proanthocyanins                    5.64
color intensity                    1.04
hue                                3.92
OD280/OD315 of diluted wines    1065.00
Name: 14.23, dtype: float64
X
alcohol malic acid ash ash alcalinity magnesium total phenols flavanoids nonflavanoid phenols proanthocyanins color intensity hue OD280/OD315 of diluted wines
14.23 1.71 2.43 15.6 127.0 2.80 3.06 0.28 2.29 5.64 1.04 3.92 1065
13.20 1.78 2.14 11.2 100.0 2.65 2.76 0.26 1.28 4.38 1.05 3.40 1050
13.16 2.36 2.67 18.6 101.0 2.80 3.24 0.30 2.81 5.68 1.03 3.17 1185
14.37 1.95 2.50 16.8 113.0 3.85 3.49 0.24 2.18 7.80 0.86 3.45 1480
13.24 2.59 2.87 21.0 118.0 2.80 2.69 0.39 1.82 4.32 1.04 2.93 735
14.20 1.76 2.45 15.2 112.0 3.27 3.39 0.34 1.97 6.75 1.05 2.85 1450
14.39 1.87 2.45 14.6 96.0 2.50 2.52 0.30 1.98 5.25 1.02 3.58 1290
14.06 2.15 2.61 17.6 121.0 2.60 2.51 0.31 1.25 5.05 1.06 3.58 1295
14.83 1.64 2.17 14.0 97.0 2.80 2.98 0.29 1.98 5.20 1.08 2.85 1045
13.86 1.35 2.27 16.0 98.0 2.98 3.15 0.22 1.85 7.22 1.01 3.55 1045
14.10 2.16 2.30 18.0 105.0 2.95 3.32 0.22 2.38 5.75 1.25 3.17 1510
14.12 1.48 2.32 16.8 95.0 2.20 2.43 0.26 1.57 5.00 1.17 2.82 1280
13.75 1.73 2.41 16.0 89.0 2.60 2.76 0.29 1.81 5.60 1.15 2.90 1320
14.75 1.73 2.39 11.4 91.0 3.10 3.69 0.43 2.81 5.40 1.25 2.73 1150
14.38 1.87 2.38 12.0 102.0 3.30 3.64 0.29 2.96 7.50 1.20 3.00 1547
13.63 1.81 2.70 17.2 112.0 2.85 2.91 0.30 1.46 7.30 1.28 2.88 1310
14.30 1.92 2.72 20.0 120.0 2.80 3.14 0.33 1.97 6.20 1.07 2.65 1280
13.83 1.57 2.62 20.0 115.0 2.95 3.40 0.40 1.72 6.60 1.13 2.57 1130
14.19 1.59 2.48 16.5 108.0 3.30 3.93 0.32 1.86 8.70 1.23 2.82 1680
13.64 3.10 2.56 15.2 116.0 2.70 3.03 0.17 1.66 5.10 0.96 3.36 845
14.06 1.63 2.28 16.0 126.0 3.00 3.17 0.24 2.10 5.65 1.09 3.71 780
12.93 3.80 2.65 18.6 102.0 2.41 2.41 0.25 1.98 4.50 1.03 3.52 770
13.71 1.86 2.36 16.6 101.0 2.61 2.88 0.27 1.69 3.80 1.11 4.00 1035
12.85 1.60 2.52 17.8 95.0 2.48 2.37 0.26 1.46 3.93 1.09 3.63 1015
13.50 1.81 2.61 20.0 96.0 2.53 2.61 0.28 1.66 3.52 1.12 3.82 845
13.05 2.05 3.22 25.0 124.0 2.63 2.68 0.47 1.92 3.58 1.13 3.20 830
13.39 1.77 2.62 16.1 93.0 2.85 2.94 0.34 1.45 4.80 0.92 3.22 1195
13.30 1.72 2.14 17.0 94.0 2.40 2.19 0.27 1.35 3.95 1.02 2.77 1285
13.87 1.90 2.80 19.4 107.0 2.95 2.97 0.37 1.76 4.50 1.25 3.40 915
14.02 1.68 2.21 16.0 96.0 2.65 2.33 0.26 1.98 4.70 1.04 3.59 1035
... ... ... ... ... ... ... ... ... ... ... ... ...
13.32 3.24 2.38 21.5 92.0 1.93 0.76 0.45 1.25 8.42 0.55 1.62 650
13.08 3.90 2.36 21.5 113.0 1.41 1.39 0.34 1.14 9.40 0.57 1.33 550
13.50 3.12 2.62 24.0 123.0 1.40 1.57 0.22 1.25 8.60 0.59 1.30 500
12.79 2.67 2.48 22.0 112.0 1.48 1.36 0.24 1.26 10.80 0.48 1.47 480
13.11 1.90 2.75 25.5 116.0 2.20 1.28 0.26 1.56 7.10 0.61 1.33 425
13.23 3.30 2.28 18.5 98.0 1.80 0.83 0.61 1.87 10.52 0.56 1.51 675
12.58 1.29 2.10 20.0 103.0 1.48 0.58 0.53 1.40 7.60 0.58 1.55 640
13.17 5.19 2.32 22.0 93.0 1.74 0.63 0.61 1.55 7.90 0.60 1.48 725
13.84 4.12 2.38 19.5 89.0 1.80 0.83 0.48 1.56 9.01 0.57 1.64 480
12.45 3.03 2.64 27.0 97.0 1.90 0.58 0.63 1.14 7.50 0.67 1.73 880
14.34 1.68 2.70 25.0 98.0 2.80 1.31 0.53 2.70 13.00 0.57 1.96 660
13.48 1.67 2.64 22.5 89.0 2.60 1.10 0.52 2.29 11.75 0.57 1.78 620
12.36 3.83 2.38 21.0 88.0 2.30 0.92 0.50 1.04 7.65 0.56 1.58 520
13.69 3.26 2.54 20.0 107.0 1.83 0.56 0.50 0.80 5.88 0.96 1.82 680
12.85 3.27 2.58 22.0 106.0 1.65 0.60 0.60 0.96 5.58 0.87 2.11 570
12.96 3.45 2.35 18.5 106.0 1.39 0.70 0.40 0.94 5.28 0.68 1.75 675
13.78 2.76 2.30 22.0 90.0 1.35 0.68 0.41 1.03 9.58 0.70 1.68 615
13.73 4.36 2.26 22.5 88.0 1.28 0.47 0.52 1.15 6.62 0.78 1.75 520
13.45 3.70 2.60 23.0 111.0 1.70 0.92 0.43 1.46 10.68 0.85 1.56 695
12.82 3.37 2.30 19.5 88.0 1.48 0.66 0.40 0.97 10.26 0.72 1.75 685
13.58 2.58 2.69 24.5 105.0 1.55 0.84 0.39 1.54 8.66 0.74 1.80 750
13.40 4.60 2.86 25.0 112.0 1.98 0.96 0.27 1.11 8.50 0.67 1.92 630
12.20 3.03 2.32 19.0 96.0 1.25 0.49 0.40 0.73 5.50 0.66 1.83 510
12.77 2.39 2.28 19.5 86.0 1.39 0.51 0.48 0.64 9.90 0.57 1.63 470
14.16 2.51 2.48 20.0 91.0 1.68 0.70 0.44 1.24 9.70 0.62 1.71 660
13.71 5.65 2.45 20.5 95.0 1.68 0.61 0.52 1.06 7.70 0.64 1.74 740
13.40 3.91 2.48 23.0 102.0 1.80 0.75 0.43 1.41 7.30 0.70 1.56 750
13.27 4.28 2.26 20.0 120.0 1.59 0.69 0.43 1.35 10.20 0.59 1.56 835
13.17 2.59 2.37 20.0 120.0 1.65 0.68 0.53 1.46 9.30 0.60 1.62 840
14.13 4.10 2.74 24.5 96.0 2.05 0.76 0.56 1.35 9.20 0.61 1.60 560

178 rows × 12 columns

import numpy as np
print('Classes: %s' % np.unique(y))
print('Class distribution: %s' % np.bincount(y))

API