Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)
Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)
import pandas
from pandas.plotting import scatter_matrix
import matplotlib.pyplot as plt
from sklearn import model_selection
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
url = "C:/Users/rahee/Desktop/lab2/wine.data"
names = ['Alcohol', 'Malic-Acid', 'Ash','Alclanity-of-Ash', 'Magnesium','Total-
Phenols','Flavanoids','NonFlavanoids-Phenols','Proanthocyanins','Colour-Intensity','Hue','OD280/OD315-
of-diluted-wines','Proline']
dataset = pandas.read_csv(url, names = names)
print(dataset.shape)
print(dataset.head(20))
print(dataset.describe())
print(dataset.groupby('Alcohol').size())
dataset = pandas.read_csv(url, names = names)
dataset.plot(kind ='box', subplots = True,
layout =(1, 5), sharex = False, sharey = False)
plt.show()
dataset.hist()
plt.show()
scatter_matrix(dataset)
plt.show()
Output:
Python: 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
scipy: 1.4.1
numpy: 1.18.1
matplotlib: 3.1.3
pandas: 1.0.1
sklearn: 0.22.2
(178, 13)
Alcohol Malic-Acid Ash ... Hue OD280/OD315-of-diluted-wines Proline
1 14.23 1.71 2.43 ... 1.04 3.92 1065
1 13.20 1.78 2.14 ... 1.05 3.40 1050
1 13.16 2.36 2.67 ... 1.03 3.17 1185
1 14.37 1.95 2.50 ... 0.86 3.45 1480
1 13.24 2.59 2.87 ... 1.04 2.93 735
1 14.20 1.76 2.45 ... 1.05 2.85 1450
1 14.39 1.87 2.45 ... 1.02 3.58 1290
1 14.06 2.15 2.61 ... 1.06 3.58 1295
1 14.83 1.64 2.17 ... 1.08 2.85 1045
1 13.86 1.35 2.27 ... 1.01 3.55 1045
1 14.10 2.16 2.30 ... 1.25 3.17 1510
1 14.12 1.48 2.32 ... 1.17 2.82 1280
1 13.75 1.73 2.41 ... 1.15 2.90 1320
1 14.75 1.73 2.39 ... 1.25 2.73 1150
1 14.38 1.87 2.38 ... 1.20 3.00 1547
1 13.63 1.81 2.70 ... 1.28 2.88 1310
1 14.30 1.92 2.72 ... 1.07 2.65 1280
1 13.83 1.57 2.62 ... 1.13 2.57 1130
1 14.19 1.59 2.48 ... 1.23 2.82 1680
1 13.64 3.10 2.56 ... 0.96 3.36 845
[8 rows x 13 columns]
Alcohol
11.03 1
11.41 1
11.45 1
11.46 1
11.56 1
..
14.37 1
14.38 2
14.39 1
14.75 1
14.83 1
Length: 126, dtype: int64