Source From Here
Preface
Agenda
* What is the K-nearest neighbors classification model?
* What are the four steps for model training and prediction in scikit-learn?
* How can I apply this pattern to other machine learning models?
Reviewing the iris dataset
* 150 observationss
* 4 features (sepal length, sepal width, petal length, petal width)
* Response variable is the iris species
* Classification problem since response is categorical
How To Use Scikit-learn to train model
Loading the Data
scikit-learn 4-step modeling pattern
Step1: Import the class you plan to use
Step2: "Instantiate" the "estimator" (Here is KNeighborsClassifier)
Step3: Fit the model with data (aka "Model training")
* Model is learning the relationship between X and y
* Occurs in-place
Step4: Predict the response for a new observation
* New observations are called "out-of-sample" data
* Use the information it learned during the model training process
* Return a NumPy array
* Can predict for multiple observations at once
Using a different value for K
Using a different classification model
Consistent APIs make you easily to use other model relatively easily. Below will use LogisticRegression instead:
Supplement
* Previous section - Getting started in scikit-learn with the famous iris dataset
* Next section - Comparing machine learning models in scikit-learn
* Supervised Learning - 1.6 Nearest Neighbors
* 1.1.11. Logistic regression
* In-depth introduction to machine learning in 15 hours of expert videos
Preface
Agenda
* What is the K-nearest neighbors classification model?
* What are the four steps for model training and prediction in scikit-learn?
* How can I apply this pattern to other machine learning models?
Reviewing the iris dataset
* 150 observationss
* 4 features (sepal length, sepal width, petal length, petal width)
* Response variable is the iris species
* Classification problem since response is categorical
How To Use Scikit-learn to train model
Loading the Data
scikit-learn 4-step modeling pattern
Step1: Import the class you plan to use
Step2: "Instantiate" the "estimator" (Here is KNeighborsClassifier)
Step3: Fit the model with data (aka "Model training")
* Model is learning the relationship between X and y
* Occurs in-place
Step4: Predict the response for a new observation
* New observations are called "out-of-sample" data
* Use the information it learned during the model training process
* Return a NumPy array
* Can predict for multiple observations at once
Using a different value for K
Using a different classification model
Consistent APIs make you easily to use other model relatively easily. Below will use LogisticRegression instead:
Supplement
* Previous section - Getting started in scikit-learn with the famous iris dataset
* Next section - Comparing machine learning models in scikit-learn
* Supervised Learning - 1.6 Nearest Neighbors
* 1.1.11. Logistic regression
* In-depth introduction to machine learning in 15 hours of expert videos
沒有留言:
張貼留言