SlideShare una empresa de Scribd logo
1 de 1
Descargar para leer sin conexión
Do part C
Problem The Fisher's Iris data set is a dataset containing 150 samples, each of which has four
attributes Petal Length, Petal Width, Sepal Length, Sepal width and a species label. The species
can be predicted based on the four features associated with each sample. More details about the
dataset are available in this Wikipedia page: https:/len. wikipedia.org/wiki/lris flower data set. The
data can be assessed by loading the mat file provided in this assignment. Two items
Irismeasurements and Irisclass should be loaded into the workspace. Irismeasurements is a 1504
matrix containing the four features of 150 iris samples, with each row corresponding to the
features of each sample. Irisclass is a 150-element column vector specifying the species of the
150 samples. In Irisclass, 1, 2, 3 encode the species setosa, versicolor and virginica, respectively.
(a) (60 marks) Write a Python function called KNearestNeighbour that uses the KNN algorithm to
classify a test set based on a training set (i.e., determine the species of each data point in the test
set). Save the function in a file named KNearestNeighbour.py. Your function should be well-
commented. The function header should have the form: def KNearestNeighbour
(TestMeasurements, TrainMeasurements, Trainclass, K) where Testmeasurements is an M4
matrix containing the feature vector of M test samples, TrainMeasurements is a N4 matrix
containing the feature vectors of the training set and TrainClass is a N-element vector containing
the species label of the N training samples, K is the parameter K used in KNN. The function
should return a M element vector showing classification results generated by KNN for the test
samples. You are allowed to use all built-in functions except those related to kNeighborsClassifier,
which is the built-in class for KNN classification. (b) (10 marks) Write a Python script to test the
function you wrote in Part (a). Use the first 100 samples in the data set as training set and the last
50 samples as the testing set. Set K= 5. Your test code should be written and saved in a Jupyter
notebook called TestKNearestNeighbour. ipynb. (c) (30 marks) Write a Python script to implement
the lockbox approach. Save the script in a Jupyter notebook called LockBoxKNN . ipynb. Use the
first 50 samples as the training data, the next 50 samples as validation data and the last 50
samples as the test data. Use the function you wrote in Part (a) for all KNN classifications
required. When tuning the parameter K, consider all even K inside the range 1K21. Tabulate the
accuracy for

Más contenido relacionado

Similar a Do part C Problem The Fishers Iris data set is a dataset co.pdf

C programming session 05
C programming session 05C programming session 05
C programming session 05
Vivek Singh
 
arrays-120712074248-phpapp01
arrays-120712074248-phpapp01arrays-120712074248-phpapp01
arrays-120712074248-phpapp01
Abdul Samee
 
Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7
ashhadiqbal
 
MPerceptron
MPerceptronMPerceptron
MPerceptron
butest
 

Similar a Do part C Problem The Fishers Iris data set is a dataset co.pdf (14)

C programming session 05
C programming session 05C programming session 05
C programming session 05
 
Neural networks using tensor flow in amazon deep learning server
Neural networks using tensor flow in amazon deep learning serverNeural networks using tensor flow in amazon deep learning server
Neural networks using tensor flow in amazon deep learning server
 
BPstudy sklearn 20180925
BPstudy sklearn 20180925BPstudy sklearn 20180925
BPstudy sklearn 20180925
 
arrays-120712074248-phpapp01
arrays-120712074248-phpapp01arrays-120712074248-phpapp01
arrays-120712074248-phpapp01
 
wk5ppt1_Titanic
wk5ppt1_Titanicwk5ppt1_Titanic
wk5ppt1_Titanic
 
Be smart when testing your Akka code
Be smart when testing your Akka codeBe smart when testing your Akka code
Be smart when testing your Akka code
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 
Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7Comp 220 ilab 5 of 7
Comp 220 ilab 5 of 7
 
Arrays
ArraysArrays
Arrays
 
Control statements
Control statementsControl statements
Control statements
 
iOS와 케라스의 만남
iOS와 케라스의 만남iOS와 케라스의 만남
iOS와 케라스의 만남
 
MPerceptron
MPerceptronMPerceptron
MPerceptron
 
R Cheat Sheet
R Cheat SheetR Cheat Sheet
R Cheat Sheet
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 

Más de adamsapparelsformen

Domes and basins In some folds Inliers and outliersFigur.pdf
Domes and basins  In some folds Inliers and outliersFigur.pdfDomes and basins  In some folds Inliers and outliersFigur.pdf
Domes and basins In some folds Inliers and outliersFigur.pdf
adamsapparelsformen
 
Does anyone have a photo of the completed moon map I need t.pdf
Does anyone have a photo of the completed moon map I need t.pdfDoes anyone have a photo of the completed moon map I need t.pdf
Does anyone have a photo of the completed moon map I need t.pdf
adamsapparelsformen
 
Do it in Java Please ExamPrep4_Spring2023 Source Packages lo.pdf
Do it in Java Please ExamPrep4_Spring2023 Source Packages lo.pdfDo it in Java Please ExamPrep4_Spring2023 Source Packages lo.pdf
Do it in Java Please ExamPrep4_Spring2023 Source Packages lo.pdf
adamsapparelsformen
 
DNA exits mostly as a double stranded molecule Because of .pdf
DNA exits mostly as a double stranded molecule Because of .pdfDNA exits mostly as a double stranded molecule Because of .pdf
DNA exits mostly as a double stranded molecule Because of .pdf
adamsapparelsformen
 

Más de adamsapparelsformen (20)

Doctors Diaries is a 1990s documentary following a group of.pdf
Doctors Diaries is a 1990s documentary following a group of.pdfDoctors Diaries is a 1990s documentary following a group of.pdf
Doctors Diaries is a 1990s documentary following a group of.pdf
 
Dont respond to this questionGive only the references Bib.pdf
Dont respond to this questionGive only the references Bib.pdfDont respond to this questionGive only the references Bib.pdf
Dont respond to this questionGive only the references Bib.pdf
 
dogh dogcpp maincpp For the code above How many MyCo Cop.pdf
dogh dogcpp maincpp For the code above How many MyCo Cop.pdfdogh dogcpp maincpp For the code above How many MyCo Cop.pdf
dogh dogcpp maincpp For the code above How many MyCo Cop.pdf
 
Donald Lyles 52year old male was admitted yesterday eveni.pdf
Donald Lyles 52year old male was admitted yesterday eveni.pdfDonald Lyles 52year old male was admitted yesterday eveni.pdf
Donald Lyles 52year old male was admitted yesterday eveni.pdf
 
Domes and basins In some folds Inliers and outliersFigur.pdf
Domes and basins  In some folds Inliers and outliersFigur.pdfDomes and basins  In some folds Inliers and outliersFigur.pdf
Domes and basins In some folds Inliers and outliersFigur.pdf
 
Dolce is an Italian company selling highend turnkey kitchen.pdf
Dolce is an Italian company selling highend turnkey kitchen.pdfDolce is an Italian company selling highend turnkey kitchen.pdf
Dolce is an Italian company selling highend turnkey kitchen.pdf
 
Do This Consider the partial class declarations below A co.pdf
Do This Consider the partial class declarations below A co.pdfDo This Consider the partial class declarations below A co.pdf
Do This Consider the partial class declarations below A co.pdf
 
Doede Corporation uses activitybased costing to compute pro.pdf
Doede Corporation uses activitybased costing to compute pro.pdfDoede Corporation uses activitybased costing to compute pro.pdf
Doede Corporation uses activitybased costing to compute pro.pdf
 
Does anyone have a photo of the completed moon map I need t.pdf
Does anyone have a photo of the completed moon map I need t.pdfDoes anyone have a photo of the completed moon map I need t.pdf
Does anyone have a photo of the completed moon map I need t.pdf
 
Document your result for H influenzae below 1 What is the.pdf
Document your result for H influenzae below 1 What is the.pdfDocument your result for H influenzae below 1 What is the.pdf
Document your result for H influenzae below 1 What is the.pdf
 
Doal gaz doru bir ekilde tanmlayan ifadeyi sein Fracking.pdf
Doal gaz doru bir ekilde tanmlayan ifadeyi sein  Fracking.pdfDoal gaz doru bir ekilde tanmlayan ifadeyi sein  Fracking.pdf
Doal gaz doru bir ekilde tanmlayan ifadeyi sein Fracking.pdf
 
Do it in Java Problem4 Natural Language Processing Writ.pdf
Do it in Java Problem4 Natural Language Processing Writ.pdfDo it in Java Problem4 Natural Language Processing Writ.pdf
Do it in Java Problem4 Natural Language Processing Writ.pdf
 
Diyelim ki mevcut d politikann aksine ABD ve Meksika farkl .pdf
Diyelim ki mevcut d politikann aksine ABD ve Meksika farkl .pdfDiyelim ki mevcut d politikann aksine ABD ve Meksika farkl .pdf
Diyelim ki mevcut d politikann aksine ABD ve Meksika farkl .pdf
 
Do it in Java Please ExamPrep4_Spring2023 Source Packages lo.pdf
Do it in Java Please ExamPrep4_Spring2023 Source Packages lo.pdfDo it in Java Please ExamPrep4_Spring2023 Source Packages lo.pdf
Do it in Java Please ExamPrep4_Spring2023 Source Packages lo.pdf
 
DNA replikasyonundan geen bakterileri moleklleri izlemeni.pdf
DNA replikasyonundan geen bakterileri moleklleri izlemeni.pdfDNA replikasyonundan geen bakterileri moleklleri izlemeni.pdf
DNA replikasyonundan geen bakterileri moleklleri izlemeni.pdf
 
DNA exits mostly as a double stranded molecule Because of .pdf
DNA exits mostly as a double stranded molecule Because of .pdfDNA exits mostly as a double stranded molecule Because of .pdf
DNA exits mostly as a double stranded molecule Because of .pdf
 
Dk bir gerileme R2 u anlama gelir A sol taraftaki d.pdf
Dk bir gerileme  R2  u anlama gelir   A  sol taraftaki d.pdfDk bir gerileme  R2  u anlama gelir   A  sol taraftaki d.pdf
Dk bir gerileme R2 u anlama gelir A sol taraftaki d.pdf
 
Divisional Income Statements and Retum on fnvestment Analysi.pdf
Divisional Income Statements and Retum on fnvestment Analysi.pdfDivisional Income Statements and Retum on fnvestment Analysi.pdf
Divisional Income Statements and Retum on fnvestment Analysi.pdf
 
discussing Monopolies and Externalities Positive and Negati.pdf
discussing Monopolies and Externalities Positive and Negati.pdfdiscussing Monopolies and Externalities Positive and Negati.pdf
discussing Monopolies and Externalities Positive and Negati.pdf
 
Distinguish time clauses from conditions and name the types .pdf
Distinguish time clauses from conditions and name the types .pdfDistinguish time clauses from conditions and name the types .pdf
Distinguish time clauses from conditions and name the types .pdf
 

Último

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Último (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 

Do part C Problem The Fishers Iris data set is a dataset co.pdf

  • 1. Do part C Problem The Fisher's Iris data set is a dataset containing 150 samples, each of which has four attributes Petal Length, Petal Width, Sepal Length, Sepal width and a species label. The species can be predicted based on the four features associated with each sample. More details about the dataset are available in this Wikipedia page: https:/len. wikipedia.org/wiki/lris flower data set. The data can be assessed by loading the mat file provided in this assignment. Two items Irismeasurements and Irisclass should be loaded into the workspace. Irismeasurements is a 1504 matrix containing the four features of 150 iris samples, with each row corresponding to the features of each sample. Irisclass is a 150-element column vector specifying the species of the 150 samples. In Irisclass, 1, 2, 3 encode the species setosa, versicolor and virginica, respectively. (a) (60 marks) Write a Python function called KNearestNeighbour that uses the KNN algorithm to classify a test set based on a training set (i.e., determine the species of each data point in the test set). Save the function in a file named KNearestNeighbour.py. Your function should be well- commented. The function header should have the form: def KNearestNeighbour (TestMeasurements, TrainMeasurements, Trainclass, K) where Testmeasurements is an M4 matrix containing the feature vector of M test samples, TrainMeasurements is a N4 matrix containing the feature vectors of the training set and TrainClass is a N-element vector containing the species label of the N training samples, K is the parameter K used in KNN. The function should return a M element vector showing classification results generated by KNN for the test samples. You are allowed to use all built-in functions except those related to kNeighborsClassifier, which is the built-in class for KNN classification. (b) (10 marks) Write a Python script to test the function you wrote in Part (a). Use the first 100 samples in the data set as training set and the last 50 samples as the testing set. Set K= 5. Your test code should be written and saved in a Jupyter notebook called TestKNearestNeighbour. ipynb. (c) (30 marks) Write a Python script to implement the lockbox approach. Save the script in a Jupyter notebook called LockBoxKNN . ipynb. Use the first 50 samples as the training data, the next 50 samples as validation data and the last 50 samples as the test data. Use the function you wrote in Part (a) for all KNN classifications required. When tuning the parameter K, consider all even K inside the range 1K21. Tabulate the accuracy for