SlideShare a Scribd company logo
1 of 41
Download to read offline
Machine Learning with Scikit learn
Jayanti Prasad
Inter-University Centre for Astronomy & Astrophysics (IUCAA)
PUNE - 411007
June 22, 2018
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 1 / 41
Plan of the Talk
Plan of the Talk
Introduction
Scikit-learn
(1) Linear Regression
(2) Logistic Regression
(3) Nearest Neighbors
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 2 / 41
Introduction
Machine Learing : Definitions
Arthur Samuel
A field of study that gives computers the ability to learn without being
explicitly programmed.
Tom M. Mitchell
A computer program is said to learn from experience E with respect to
some class of tasks T and performance measure P, if its performance at
tasks in T, as measured by P, improves with the experience E.
Here we need to define :
Task (T), either one or more
Experience (E)
Performance (P)
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 3 / 41
Introduction
Machine Learning
Training Machines to see patterns in the data and learn from that - Ability
to learn in a changing environment.
INPUT
OUTPUT
ALGORITHM
INPUT
OUTPUT
ALGORITHM
NORMAL COMPUTING MACHINE LEARNING
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 4 / 41
Introduction
Machine Learning
DATA
LABELLED (X,y) UNLABELLED (X)
X-Features
y- Target
SUPERVISED
UNSUPERVISED
REGRESSION CLASSIFICATION
CLUSTERING
SIMILARITY
LINK PREDICTION
DATA REDUCTION
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 5 / 41
Introduction
Layman’s Machine Learning (Supervised) Recipes
1 Split the data into two parts: Training/Learning and Testing.
(X, y) = (XTrain, yTrain) + (XTest, yTest) (1)
2 Find a model f (X, θ) : X −→ y from the training data. This need
some mismatch function to be minimized.
χ2
(θ) =
N
i=1
(yi − f (Xi , θ))2
(2)
3 The model could be predictive (make predictions in the future), or
descriptive (gain knowledge from data), or both.
4 Apply the model on testing data and find the accuracy.
5 Once satisfied apply model for some unknown feature X and get the
target y for that.
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 6 / 41
Introduction
Machine Learning: Frameworks
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 7 / 41
scikit-learn
Scitkit-learn : What it is ?
Scikit-learn is a free machine learning library for the Python
programming language.
The scikit-learn project started as scikits.learn, a Google Summer of
Code project by David Cournapeau.
Its name stems from the notion that it is a "SciKit" (SciPy Toolkit), a
separately-developed and distributed third-party extension to SciPy.
Scikit-learn is largely written in Python, with some core algorithms
written in Cython to achieve performance.
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 8 / 41
scikit-learn
Scikit-learn : Why to learn ?
If you have problem with a lot of data and you want to draw insight
from that using some open source python library.
If you want to understand common problems of Machine Learning
such as regression, classification, clusters ...
If you want to develop new techniques or compare different techniques.
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 9 / 41
scikit-learn
Scikit-learn : What it has ?
Reference : http://scikit-learn.org/stable/index.html
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 10 / 41
scikit-learn
Scikit-learn : Installation
Scikit-learn requires:
Python (>= 2.7 or >= 3.3),
NumPy (>= 1.8.2),
SciPy (>= 0.13.3).
One can install it from the source by cloning the git repo:
git clone https://github.com/scikit-learn/scikit-learn.git
pip install -U scikit-learn
conda install scikit-learn
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 11 / 41
scikit-learn
Scikit-learn : The package/s
cluster
compose
covariance
cross_decomposition
cross_validation
datasets
decomposition
discriminant_analysis
ensemble
externals
feature_extraction
feature_selection
gaussian_process
linear_model
manifold
metrics
mixture
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 12 / 41
scikit-learn
scikit-learn packages
model_selection
neighbors
neural_network
preprocessing
random_projection
semi_supervised
svm
tests
tree
utils
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 13 / 41
scikit-learn
Scikit-learn : Test datasets
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 14 / 41
scikit-learn
Test datasets
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 15 / 41
scikit-learn
Datasets
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 16 / 41
scikit-learn
Test datasets : Iris Flower species
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 17 / 41
scikit-learn
Test datasets : Iris Flower species
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 18 / 41
Linear Regression
Linear Regression : Theory
1 The data is fitted with a linear model :
yi =
N
j=1
wi xi = w0 + w1xi for one dimensional case. (3)
2 Minimize the mismatch (wrt w0 and w1) for training data :
χ2
(w, X) = |yi − (w0 + w1xi )|2
(4)
3 Apply the model on testing data and see the accuracy.
4 Once satisfied apply the model for unknown data.
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 19 / 41
Linear Regression Example 1
Linear Regression : Examples
[linear-regression-general.ipynb]
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 20 / 41
Linear Regression Example 1
Linear Regression: Examples [linear-regression-general.ipynb]
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 21 / 41
Linear Regression Example 1
Linear Regression : Ridge (Regularization)
Ordinary Least Square (OLS) can over-fit the data and in order to
avoid that we add an extra term in the mismatch function.
Q(w, X) = |yi − (w0 + w1xi )|2
+ λR(w, X), (5)
where λ is the regularization parameter and R is regularization
function.
There are many choices for R and one of those is the what is called L2
norm.
Q(w, X) = |yi − (w0 + w1xi )|2
+ λ||w||2
2 (6)
There are many ways to set the regularization parameter λ and one of
those is generalized Cross-Validation.
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 22 / 41
Linear Regression Example 2
Linear Regression : Example [linear-regression-ridge.ipynb]
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 23 / 41
Linear Regression Example 2
Linear Regression [linear-regression-ridge.ipynb]
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 24 / 41
Logistic Regression
Logistic Regression
It is used when the ’target’ is binary - ’0’ and ’1’ or ’yes’ and ’no’.
If the probability of ’1’ is ’p’ then the ’odd’ is defined as p/(1 − p) and
a function called ’logit’ is defined as :
l = ln
p
1 − p
(7)
We try to compute p by fitting a line to the ’logit’ function:
ln
p
1 − p
= w0 + w1 ∗ x, (8)
which gives:
p =
1
1 + e−(w0+w1∗x)
(9)
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 25 / 41
Logistic Regression
Logistic Regression
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 26 / 41
Logistic Regression Example 3
Logistic Regression : MNIST
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 27 / 41
Logistic Regression Example 3
Logistic Regression : MNIST
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 28 / 41
Logistic Regression Example 3
Logistic Regression: MNIST
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 29 / 41
Logistic Regression Example 4
Logistic Regression: Iris
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 30 / 41
Logistic Regression Example 4
Logistic Regression: Iris
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 31 / 41
Nearest neighbors
Nearest neighbors : Theory
Nearest Neighbors is one of the import techniques of ML which can be
used for supervised as well as un-supervised learning.
sklearn.neighbors package from scikit-learn can be used for this
purpose.
The principle behind nearest neighbor methods is to find a predefined
number of training samples closest in distance to the new point, and
predict the label from these.
The number of samples can be a user-defined constant (k-nearest
neighbor learning), or vary based on the local density of points
(radius-based neighbor learning).
The distance can, in general, be any metric measure: standard
Euclidean distance is the most common choice,
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 32 / 41
Nearest neighbors
Nearest neighbors : Scikit-learn
scikit-learn implements two different nearest neighbors classifiers:
KNeighborsClassifier: learning based on the k nearest neighbors of each
query point.
RadiusNeighborsClassifier: learning based on the number of neighbors
within a fixed radius r of each training point.
Weights to neighbours can be uniform or non-uniform.
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 33 / 41
Nearest neighbors
Nearest Neighbors : Regression
NN based regression can be used for the purpose when ’labels’ are
continuous in place of discrete.
The ’label’ for the query point can be found from the mean of the
labels of the nearest points.
NN based regression can be used for finding some missing/blurred area
in an image.
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 34 / 41
Nearest neighbors
Nearest neighbors
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 35 / 41
Nearest neighbors Example 5
Iris with NN: [knn-neighbours-iris.ipynb]
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 36 / 41
Nearest neighbors Example 5
Iris classification with Nearest Neighbors
We can consider only two features of the iris flowers.
Can make prediction for all the points on the two dimensional grid on
the basis of nearest neighbors.
The result can be shown by a plot with distinct regions for different
type of flowers.
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 37 / 41
Nearest neighbors Example
Iris KNN : [knn-iris.ipynb]
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 38 / 41
Nearest neighbors Example
Iris KNN : [knn-iris.ipynb]
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 39 / 41
Nearest neighbors Example
Thank You !
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 40 / 41
Nearest neighbors Example
References
1 http://scikit-learn.org/stable/documentation.html
2 Guillermo Moncecchi and Raul Garreta, Learning Scikit-learn: Machine
Learning in Python
3 Trent Hauck, Scikit-Learn Cookbook
Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 41 / 41

More Related Content

What's hot

2019 Fighting Game AI Competition
2019 Fighting Game AI Competition2019 Fighting Game AI Competition
2019 Fighting Game AI Competitionftgaic
 
2020 Fighting Game AI Competition
2020 Fighting Game AI Competition2020 Fighting Game AI Competition
2020 Fighting Game AI Competitionftgaic
 
RAIL: Risk-Averse Imitation Learning | Invited talk at Intel AI Workshop at K...
RAIL: Risk-Averse Imitation Learning | Invited talk at Intel AI Workshop at K...RAIL: Risk-Averse Imitation Learning | Invited talk at Intel AI Workshop at K...
RAIL: Risk-Averse Imitation Learning | Invited talk at Intel AI Workshop at K...Anirban Santara
 
ShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReportShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReportShawn Quinn
 
2018 Fighting Game AI Competition
2018 Fighting Game AI Competition 2018 Fighting Game AI Competition
2018 Fighting Game AI Competition ftgaic
 
2015 Fighting Game Artificial Intelligence Competition
2015 Fighting Game Artificial Intelligence Competition2015 Fighting Game Artificial Intelligence Competition
2015 Fighting Game Artificial Intelligence Competitionftgaic
 
IRJET- Student Placement Prediction using Machine Learning
IRJET- Student Placement Prediction using Machine LearningIRJET- Student Placement Prediction using Machine Learning
IRJET- Student Placement Prediction using Machine LearningIRJET Journal
 
Machine learning visual_quiz
Machine learning visual_quizMachine learning visual_quiz
Machine learning visual_quizUmmeSalmaM1
 

What's hot (10)

2019 Fighting Game AI Competition
2019 Fighting Game AI Competition2019 Fighting Game AI Competition
2019 Fighting Game AI Competition
 
2020 Fighting Game AI Competition
2020 Fighting Game AI Competition2020 Fighting Game AI Competition
2020 Fighting Game AI Competition
 
presentationIDC - 14MAY2015
presentationIDC - 14MAY2015presentationIDC - 14MAY2015
presentationIDC - 14MAY2015
 
Open-ended Visual Question-Answering
Open-ended  Visual Question-AnsweringOpen-ended  Visual Question-Answering
Open-ended Visual Question-Answering
 
RAIL: Risk-Averse Imitation Learning | Invited talk at Intel AI Workshop at K...
RAIL: Risk-Averse Imitation Learning | Invited talk at Intel AI Workshop at K...RAIL: Risk-Averse Imitation Learning | Invited talk at Intel AI Workshop at K...
RAIL: Risk-Averse Imitation Learning | Invited talk at Intel AI Workshop at K...
 
ShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReportShawnQuinnCSS581FinalProjectReport
ShawnQuinnCSS581FinalProjectReport
 
2018 Fighting Game AI Competition
2018 Fighting Game AI Competition 2018 Fighting Game AI Competition
2018 Fighting Game AI Competition
 
2015 Fighting Game Artificial Intelligence Competition
2015 Fighting Game Artificial Intelligence Competition2015 Fighting Game Artificial Intelligence Competition
2015 Fighting Game Artificial Intelligence Competition
 
IRJET- Student Placement Prediction using Machine Learning
IRJET- Student Placement Prediction using Machine LearningIRJET- Student Placement Prediction using Machine Learning
IRJET- Student Placement Prediction using Machine Learning
 
Machine learning visual_quiz
Machine learning visual_quizMachine learning visual_quiz
Machine learning visual_quiz
 

Similar to Scikit-learn1

Programing Slicing and Its applications
Programing Slicing and Its applicationsPrograming Slicing and Its applications
Programing Slicing and Its applicationsAnkur Jain
 
Machine learning and_neural_network_lecture_slide_ece_dku
Machine learning and_neural_network_lecture_slide_ece_dkuMachine learning and_neural_network_lecture_slide_ece_dku
Machine learning and_neural_network_lecture_slide_ece_dkuSeokhyun Yoon
 
Water Quality Index Calculation of River Ganga using Decision Tree Algorithm
Water Quality Index Calculation of River Ganga using Decision Tree AlgorithmWater Quality Index Calculation of River Ganga using Decision Tree Algorithm
Water Quality Index Calculation of River Ganga using Decision Tree AlgorithmIRJET Journal
 
Machine Learning - Object Detection and Classification
Machine Learning - Object Detection and ClassificationMachine Learning - Object Detection and Classification
Machine Learning - Object Detection and ClassificationVikas Jain
 
Top 5 Data Analytics course in Rajouri Garden
Top 5 Data Analytics course in Rajouri GardenTop 5 Data Analytics course in Rajouri Garden
Top 5 Data Analytics course in Rajouri GardenSaanviJoshi3
 
IRJET- The Machine Learning: The method of Artificial Intelligence
IRJET- The Machine Learning: The method of Artificial IntelligenceIRJET- The Machine Learning: The method of Artificial Intelligence
IRJET- The Machine Learning: The method of Artificial IntelligenceIRJET Journal
 
mushroom classification using machine learning
mushroom classification using machine learningmushroom classification using machine learning
mushroom classification using machine learningARUPSARKAR202E11
 
Enhanced Privacy Preserving Access Control in Incremental Data using microagg...
Enhanced Privacy Preserving Access Control in Incremental Data using microagg...Enhanced Privacy Preserving Access Control in Incremental Data using microagg...
Enhanced Privacy Preserving Access Control in Incremental Data using microagg...ravi sharma
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningDr. Radhey Shyam
 
Presentation Template__TY_AIML_IE2_Project (1).pptx
Presentation Template__TY_AIML_IE2_Project (1).pptxPresentation Template__TY_AIML_IE2_Project (1).pptx
Presentation Template__TY_AIML_IE2_Project (1).pptxSYETB202RandhirBhosa
 
ACC_dohuan
ACC_dohuanACC_dohuan
ACC_dohuanDo Huan
 
2021_06_30 «Stealth Assessment of Physics Understanding in Physics Playground»
2021_06_30 «Stealth Assessment of Physics Understanding in Physics Playground»2021_06_30 «Stealth Assessment of Physics Understanding in Physics Playground»
2021_06_30 «Stealth Assessment of Physics Understanding in Physics Playground»eMadrid network
 
Learning Strategy with Groups on Page Based Students' Profiles
Learning Strategy with Groups on Page Based Students' ProfilesLearning Strategy with Groups on Page Based Students' Profiles
Learning Strategy with Groups on Page Based Students' Profilesaciijournal
 
Automatic selection of object recognition methods using reinforcement learning
Automatic selection of object recognition methods using reinforcement learningAutomatic selection of object recognition methods using reinforcement learning
Automatic selection of object recognition methods using reinforcement learningShunta Saito
 
Machine Learning Crash Course by Sebastian Raschka
Machine Learning Crash Course by Sebastian RaschkaMachine Learning Crash Course by Sebastian Raschka
Machine Learning Crash Course by Sebastian RaschkaPawanJayarathna1
 
Learning strategy with groups on page based students' profiles
Learning strategy with groups on page based students' profilesLearning strategy with groups on page based students' profiles
Learning strategy with groups on page based students' profilesaciijournal
 
Big-Data Analytics for Media Management
Big-Data Analytics for Media ManagementBig-Data Analytics for Media Management
Big-Data Analytics for Media Managementtechkrish
 

Similar to Scikit-learn1 (20)

Programing Slicing and Its applications
Programing Slicing and Its applicationsPrograming Slicing and Its applications
Programing Slicing and Its applications
 
ML_Lec1.pdf
ML_Lec1.pdfML_Lec1.pdf
ML_Lec1.pdf
 
Machine learning and_neural_network_lecture_slide_ece_dku
Machine learning and_neural_network_lecture_slide_ece_dkuMachine learning and_neural_network_lecture_slide_ece_dku
Machine learning and_neural_network_lecture_slide_ece_dku
 
Water Quality Index Calculation of River Ganga using Decision Tree Algorithm
Water Quality Index Calculation of River Ganga using Decision Tree AlgorithmWater Quality Index Calculation of River Ganga using Decision Tree Algorithm
Water Quality Index Calculation of River Ganga using Decision Tree Algorithm
 
Machine Learning - Object Detection and Classification
Machine Learning - Object Detection and ClassificationMachine Learning - Object Detection and Classification
Machine Learning - Object Detection and Classification
 
Top 5 Data Analytics course in Rajouri Garden
Top 5 Data Analytics course in Rajouri GardenTop 5 Data Analytics course in Rajouri Garden
Top 5 Data Analytics course in Rajouri Garden
 
Review_Cibe Sridharan
Review_Cibe SridharanReview_Cibe Sridharan
Review_Cibe Sridharan
 
IRJET- The Machine Learning: The method of Artificial Intelligence
IRJET- The Machine Learning: The method of Artificial IntelligenceIRJET- The Machine Learning: The method of Artificial Intelligence
IRJET- The Machine Learning: The method of Artificial Intelligence
 
QMC: Operator Splitting Workshop, Estimation of Inverse Covariance Matrix in ...
QMC: Operator Splitting Workshop, Estimation of Inverse Covariance Matrix in ...QMC: Operator Splitting Workshop, Estimation of Inverse Covariance Matrix in ...
QMC: Operator Splitting Workshop, Estimation of Inverse Covariance Matrix in ...
 
mushroom classification using machine learning
mushroom classification using machine learningmushroom classification using machine learning
mushroom classification using machine learning
 
Enhanced Privacy Preserving Access Control in Incremental Data using microagg...
Enhanced Privacy Preserving Access Control in Incremental Data using microagg...Enhanced Privacy Preserving Access Control in Incremental Data using microagg...
Enhanced Privacy Preserving Access Control in Incremental Data using microagg...
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Presentation Template__TY_AIML_IE2_Project (1).pptx
Presentation Template__TY_AIML_IE2_Project (1).pptxPresentation Template__TY_AIML_IE2_Project (1).pptx
Presentation Template__TY_AIML_IE2_Project (1).pptx
 
ACC_dohuan
ACC_dohuanACC_dohuan
ACC_dohuan
 
2021_06_30 «Stealth Assessment of Physics Understanding in Physics Playground»
2021_06_30 «Stealth Assessment of Physics Understanding in Physics Playground»2021_06_30 «Stealth Assessment of Physics Understanding in Physics Playground»
2021_06_30 «Stealth Assessment of Physics Understanding in Physics Playground»
 
Learning Strategy with Groups on Page Based Students' Profiles
Learning Strategy with Groups on Page Based Students' ProfilesLearning Strategy with Groups on Page Based Students' Profiles
Learning Strategy with Groups on Page Based Students' Profiles
 
Automatic selection of object recognition methods using reinforcement learning
Automatic selection of object recognition methods using reinforcement learningAutomatic selection of object recognition methods using reinforcement learning
Automatic selection of object recognition methods using reinforcement learning
 
Machine Learning Crash Course by Sebastian Raschka
Machine Learning Crash Course by Sebastian RaschkaMachine Learning Crash Course by Sebastian Raschka
Machine Learning Crash Course by Sebastian Raschka
 
Learning strategy with groups on page based students' profiles
Learning strategy with groups on page based students' profilesLearning strategy with groups on page based students' profiles
Learning strategy with groups on page based students' profiles
 
Big-Data Analytics for Media Management
Big-Data Analytics for Media ManagementBig-Data Analytics for Media Management
Big-Data Analytics for Media Management
 

More from Jayanti Prasad Ph.D. (14)

parallel-computation.pdf
parallel-computation.pdfparallel-computation.pdf
parallel-computation.pdf
 
thesis_seminar.pdf
thesis_seminar.pdfthesis_seminar.pdf
thesis_seminar.pdf
 
pso2015.pdf
pso2015.pdfpso2015.pdf
pso2015.pdf
 
nbody_iitk.pdf
nbody_iitk.pdfnbody_iitk.pdf
nbody_iitk.pdf
 
likelihood_p2.pdf
likelihood_p2.pdflikelihood_p2.pdf
likelihood_p2.pdf
 
likelihood_p1.pdf
likelihood_p1.pdflikelihood_p1.pdf
likelihood_p1.pdf
 
doing_parallel.pdf
doing_parallel.pdfdoing_parallel.pdf
doing_parallel.pdf
 
Artificial Intelligence - Anna Uni -v1.pdf
Artificial Intelligence - Anna Uni -v1.pdfArtificial Intelligence - Anna Uni -v1.pdf
Artificial Intelligence - Anna Uni -v1.pdf
 
CMB Likelihood Part 2
CMB Likelihood Part 2CMB Likelihood Part 2
CMB Likelihood Part 2
 
CMB Likelihood Part 1
CMB Likelihood Part 1CMB Likelihood Part 1
CMB Likelihood Part 1
 
Cmb part3
Cmb part3Cmb part3
Cmb part3
 
Cmb part2
Cmb part2Cmb part2
Cmb part2
 
Cmb part1
Cmb part1Cmb part1
Cmb part1
 
Parallel computation
Parallel computationParallel computation
Parallel computation
 

Recently uploaded

Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...amitlee9823
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...only4webmaster01
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsJoseMangaJr1
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Pooja Nehwal
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 

Recently uploaded (20)

Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 

Scikit-learn1

  • 1. Machine Learning with Scikit learn Jayanti Prasad Inter-University Centre for Astronomy & Astrophysics (IUCAA) PUNE - 411007 June 22, 2018 Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 1 / 41
  • 2. Plan of the Talk Plan of the Talk Introduction Scikit-learn (1) Linear Regression (2) Logistic Regression (3) Nearest Neighbors Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 2 / 41
  • 3. Introduction Machine Learing : Definitions Arthur Samuel A field of study that gives computers the ability to learn without being explicitly programmed. Tom M. Mitchell A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with the experience E. Here we need to define : Task (T), either one or more Experience (E) Performance (P) Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 3 / 41
  • 4. Introduction Machine Learning Training Machines to see patterns in the data and learn from that - Ability to learn in a changing environment. INPUT OUTPUT ALGORITHM INPUT OUTPUT ALGORITHM NORMAL COMPUTING MACHINE LEARNING Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 4 / 41
  • 5. Introduction Machine Learning DATA LABELLED (X,y) UNLABELLED (X) X-Features y- Target SUPERVISED UNSUPERVISED REGRESSION CLASSIFICATION CLUSTERING SIMILARITY LINK PREDICTION DATA REDUCTION Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 5 / 41
  • 6. Introduction Layman’s Machine Learning (Supervised) Recipes 1 Split the data into two parts: Training/Learning and Testing. (X, y) = (XTrain, yTrain) + (XTest, yTest) (1) 2 Find a model f (X, θ) : X −→ y from the training data. This need some mismatch function to be minimized. χ2 (θ) = N i=1 (yi − f (Xi , θ))2 (2) 3 The model could be predictive (make predictions in the future), or descriptive (gain knowledge from data), or both. 4 Apply the model on testing data and find the accuracy. 5 Once satisfied apply model for some unknown feature X and get the target y for that. Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 6 / 41
  • 7. Introduction Machine Learning: Frameworks Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 7 / 41
  • 8. scikit-learn Scitkit-learn : What it is ? Scikit-learn is a free machine learning library for the Python programming language. The scikit-learn project started as scikits.learn, a Google Summer of Code project by David Cournapeau. Its name stems from the notion that it is a "SciKit" (SciPy Toolkit), a separately-developed and distributed third-party extension to SciPy. Scikit-learn is largely written in Python, with some core algorithms written in Cython to achieve performance. Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 8 / 41
  • 9. scikit-learn Scikit-learn : Why to learn ? If you have problem with a lot of data and you want to draw insight from that using some open source python library. If you want to understand common problems of Machine Learning such as regression, classification, clusters ... If you want to develop new techniques or compare different techniques. Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 9 / 41
  • 10. scikit-learn Scikit-learn : What it has ? Reference : http://scikit-learn.org/stable/index.html Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 10 / 41
  • 11. scikit-learn Scikit-learn : Installation Scikit-learn requires: Python (>= 2.7 or >= 3.3), NumPy (>= 1.8.2), SciPy (>= 0.13.3). One can install it from the source by cloning the git repo: git clone https://github.com/scikit-learn/scikit-learn.git pip install -U scikit-learn conda install scikit-learn Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 11 / 41
  • 12. scikit-learn Scikit-learn : The package/s cluster compose covariance cross_decomposition cross_validation datasets decomposition discriminant_analysis ensemble externals feature_extraction feature_selection gaussian_process linear_model manifold metrics mixture Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 12 / 41
  • 14. scikit-learn Scikit-learn : Test datasets Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 14 / 41
  • 15. scikit-learn Test datasets Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 15 / 41
  • 16. scikit-learn Datasets Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 16 / 41
  • 17. scikit-learn Test datasets : Iris Flower species Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 17 / 41
  • 18. scikit-learn Test datasets : Iris Flower species Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 18 / 41
  • 19. Linear Regression Linear Regression : Theory 1 The data is fitted with a linear model : yi = N j=1 wi xi = w0 + w1xi for one dimensional case. (3) 2 Minimize the mismatch (wrt w0 and w1) for training data : χ2 (w, X) = |yi − (w0 + w1xi )|2 (4) 3 Apply the model on testing data and see the accuracy. 4 Once satisfied apply the model for unknown data. Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 19 / 41
  • 20. Linear Regression Example 1 Linear Regression : Examples [linear-regression-general.ipynb] Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 20 / 41
  • 21. Linear Regression Example 1 Linear Regression: Examples [linear-regression-general.ipynb] Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 21 / 41
  • 22. Linear Regression Example 1 Linear Regression : Ridge (Regularization) Ordinary Least Square (OLS) can over-fit the data and in order to avoid that we add an extra term in the mismatch function. Q(w, X) = |yi − (w0 + w1xi )|2 + λR(w, X), (5) where λ is the regularization parameter and R is regularization function. There are many choices for R and one of those is the what is called L2 norm. Q(w, X) = |yi − (w0 + w1xi )|2 + λ||w||2 2 (6) There are many ways to set the regularization parameter λ and one of those is generalized Cross-Validation. Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 22 / 41
  • 23. Linear Regression Example 2 Linear Regression : Example [linear-regression-ridge.ipynb] Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 23 / 41
  • 24. Linear Regression Example 2 Linear Regression [linear-regression-ridge.ipynb] Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 24 / 41
  • 25. Logistic Regression Logistic Regression It is used when the ’target’ is binary - ’0’ and ’1’ or ’yes’ and ’no’. If the probability of ’1’ is ’p’ then the ’odd’ is defined as p/(1 − p) and a function called ’logit’ is defined as : l = ln p 1 − p (7) We try to compute p by fitting a line to the ’logit’ function: ln p 1 − p = w0 + w1 ∗ x, (8) which gives: p = 1 1 + e−(w0+w1∗x) (9) Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 25 / 41
  • 26. Logistic Regression Logistic Regression Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 26 / 41
  • 27. Logistic Regression Example 3 Logistic Regression : MNIST Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 27 / 41
  • 28. Logistic Regression Example 3 Logistic Regression : MNIST Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 28 / 41
  • 29. Logistic Regression Example 3 Logistic Regression: MNIST Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 29 / 41
  • 30. Logistic Regression Example 4 Logistic Regression: Iris Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 30 / 41
  • 31. Logistic Regression Example 4 Logistic Regression: Iris Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 31 / 41
  • 32. Nearest neighbors Nearest neighbors : Theory Nearest Neighbors is one of the import techniques of ML which can be used for supervised as well as un-supervised learning. sklearn.neighbors package from scikit-learn can be used for this purpose. The principle behind nearest neighbor methods is to find a predefined number of training samples closest in distance to the new point, and predict the label from these. The number of samples can be a user-defined constant (k-nearest neighbor learning), or vary based on the local density of points (radius-based neighbor learning). The distance can, in general, be any metric measure: standard Euclidean distance is the most common choice, Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 32 / 41
  • 33. Nearest neighbors Nearest neighbors : Scikit-learn scikit-learn implements two different nearest neighbors classifiers: KNeighborsClassifier: learning based on the k nearest neighbors of each query point. RadiusNeighborsClassifier: learning based on the number of neighbors within a fixed radius r of each training point. Weights to neighbours can be uniform or non-uniform. Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 33 / 41
  • 34. Nearest neighbors Nearest Neighbors : Regression NN based regression can be used for the purpose when ’labels’ are continuous in place of discrete. The ’label’ for the query point can be found from the mean of the labels of the nearest points. NN based regression can be used for finding some missing/blurred area in an image. Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 34 / 41
  • 35. Nearest neighbors Nearest neighbors Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 35 / 41
  • 36. Nearest neighbors Example 5 Iris with NN: [knn-neighbours-iris.ipynb] Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 36 / 41
  • 37. Nearest neighbors Example 5 Iris classification with Nearest Neighbors We can consider only two features of the iris flowers. Can make prediction for all the points on the two dimensional grid on the basis of nearest neighbors. The result can be shown by a plot with distinct regions for different type of flowers. Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 37 / 41
  • 38. Nearest neighbors Example Iris KNN : [knn-iris.ipynb] Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 38 / 41
  • 39. Nearest neighbors Example Iris KNN : [knn-iris.ipynb] Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 39 / 41
  • 40. Nearest neighbors Example Thank You ! Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 40 / 41
  • 41. Nearest neighbors Example References 1 http://scikit-learn.org/stable/documentation.html 2 Guillermo Moncecchi and Raul Garreta, Learning Scikit-learn: Machine Learning in Python 3 Trent Hauck, Scikit-Learn Cookbook Jayanti Prasad (IUCAA-PUNE) Machine Learning with scikit-learn June 22, 2018 41 / 41