From ff837c63872c14cd12ac1038c26ec78ba6234a05 Mon Sep 17 00:00:00 2001 From: Ryan McCormick Date: Mon, 1 Apr 2019 23:40:00 -0700 Subject: [PATCH] Update Part 1 - Introduction to Machine Learning with scikit-learn.md add notes on Linear/Logistic regression, images in next commit --- ...n to Machine Learning with scikit-learn.md | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Part 1 - Introduction to Machine Learning with scikit-learn.md b/Part 1 - Introduction to Machine Learning with scikit-learn.md index 01325a9..9df191d 100644 --- a/Part 1 - Introduction to Machine Learning with scikit-learn.md +++ b/Part 1 - Introduction to Machine Learning with scikit-learn.md @@ -95,8 +95,8 @@ It can be tough to find a good ratio between the training and testing set size. --- -# Implementing a Machine Learning Algorithm -Let's get to the fun part - implementing these algorithms. +# Using a Machine Learning Algorithm +Let's get to the fun part - using these algorithms. For now, we'll start off with two regression-based algorithms for supervised learning - Linear Regression and Logistic Regression.     @@ -113,6 +113,14 @@ linear_model = LinearRegression() linear_model.fit(X_train, Y_train) ``` +Linear Regression is one of the gold standards in machine learning algorithms. It's very simple, powerful, and easy to +interpret. You can think of it as trying to draw a line of best fit in your data like so: + +![Linear Regression](images/line-of-best-fit.png) + +However, there are cases where drawing a simple line of best fit just won't help. That's where +Logistic Regression might come in handy! + **Logistic Regression** ``` # Initialize a LogisticRegression object @@ -121,6 +129,16 @@ logistic_model = LogisticRegression() logistic_model.fit(X_train, Y_train) ``` +In a very simple case, Logistic Regression can kind of be thought as drawing an +S-shaped line of best fit. Here's an example of where that might come in handy: + +![Logistic Regression](images/logit.jpeg) + +But Logistic Regression is generally used for classifying discrete values, whereas +Linear Regression is generally used for predicting continuous values. + +## Results + And now to test these algorithms: ``` print("Linear Regression accuracy:", str(linear_model.score(X_test, Y_test) * 100) + "%")