SlideShare a Scribd company logo
1 of 5
Machine Learning
Complete the lab as given in the notebook file. Include all screenshots of code and output.
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "An7pIRrhKhTb"
},
"outputs": [],
"source": [
"# Source: https://scikit-
learn.org/stable/auto_examples/classification/plot_digits_classification.htmln",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"source": [
"# Import datasets, classifiers and performance metricsn",
"from sklearn import datasets, svm, metricsn",
"from sklearn.model_selection import train_test_split"
],
"metadata": {
"id": "m-4vkyOSLHY-"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"digits = datasets.load_digits()"
],
"metadata": {
"id": "JUK7wpLQLJ0Y"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))n",
"for ax, image, label in zip(axes, digits.images, digits.target):n",
" ax.set_axis_off()n",
" ax.imshow(image, cmap=plt.cm.gray_r, interpolation="nearest")n",
" ax.set_title("Training: %i" % label)"
],
"metadata": {
"id": "C2_v9MqbLhQX"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# flatten the imagesn",
"n_samples = len(digits.images)n",
"data = digits.images.reshape((n_samples, -1))"
],
"metadata": {
"id": "L65XSQXhLLw0"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Create a classifier: a support vector classifiern",
"clf = svm.SVC(gamma=0.001)"
],
"metadata": {
"id": "6SO7xR-QMUa9"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Split data into 50% train and 50% test subsetsn",
"X_train, X_test, y_train, y_test = train_test_split(n",
" data, digits.target, test_size=0.5, shuffle=Falsen",
")"
],
"metadata": {
"id": "B-AEWWiTLlqG"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Learn the digits on the train subsetn",
"clf.fit(X_train, y_train)"
],
"metadata": {
"id": "0QXu0qt5LkA_"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Predict the value of the digit on the test subsetn",
"predicted = clf.predict(X_test)"
],
"metadata": {
"id": "v-hhRIHWLwB3"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))n",
"for ax, image, prediction in zip(axes, X_test, predicted):n",
" ax.set_axis_off()n",
" image = image.reshape(8, 8)n",
" ax.imshow(image, cmap=plt.cm.gray_r, interpolation="nearest")n",
" ax.set_title(f"Prediction: {prediction}")"
],
"metadata": {
"id": "6sHCRYZOLOvz"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"print(n",
" f"Classification report for classifier {clf}:n"n",
" f"{metrics.classification_report(y_test, predicted)}n"n",
")"
],
"metadata": {
"id": "cn875FFXLQql"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"disp = metrics.ConfusionMatrixDisplay.from_predictions(y_test, predicted)n",
"disp.figure_.suptitle("Confusion Matrix")n",
"print(f"Confusion matrix:n{disp.confusion_matrix}")n",
"n",
"plt.show()"
],
"metadata": {
"id": "wVU73pCgLSun"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "3PpbWPoFLUyb"
},
"execution_count": null,
"outputs": []
}
]
}

More Related Content

Similar to Machine Learning Complete the lab as given in the notebook file- Inclu.docx

LSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityLSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityBrendan Gregg
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using PythonNishantKumar1179
 
Checking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xChecking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xAndrey Karpov
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects Andrey Karpov
 
Checking the Source SDK Project
Checking the Source SDK ProjectChecking the Source SDK Project
Checking the Source SDK ProjectAndrey Karpov
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk PemulaOon Arfiandwi
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2PVS-Studio
 
GDG-MLOps using Protobuf in Unity
GDG-MLOps using Protobuf in UnityGDG-MLOps using Protobuf in Unity
GDG-MLOps using Protobuf in UnityIvan Chiou
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docxeugeniadean34240
 
Assignment no39
Assignment no39Assignment no39
Assignment no39Jay Patel
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
Boost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationBoost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationGlobalLogic Ukraine
 
Tutorial - 16 : How to pass parameters from one script to another by CallScri...
Tutorial - 16 : How to pass parameters from one script to another by CallScri...Tutorial - 16 : How to pass parameters from one script to another by CallScri...
Tutorial - 16 : How to pass parameters from one script to another by CallScri...Yogindernath Gupta
 

Similar to Machine Learning Complete the lab as given in the notebook file- Inclu.docx (20)

Lec05 buffers basic_examples
Lec05 buffers basic_examplesLec05 buffers basic_examples
Lec05 buffers basic_examples
 
LSFMM 2019 BPF Observability
LSFMM 2019 BPF ObservabilityLSFMM 2019 BPF Observability
LSFMM 2019 BPF Observability
 
Os lab final
Os lab finalOs lab final
Os lab final
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using Python
 
Checking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xChecking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-x
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
 
Checking the Source SDK Project
Checking the Source SDK ProjectChecking the Source SDK Project
Checking the Source SDK Project
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
 
GDG-MLOps using Protobuf in Unity
GDG-MLOps using Protobuf in UnityGDG-MLOps using Protobuf in Unity
GDG-MLOps using Protobuf in Unity
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
srgoc
srgocsrgoc
srgoc
 
Assignment no39
Assignment no39Assignment no39
Assignment no39
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Python para equipos de ciberseguridad
Python para equipos de ciberseguridad Python para equipos de ciberseguridad
Python para equipos de ciberseguridad
 
Book
BookBook
Book
 
Boost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationBoost.Python: C++ and Python Integration
Boost.Python: C++ and Python Integration
 
Tutorial - 16 : How to pass parameters from one script to another by CallScri...
Tutorial - 16 : How to pass parameters from one script to another by CallScri...Tutorial - 16 : How to pass parameters from one script to another by CallScri...
Tutorial - 16 : How to pass parameters from one script to another by CallScri...
 
Python for web security - beginner
Python for web security - beginnerPython for web security - beginner
Python for web security - beginner
 

More from EvandWYAlland

Milford Company has the following income statement for the year ending.docx
Milford Company has the following income statement for the year ending.docxMilford Company has the following income statement for the year ending.docx
Milford Company has the following income statement for the year ending.docxEvandWYAlland
 
MGT324 - Week2- Interactive Activity 2-3 Test your Knowledge (Questi.docx
MGT324 - Week2- Interactive Activity   2-3 Test your Knowledge (Questi.docxMGT324 - Week2- Interactive Activity   2-3 Test your Knowledge (Questi.docx
MGT324 - Week2- Interactive Activity 2-3 Test your Knowledge (Questi.docxEvandWYAlland
 
MGT324 - Week-2 Interactive Activity 2-3 Test your Knowledge (Ques.docx
MGT324 - Week-2 Interactive Activity     2-3 Test your Knowledge (Ques.docxMGT324 - Week-2 Interactive Activity     2-3 Test your Knowledge (Ques.docx
MGT324 - Week-2 Interactive Activity 2-3 Test your Knowledge (Ques.docxEvandWYAlland
 
MGT421 - Week-11 Interactive Activity 11-2 Action Required- Chapters.docx
MGT421 - Week-11 Interactive Activity   11-2 Action Required- Chapters.docxMGT421 - Week-11 Interactive Activity   11-2 Action Required- Chapters.docx
MGT421 - Week-11 Interactive Activity 11-2 Action Required- Chapters.docxEvandWYAlland
 
mgt421How plan and create an effective presentation Explain the SOFTEN.docx
mgt421How plan and create an effective presentation Explain the SOFTEN.docxmgt421How plan and create an effective presentation Explain the SOFTEN.docx
mgt421How plan and create an effective presentation Explain the SOFTEN.docxEvandWYAlland
 
Metlock Corporation has retained earnings of $708-100 at January 1- 20.docx
Metlock Corporation has retained earnings of $708-100 at January 1- 20.docxMetlock Corporation has retained earnings of $708-100 at January 1- 20.docx
Metlock Corporation has retained earnings of $708-100 at January 1- 20.docxEvandWYAlland
 
Metlock Inc- uses a calendar year for financial reporting- The compamy.docx
Metlock Inc- uses a calendar year for financial reporting- The compamy.docxMetlock Inc- uses a calendar year for financial reporting- The compamy.docx
Metlock Inc- uses a calendar year for financial reporting- The compamy.docxEvandWYAlland
 
Mendel worked with traits that are inherited in distinct classes (two.docx
Mendel worked with traits that are inherited in distinct classes (two.docxMendel worked with traits that are inherited in distinct classes (two.docx
Mendel worked with traits that are inherited in distinct classes (two.docxEvandWYAlland
 
Mendel studied seven (what he termed) -characteristics- of pea plants.docx
Mendel studied seven (what he termed) -characteristics- of pea plants.docxMendel studied seven (what he termed) -characteristics- of pea plants.docx
Mendel studied seven (what he termed) -characteristics- of pea plants.docxEvandWYAlland
 
Mendel's dihybrid crosses demonstrated that Group of answer choices al.docx
Mendel's dihybrid crosses demonstrated that Group of answer choices al.docxMendel's dihybrid crosses demonstrated that Group of answer choices al.docx
Mendel's dihybrid crosses demonstrated that Group of answer choices al.docxEvandWYAlland
 
Meredith Peters and Sebastian Bunsen were married for 10 years and sep.docx
Meredith Peters and Sebastian Bunsen were married for 10 years and sep.docxMeredith Peters and Sebastian Bunsen were married for 10 years and sep.docx
Meredith Peters and Sebastian Bunsen were married for 10 years and sep.docxEvandWYAlland
 
Menstruation is triggered by a- a- increase in the level(s) Estrogen b.docx
Menstruation is triggered by a- a- increase in the level(s) Estrogen b.docxMenstruation is triggered by a- a- increase in the level(s) Estrogen b.docx
Menstruation is triggered by a- a- increase in the level(s) Estrogen b.docxEvandWYAlland
 
Mercury is located at 0-47AU with a albedo of 0-14- Given that the amo.docx
Mercury is located at 0-47AU with a albedo of 0-14- Given that the amo.docxMercury is located at 0-47AU with a albedo of 0-14- Given that the amo.docx
Mercury is located at 0-47AU with a albedo of 0-14- Given that the amo.docxEvandWYAlland
 
Membrane lipids are made in the where the enzyme ensure both leaflets.docx
Membrane lipids are made in the where the enzyme ensure both leaflets.docxMembrane lipids are made in the where the enzyme ensure both leaflets.docx
Membrane lipids are made in the where the enzyme ensure both leaflets.docxEvandWYAlland
 
mere birweyod found that 42- hai taben out a sudent ioan- (p1p2) (Riou.docx
mere birweyod found that 42- hai taben out a sudent ioan- (p1p2) (Riou.docxmere birweyod found that 42- hai taben out a sudent ioan- (p1p2) (Riou.docx
mere birweyod found that 42- hai taben out a sudent ioan- (p1p2) (Riou.docxEvandWYAlland
 
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.docx
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.docxMerge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.docx
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.docxEvandWYAlland
 
Mendel crossed pea plants with smooth- long pods (SSLL) with plants wi.docx
Mendel crossed pea plants with smooth- long pods (SSLL) with plants wi.docxMendel crossed pea plants with smooth- long pods (SSLL) with plants wi.docx
Mendel crossed pea plants with smooth- long pods (SSLL) with plants wi.docxEvandWYAlland
 
Mendel studied the structure traits of his plants- however humans disp.docx
Mendel studied the structure traits of his plants- however humans disp.docxMendel studied the structure traits of his plants- however humans disp.docx
Mendel studied the structure traits of his plants- however humans disp.docxEvandWYAlland
 
Mendel disproved the idea that- for autosomal traits- one parent contr.docx
Mendel disproved the idea that- for autosomal traits- one parent contr.docxMendel disproved the idea that- for autosomal traits- one parent contr.docx
Mendel disproved the idea that- for autosomal traits- one parent contr.docxEvandWYAlland
 
Melissa reports to a supportive manager who prowides a lot of career a.docx
Melissa reports to a supportive manager who prowides a lot of career a.docxMelissa reports to a supportive manager who prowides a lot of career a.docx
Melissa reports to a supportive manager who prowides a lot of career a.docxEvandWYAlland
 

More from EvandWYAlland (20)

Milford Company has the following income statement for the year ending.docx
Milford Company has the following income statement for the year ending.docxMilford Company has the following income statement for the year ending.docx
Milford Company has the following income statement for the year ending.docx
 
MGT324 - Week2- Interactive Activity 2-3 Test your Knowledge (Questi.docx
MGT324 - Week2- Interactive Activity   2-3 Test your Knowledge (Questi.docxMGT324 - Week2- Interactive Activity   2-3 Test your Knowledge (Questi.docx
MGT324 - Week2- Interactive Activity 2-3 Test your Knowledge (Questi.docx
 
MGT324 - Week-2 Interactive Activity 2-3 Test your Knowledge (Ques.docx
MGT324 - Week-2 Interactive Activity     2-3 Test your Knowledge (Ques.docxMGT324 - Week-2 Interactive Activity     2-3 Test your Knowledge (Ques.docx
MGT324 - Week-2 Interactive Activity 2-3 Test your Knowledge (Ques.docx
 
MGT421 - Week-11 Interactive Activity 11-2 Action Required- Chapters.docx
MGT421 - Week-11 Interactive Activity   11-2 Action Required- Chapters.docxMGT421 - Week-11 Interactive Activity   11-2 Action Required- Chapters.docx
MGT421 - Week-11 Interactive Activity 11-2 Action Required- Chapters.docx
 
mgt421How plan and create an effective presentation Explain the SOFTEN.docx
mgt421How plan and create an effective presentation Explain the SOFTEN.docxmgt421How plan and create an effective presentation Explain the SOFTEN.docx
mgt421How plan and create an effective presentation Explain the SOFTEN.docx
 
Metlock Corporation has retained earnings of $708-100 at January 1- 20.docx
Metlock Corporation has retained earnings of $708-100 at January 1- 20.docxMetlock Corporation has retained earnings of $708-100 at January 1- 20.docx
Metlock Corporation has retained earnings of $708-100 at January 1- 20.docx
 
Metlock Inc- uses a calendar year for financial reporting- The compamy.docx
Metlock Inc- uses a calendar year for financial reporting- The compamy.docxMetlock Inc- uses a calendar year for financial reporting- The compamy.docx
Metlock Inc- uses a calendar year for financial reporting- The compamy.docx
 
Mendel worked with traits that are inherited in distinct classes (two.docx
Mendel worked with traits that are inherited in distinct classes (two.docxMendel worked with traits that are inherited in distinct classes (two.docx
Mendel worked with traits that are inherited in distinct classes (two.docx
 
Mendel studied seven (what he termed) -characteristics- of pea plants.docx
Mendel studied seven (what he termed) -characteristics- of pea plants.docxMendel studied seven (what he termed) -characteristics- of pea plants.docx
Mendel studied seven (what he termed) -characteristics- of pea plants.docx
 
Mendel's dihybrid crosses demonstrated that Group of answer choices al.docx
Mendel's dihybrid crosses demonstrated that Group of answer choices al.docxMendel's dihybrid crosses demonstrated that Group of answer choices al.docx
Mendel's dihybrid crosses demonstrated that Group of answer choices al.docx
 
Meredith Peters and Sebastian Bunsen were married for 10 years and sep.docx
Meredith Peters and Sebastian Bunsen were married for 10 years and sep.docxMeredith Peters and Sebastian Bunsen were married for 10 years and sep.docx
Meredith Peters and Sebastian Bunsen were married for 10 years and sep.docx
 
Menstruation is triggered by a- a- increase in the level(s) Estrogen b.docx
Menstruation is triggered by a- a- increase in the level(s) Estrogen b.docxMenstruation is triggered by a- a- increase in the level(s) Estrogen b.docx
Menstruation is triggered by a- a- increase in the level(s) Estrogen b.docx
 
Mercury is located at 0-47AU with a albedo of 0-14- Given that the amo.docx
Mercury is located at 0-47AU with a albedo of 0-14- Given that the amo.docxMercury is located at 0-47AU with a albedo of 0-14- Given that the amo.docx
Mercury is located at 0-47AU with a albedo of 0-14- Given that the amo.docx
 
Membrane lipids are made in the where the enzyme ensure both leaflets.docx
Membrane lipids are made in the where the enzyme ensure both leaflets.docxMembrane lipids are made in the where the enzyme ensure both leaflets.docx
Membrane lipids are made in the where the enzyme ensure both leaflets.docx
 
mere birweyod found that 42- hai taben out a sudent ioan- (p1p2) (Riou.docx
mere birweyod found that 42- hai taben out a sudent ioan- (p1p2) (Riou.docxmere birweyod found that 42- hai taben out a sudent ioan- (p1p2) (Riou.docx
mere birweyod found that 42- hai taben out a sudent ioan- (p1p2) (Riou.docx
 
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.docx
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.docxMerge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.docx
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.docx
 
Mendel crossed pea plants with smooth- long pods (SSLL) with plants wi.docx
Mendel crossed pea plants with smooth- long pods (SSLL) with plants wi.docxMendel crossed pea plants with smooth- long pods (SSLL) with plants wi.docx
Mendel crossed pea plants with smooth- long pods (SSLL) with plants wi.docx
 
Mendel studied the structure traits of his plants- however humans disp.docx
Mendel studied the structure traits of his plants- however humans disp.docxMendel studied the structure traits of his plants- however humans disp.docx
Mendel studied the structure traits of his plants- however humans disp.docx
 
Mendel disproved the idea that- for autosomal traits- one parent contr.docx
Mendel disproved the idea that- for autosomal traits- one parent contr.docxMendel disproved the idea that- for autosomal traits- one parent contr.docx
Mendel disproved the idea that- for autosomal traits- one parent contr.docx
 
Melissa reports to a supportive manager who prowides a lot of career a.docx
Melissa reports to a supportive manager who prowides a lot of career a.docxMelissa reports to a supportive manager who prowides a lot of career a.docx
Melissa reports to a supportive manager who prowides a lot of career a.docx
 

Recently uploaded

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 

Recently uploaded (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 

Machine Learning Complete the lab as given in the notebook file- Inclu.docx

  • 1. Machine Learning Complete the lab as given in the notebook file. Include all screenshots of code and output. { "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "id": "An7pIRrhKhTb" }, "outputs": [], "source": [ "# Source: https://scikit- learn.org/stable/auto_examples/classification/plot_digits_classification.htmln", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "source": [ "# Import datasets, classifiers and performance metricsn", "from sklearn import datasets, svm, metricsn", "from sklearn.model_selection import train_test_split" ], "metadata": { "id": "m-4vkyOSLHY-" }, "execution_count": null, "outputs": []
  • 2. }, { "cell_type": "code", "source": [ "digits = datasets.load_digits()" ], "metadata": { "id": "JUK7wpLQLJ0Y" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))n", "for ax, image, label in zip(axes, digits.images, digits.target):n", " ax.set_axis_off()n", " ax.imshow(image, cmap=plt.cm.gray_r, interpolation="nearest")n", " ax.set_title("Training: %i" % label)" ], "metadata": { "id": "C2_v9MqbLhQX" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# flatten the imagesn", "n_samples = len(digits.images)n", "data = digits.images.reshape((n_samples, -1))" ], "metadata": { "id": "L65XSQXhLLw0" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Create a classifier: a support vector classifiern", "clf = svm.SVC(gamma=0.001)" ],
  • 3. "metadata": { "id": "6SO7xR-QMUa9" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Split data into 50% train and 50% test subsetsn", "X_train, X_test, y_train, y_test = train_test_split(n", " data, digits.target, test_size=0.5, shuffle=Falsen", ")" ], "metadata": { "id": "B-AEWWiTLlqG" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Learn the digits on the train subsetn", "clf.fit(X_train, y_train)" ], "metadata": { "id": "0QXu0qt5LkA_" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# Predict the value of the digit on the test subsetn", "predicted = clf.predict(X_test)" ], "metadata": { "id": "v-hhRIHWLwB3" }, "execution_count": null, "outputs": [] }, { "cell_type": "code",
  • 4. "source": [ "_, axes = plt.subplots(nrows=1, ncols=4, figsize=(10, 3))n", "for ax, image, prediction in zip(axes, X_test, predicted):n", " ax.set_axis_off()n", " image = image.reshape(8, 8)n", " ax.imshow(image, cmap=plt.cm.gray_r, interpolation="nearest")n", " ax.set_title(f"Prediction: {prediction}")" ], "metadata": { "id": "6sHCRYZOLOvz" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "print(n", " f"Classification report for classifier {clf}:n"n", " f"{metrics.classification_report(y_test, predicted)}n"n", ")" ], "metadata": { "id": "cn875FFXLQql" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "disp = metrics.ConfusionMatrixDisplay.from_predictions(y_test, predicted)n", "disp.figure_.suptitle("Confusion Matrix")n", "print(f"Confusion matrix:n{disp.confusion_matrix}")n", "n", "plt.show()" ], "metadata": { "id": "wVU73pCgLSun" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [],