Skip to content

Scikit Learn Video

changwu edited this page Jun 13, 2016 · 20 revisions

Scikit-Learn 學習

筆記

scikit-learn video #4: Model training and prediction with K-nearest neighbors

  • 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?

scikit-learn 4-step modeling pattern

# import the class
from sklearn.linear_model import LogisticRegression

# instantiate the model (using the default parameters)
logreg = LogisticRegression()

# fit the model with data
logreg.fit(X, y)

# predict the response for new observations
logreg.predict(X_new)

Step 1: Import the class you plan to use

Step 2: "Instantiate" the "estimator"

  • "Estimator" is scikit-learn's term for model
  • "Instantiate" means "make an instance of"

Step 3: Fit the model with data (aka "model training")

  • Model is learning the relationship between X and y
  • Occurs in-place

Step 4: Predict the response for a new observation

  • New observations are called "out-of-sample" data
  • Uses the information it learned during the model training process

scikit-learn video #3: Machine learning first steps with the Iris dataset

  • What is the famous Iris dataset, and how does it relate to machine learning?
  • How do we load the Iris dataset into scikit-learn?
  • How do we describe a dataset using machine learning terminology?
  • What are scikit-learn's four key requirements for working with data?

資料的處理型態:

  1. Features and response are separate objects
  2. Features and response should be numeric
  3. Features and response should be NumPy arrays
  4. Features and response should have specific shapes

推薦閱讀

  • Jake VanderPlas: Fast Numerical Computing with NumPy (slide, video)
  • Scott Shell: An Introduction to NumPy (PDF)

scikit-learn video #2: Setting up Python for machine learning

  • What are the benefits and drawbacks of scikit-learn?
  • How do I install scikit-learn?
  • How do I use the IPython Notebook?
  • What are some good resources for learning Python?

推薦閱讀

scikit-learn video #1: Intro to machine learning with scikit-learn

  1. What is machine learning?
  2. What are the two main categories of machine learning?
  3. What are some examples of machine learning?
  4. How does machine learning "work"?

推薦閱讀

1.監督式學習 (Supervised learning)

[input, correct output]

supervised

2.無監督學習 (Unsupervised learning)

[input]

  • 從 high-level 的角度學習

unsupervised

3.強化學習 (Reinforcement learning)

[input, some output, grade for this output]

  • 學習杯子冷熱的過程
  • 學習打牌的過程

相關連結

學習記錄

  1. 0613 (4/10)

Clone this wiki locally