0% found this document useful (0 votes)
60 views

Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)

The document analyzes a wine dataset using various Python machine learning and data analysis libraries. It prints version information for relevant libraries, explores the dataset by viewing the shape, sample data, and descriptions, and generates visualizations including histograms and scatter plots.

Uploaded by

Raheel Aslam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Machine Learning Lab: Raheel Aslam (74-FET/BSEE/F16)

The document analyzes a wine dataset using various Python machine learning and data analysis libraries. It prints version information for relevant libraries, explores the dataset by viewing the shape, sample data, and descriptions, and generates visualizations including histograms and scatter plots.

Uploaded by

Raheel Aslam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

LAB#02 Raheel Aslam (74-FET/BSEE/F16)

Machine Learning Lab


Code:
# Python version
import sys
print('Python: {}'.format(sys.version))
# scipy
import scipy
print('scipy: {}'.format(scipy.__version__))
# numpy
import numpy
print('numpy: {}'.format(numpy.__version__))
# matplotlib
import matplotlib
print('matplotlib: {}'.format(matplotlib.__version__))
# pandas
import pandas
print('pandas: {}'.format(pandas.__version__))
# scikit-learn
import sklearn
print('sklearn: {}'.format(sklearn.__version__))

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

[20 rows x 13 columns]


Alcohol Malic-Acid ... OD280/OD315-of-diluted-wines Proline
count 178.000000 178.000000 ... 178.000000 178.000000
mean 13.000618 2.336348 ... 2.611685 746.893258
std 0.811827 1.117146 ... 0.709990 314.907474
min 11.030000 0.740000 ... 1.270000 278.000000
25% 12.362500 1.602500 ... 1.937500 500.500000
50% 13.050000 1.865000 ... 2.780000 673.500000
75% 13.677500 3.082500 ... 3.170000 985.000000
max 14.830000 5.800000 ... 4.000000 1680.000000

[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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy