Professional Documents
Culture Documents
Wine
Wine
In [18]: df1=load_wine()
In [29]: print(df1.DESCR)
.. _wine_dataset:
- class:
- class_0
- class_1
- class_2
:Summary Statistics:
The data is the results of a chemical analysis of wines grown in the same
region in Italy by three different cultivators. There are thirteen different
measurements taken for different constituents found in the three types of
wine.
Original Owners:
Citation:
.. topic:: References
The data was used with many others for comparing various
classifiers. The classes are separable, though only RDA
has achieved 100% correct classification.
(RDA : 100%, QDA 99.4%, LDA 98.9%, 1NN 96.1% (z-transformed data))
(All results using the leave-one-out technique)
In [34]: wine_features=pd.DataFrame(df1.data,columns=df1.feature_names)
wine_features.head()
Out[34]: alcohol malic_acid ash alcalinity_of_ash magnesium total_phenols flavanoids nonflavanoid_phenols proanthocyanins color_intensity hu
0 14.23 1.71 2.43 15.6 127.0 2.80 3.06 0.28 2.29 5.64 1.
1 13.20 1.78 2.14 11.2 100.0 2.65 2.76 0.26 1.28 4.38 1.
2 13.16 2.36 2.67 18.6 101.0 2.80 3.24 0.30 2.81 5.68 1.
3 14.37 1.95 2.50 16.8 113.0 3.85 3.49 0.24 2.18 7.80 0.
4 13.24 2.59 2.87 21.0 118.0 2.80 2.69 0.39 1.82 4.32 1.
In [35]: wine_target=pd.DataFrame(df1.target,columns=['Target'])
wine_target.head()
Out[35]: Target
0 0
1 0
2 0
3 0
4 0
(178, 13)
Out[40]:
2314
Out[41]:
alcohol float64
Out[42]:
malic_acid float64
ash float64
alcalinity_of_ash float64
magnesium float64
total_phenols float64
flavanoids float64
nonflavanoid_phenols float64
proanthocyanins float64
color_intensity float64
hue float64
od280/od315_of_diluted_wines float64
proline float64
dtype: object
Out[43]: alcohol malic_acid ash alcalinity_of_ash magnesium total_phenols flavanoids nonflavanoid_phenols proanthocyanins col
count 178.000000 178.000000 178.000000 178.000000 178.000000 178.000000 178.000000 178.000000 178.000000
mean 13.000618 2.336348 2.366517 19.494944 99.741573 2.295112 2.029270 0.361854 1.590899
std 0.811827 1.117146 0.274344 3.339564 14.282484 0.625851 0.998859 0.124453 0.572359
min 11.030000 0.740000 1.360000 10.600000 70.000000 0.980000 0.340000 0.130000 0.410000
25% 12.362500 1.602500 2.210000 17.200000 88.000000 1.742500 1.205000 0.270000 1.250000
50% 13.050000 1.865000 2.360000 19.500000 98.000000 2.355000 2.135000 0.340000 1.555000
75% 13.677500 3.082500 2.557500 21.500000 107.000000 2.800000 2.875000 0.437500 1.950000
max 14.830000 5.800000 3.230000 30.000000 162.000000 3.880000 5.080000 0.660000 3.580000
In [44]: #Correlation
wine_features.corr()
alcohol 0
Out[46]:
malic_acid 0
ash 0
alcalinity_of_ash 0
magnesium 0
total_phenols 0
flavanoids 0
nonflavanoid_phenols 0
proanthocyanins 0
color_intensity 0
hue 0
od280/od315_of_diluted_wines 0
proline 0
dtype: int64
In [62]: #duplicates
wine_features.duplicated()
0 False
Out[62]:
1 False
2 False
3 False
4 False
...
173 False
174 False
175 False
176 False
177 False
Length: 178, dtype: bool
0
Out[56]:
False
Out[64]:
52
Out[71]:
20 14.06
Out[76]:
37 13.05
43 13.24
44 13.05
46 14.38
48 14.10
50 13.05
51 13.83
55 13.56
56 14.22
63 12.37
65 12.37
67 12.37
71 13.86
78 12.33
83 13.05
84 11.84
89 12.08
90 12.08
91 12.00
93 12.29
97 12.29
98 12.37
99 12.29
100 12.08
107 12.72
114 12.08
116 11.82
117 12.42
119 12.00
122 12.42
123 13.05
128 12.37
133 12.70
134 12.51
135 12.60
136 12.25
138 13.49
140 12.93
144 12.25
145 13.16
146 13.88
150 13.50
152 13.11
159 13.48
162 12.85
165 13.73
168 13.58
171 12.77
173 13.71
174 13.40
176 13.17
Name: alcohol, dtype: float64
In [79]: # dropping duplicates in alcohol column from dataframe while keeping first
wine_features.drop_duplicates(subset=['alcohol'],keep='first')
Out[79]: alcohol malic_acid ash alcalinity_of_ash magnesium total_phenols flavanoids nonflavanoid_phenols proanthocyanins color_intensity
0 14.23 1.71 2.43 15.6 127.0 2.80 3.06 0.28 2.29 5.64
1 13.20 1.78 2.14 11.2 100.0 2.65 2.76 0.26 1.28 4.38
2 13.16 2.36 2.67 18.6 101.0 2.80 3.24 0.30 2.81 5.68
3 14.37 1.95 2.50 16.8 113.0 3.85 3.49 0.24 2.18 7.80
4 13.24 2.59 2.87 21.0 118.0 2.80 2.69 0.39 1.82 4.32
... ... ... ... ... ... ... ... ... ... ...
169 13.40 4.60 2.86 25.0 112.0 1.98 0.96 0.27 1.11 8.50
170 12.20 3.03 2.32 19.0 96.0 1.25 0.49 0.40 0.73 5.50
172 14.16 2.51 2.48 20.0 91.0 1.68 0.70 0.44 1.24 9.70
175 13.27 4.28 2.26 20.0 120.0 1.59 0.69 0.43 1.35 10.20
177 14.13 4.10 2.74 24.5 96.0 2.05 0.76 0.56 1.35 9.20
Out[93]: alcohol malic_acid ash alcalinity_of_ash magnesium total_phenols flavanoids nonflavanoid_phenols proanthocyanins color_intensity
45 14.21 4.04 2.44 18.9 111.0 2.85 2.65 0.30 1.25 5.24
123 13.05 5.80 2.13 21.5 86.0 2.62 2.65 0.30 2.01 2.60
143 13.62 4.95 2.35 20.0 92.0 2.00 0.80 0.47 1.02 4.40
146 13.88 5.04 2.23 20.0 80.0 0.98 0.34 0.40 0.68 4.90
155 13.17 5.19 2.32 22.0 93.0 1.74 0.63 0.61 1.55 7.90
156 13.84 4.12 2.38 19.5 89.0 1.80 0.83 0.48 1.56 9.01
165 13.73 4.36 2.26 22.5 88.0 1.28 0.47 0.52 1.15 6.62
169 13.40 4.60 2.86 25.0 112.0 1.98 0.96 0.27 1.11 8.50
173 13.71 5.65 2.45 20.5 95.0 1.68 0.61 0.52 1.06 7.70
175 13.27 4.28 2.26 20.0 120.0 1.59 0.69 0.43 1.35 10.20
177 14.13 4.10 2.74 24.5 96.0 2.05 0.76 0.56 1.35 9.20
In [ ]: