SlideShare a Scribd company logo
1 of 3
Download to read offline
GOAL:
To Predict the Quality of Red Wine Using Binary Classification With KNN
and Decision Tree Classifier
Data Set Characteristics:
Number of Instances:1599
Number of Attributes:12
Predictors:
fixed acidity, volatile acidity, citric acid, residual sugar, chlorides, free
sulphur dioxide, total sulphur dioxide, density, pH, sulphates and
alcohol
Response:
Quality
Whats Good about the Data set:
• None of the columns have missing values in it.
• Not many levels in Nominal variables.
• No Textual Columns.
Data Preparation:
1. The Quality column which an ordinal variable with a range of 2 to
8 is converted into two parts by median, with help of pd.cut() and
labeled them into 0’s and 1’s by LaberEncoder().
2. Outliers are not removed but chosen to be in the predictive
Data Visualisation:
• The chance of getting good quality wine is less.
• All the numeric columns are independent on each
other.
Data Modelling
❖Splitting dataset into , X is predictors and y is response variable.

❖Splitting training and test in the ratios of 50:50,60:40 and 80:20.

❖KNN Classifier: 

‣ Use Standard scaler to optimise the results

‣ Two important parameters of KNNclassifier() are

metric :- Minkowski

n_neighbors: - square-root of number of predictive 

variables(y_test here).

‣ Create and Train the Model 

‣ Make predictions with the Model 

‣  Evaluate the predictions using confusion matrix and classification report.

‣ From the predictions we can see that accuracy decreases as we increase the 

Test size.

Train:Test 50:50 60:40 80:20
Bad
Quality(0)
89 89 89
Good
Quality(1)
66 59 50
Accuracy 88.25 87.03 86.56
Percentages of precision of getting 0 and 1
along with accuracy percentage
❖ Decision Tree Classifier:

‣ No standard Scaling Required as this classifier handles

outliers.

‣ Important parameters of DecisionTreeclassifier() are 

criterion: gini Index

max_depth: We have tried a range of values from 2 to 10

but 4 was best . 

‣ Create and Train the Model 

‣ Make predictions with the Model 

‣ Evaluate the predictions using confusion matrix 

and classification report.

‣ Similar to the KNN, We can Notice that accuracy decreases as we increase the Test size.

‣ Interestingly, we can See that the accuracy is exactly equal for both KNN and Decision tree models if the train and test split are in ratio
Train:Test 50:50 60:40 80:20
Bad
Quality(0)
91 91 91
Good
Quality(1)
52 70 70
Accuracy 89.37 89.35 86.56
Conclusion:
In conclusion, we can see that Both,KNN and Decision Tree Fitted models have almost
similar accuracy.But Since Decision Tree classifier has Slightly high Accuracy, It is
Recommended for this DataSet.
Thank You
Percentages of precision of getting 0 and 1
along with accuracy percentage.

More Related Content

Similar to Practical Data Science: Data Modelling and Presentation

Wine Taste Preference Modeling Based On Physicochemical Tests_ShuaiWei
Wine Taste Preference Modeling Based On Physicochemical Tests_ShuaiWeiWine Taste Preference Modeling Based On Physicochemical Tests_ShuaiWei
Wine Taste Preference Modeling Based On Physicochemical Tests_ShuaiWei
Shuai Wei
 

Similar to Practical Data Science: Data Modelling and Presentation (20)

Bridging the Gap: Machine Learning for Ubiquitous Computing -- Evaluation
Bridging the Gap: Machine Learning for Ubiquitous Computing -- EvaluationBridging the Gap: Machine Learning for Ubiquitous Computing -- Evaluation
Bridging the Gap: Machine Learning for Ubiquitous Computing -- Evaluation
 
Agreement analysis
Agreement analysisAgreement analysis
Agreement analysis
 
QCP user manual EN.pdf
QCP user manual EN.pdfQCP user manual EN.pdf
QCP user manual EN.pdf
 
What Is Generalized Linear Regression with Gaussian Distribution And How Can ...
What Is Generalized Linear Regression with Gaussian Distribution And How Can ...What Is Generalized Linear Regression with Gaussian Distribution And How Can ...
What Is Generalized Linear Regression with Gaussian Distribution And How Can ...
 
On the Robustness and Discriminative Power of IR Metrics for Top-N Recommenda...
On the Robustness and Discriminative Power of IR Metrics for Top-N Recommenda...On the Robustness and Discriminative Power of IR Metrics for Top-N Recommenda...
On the Robustness and Discriminative Power of IR Metrics for Top-N Recommenda...
 
TESCO Evaluation of Non-Normal Meter Data
TESCO Evaluation of Non-Normal Meter DataTESCO Evaluation of Non-Normal Meter Data
TESCO Evaluation of Non-Normal Meter Data
 
Cross validation
Cross validationCross validation
Cross validation
 
Quality assurance part_2
Quality assurance part_2Quality assurance part_2
Quality assurance part_2
 
Basic QC Statistics - Improving Laboratory Performance Through Quality Contro...
Basic QC Statistics - Improving Laboratory Performance Through Quality Contro...Basic QC Statistics - Improving Laboratory Performance Through Quality Contro...
Basic QC Statistics - Improving Laboratory Performance Through Quality Contro...
 
Quality Control for Quantitative Tests by Prof Aamir Ijaz (Pakistan)
Quality Control for Quantitative Tests by Prof Aamir Ijaz (Pakistan)Quality Control for Quantitative Tests by Prof Aamir Ijaz (Pakistan)
Quality Control for Quantitative Tests by Prof Aamir Ijaz (Pakistan)
 
Central Composite Design
Central Composite DesignCentral Composite Design
Central Composite Design
 
Machine Learning Performance Evaluation: Tips and Pitfalls - Jose Hernandez O...
Machine Learning Performance Evaluation: Tips and Pitfalls - Jose Hernandez O...Machine Learning Performance Evaluation: Tips and Pitfalls - Jose Hernandez O...
Machine Learning Performance Evaluation: Tips and Pitfalls - Jose Hernandez O...
 
Hypothesis testing - II.pptx
Hypothesis testing - II.pptxHypothesis testing - II.pptx
Hypothesis testing - II.pptx
 
Towards Confidence-aware Calibrated Recommendation (Slides)
Towards Confidence-aware Calibrated Recommendation (Slides)Towards Confidence-aware Calibrated Recommendation (Slides)
Towards Confidence-aware Calibrated Recommendation (Slides)
 
Calibration of ML Models - pycon
Calibration of ML Models - pyconCalibration of ML Models - pycon
Calibration of ML Models - pycon
 
Simple & Multiple Regression Analysis
Simple & Multiple Regression AnalysisSimple & Multiple Regression Analysis
Simple & Multiple Regression Analysis
 
The Beginnings of a Search Engine
The Beginnings of a Search EngineThe Beginnings of a Search Engine
The Beginnings of a Search Engine
 
Mining Credit Card Defults
Mining Credit Card DefultsMining Credit Card Defults
Mining Credit Card Defults
 
Wine Taste Preference Modeling Based On Physicochemical Tests_ShuaiWei
Wine Taste Preference Modeling Based On Physicochemical Tests_ShuaiWeiWine Taste Preference Modeling Based On Physicochemical Tests_ShuaiWei
Wine Taste Preference Modeling Based On Physicochemical Tests_ShuaiWei
 
Measurement system analysis Presentation.ppt
Measurement system analysis Presentation.pptMeasurement system analysis Presentation.ppt
Measurement system analysis Presentation.ppt
 

Recently uploaded

Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
gajnagarg
 
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
Health
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
HyderabadDolls
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
HyderabadDolls
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
nirzagarg
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
gajnagarg
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Klinik kandungan
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
gajnagarg
 

Recently uploaded (20)

Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
 
Kings of Saudi Arabia, information about them
Kings of Saudi Arabia, information about themKings of Saudi Arabia, information about them
Kings of Saudi Arabia, information about them
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
 
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
 
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubai
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 

Practical Data Science: Data Modelling and Presentation

  • 1. GOAL: To Predict the Quality of Red Wine Using Binary Classification With KNN and Decision Tree Classifier Data Set Characteristics: Number of Instances:1599 Number of Attributes:12 Predictors: fixed acidity, volatile acidity, citric acid, residual sugar, chlorides, free sulphur dioxide, total sulphur dioxide, density, pH, sulphates and alcohol Response: Quality Whats Good about the Data set: • None of the columns have missing values in it. • Not many levels in Nominal variables. • No Textual Columns. Data Preparation: 1. The Quality column which an ordinal variable with a range of 2 to 8 is converted into two parts by median, with help of pd.cut() and labeled them into 0’s and 1’s by LaberEncoder(). 2. Outliers are not removed but chosen to be in the predictive
  • 2. Data Visualisation: • The chance of getting good quality wine is less. • All the numeric columns are independent on each other. Data Modelling ❖Splitting dataset into , X is predictors and y is response variable. ❖Splitting training and test in the ratios of 50:50,60:40 and 80:20. ❖KNN Classifier: ‣ Use Standard scaler to optimise the results ‣ Two important parameters of KNNclassifier() are metric :- Minkowski n_neighbors: - square-root of number of predictive variables(y_test here). ‣ Create and Train the Model ‣ Make predictions with the Model  ‣  Evaluate the predictions using confusion matrix and classification report. ‣ From the predictions we can see that accuracy decreases as we increase the Test size. Train:Test 50:50 60:40 80:20 Bad Quality(0) 89 89 89 Good Quality(1) 66 59 50 Accuracy 88.25 87.03 86.56 Percentages of precision of getting 0 and 1 along with accuracy percentage
  • 3. ❖ Decision Tree Classifier: ‣ No standard Scaling Required as this classifier handles outliers. ‣ Important parameters of DecisionTreeclassifier() are criterion: gini Index max_depth: We have tried a range of values from 2 to 10 but 4 was best . ‣ Create and Train the Model ‣ Make predictions with the Model  ‣ Evaluate the predictions using confusion matrix and classification report. ‣ Similar to the KNN, We can Notice that accuracy decreases as we increase the Test size. ‣ Interestingly, we can See that the accuracy is exactly equal for both KNN and Decision tree models if the train and test split are in ratio Train:Test 50:50 60:40 80:20 Bad Quality(0) 91 91 91 Good Quality(1) 52 70 70 Accuracy 89.37 89.35 86.56 Conclusion: In conclusion, we can see that Both,KNN and Decision Tree Fitted models have almost similar accuracy.But Since Decision Tree classifier has Slightly high Accuracy, It is Recommended for this DataSet. Thank You Percentages of precision of getting 0 and 1 along with accuracy percentage.