From 6605d61db2546c2523362a1d801fad568cf28145 Mon Sep 17 00:00:00 2001 From: Ezio Date: Tue, 2 Aug 2016 00:01:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E9=98=9F=E7=BF=BB=E8=AF=91=20Building?= =?UTF-8?q?=20a=20data=20science=20portfolio=20-=20Machine=20learning=20pr?= =?UTF-8?q?oject?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ence portfolio - Machine learning project.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/sources/team_test/part 6 - Building a data science portfolio - Machine learning project.md b/sources/team_test/part 6 - Building a data science portfolio - Machine learning project.md index e99087b496..86ecbe127d 100644 --- a/sources/team_test/part 6 - Building a data science portfolio - Machine learning project.md +++ b/sources/team_test/part 6 - Building a data science portfolio - Machine learning project.md @@ -1,20 +1,3 @@ -### Setting up the classifier for machine learning - -We’ll use cross validation to make predictions. With cross validation, we’ll divide our data into 3 groups. Then we’ll do the following: - -- Train a model on groups 1 and 2, and use the model to make predictions for group 3. -- Train a model on groups 1 and 3, and use the model to make predictions for group 2. -- Train a model on groups 2 and 3, and use the model to make predictions for group 1. - -Splitting it up into groups this way means that we never train a model using the same data we’re making predictions for. This avoids overfitting. If we overfit, we’ll get a falsely low false negative rate, which makes it hard to improve our algorithm or use it in the real world. - -[Scikit-learn][35] has a function called [cross_val_predict][36] which will make it easy to perform cross validation. - -We’ll also need to pick an algorithm to use to make predictions. We need a classifier that can do [binary classification][37]. The target variable, foreclosure_status only has two values, True and False. - -We’ll use [logistic regression][38], because it works well for binary classification, runs extremely quickly, and uses little memory. This is due to how the algorithm works – instead of constructing dozens of trees, like a random forest, or doing expensive transformations, like a support vector machine, logistic regression has far fewer steps involving fewer matrix operations. - -We can use the [logistic regression classifier][39] algorithm that’s implemented in scikit-learn. The only thing we need to pay attention to is the weights of each class. If we weight the classes equally, the algorithm will predict False for every row, because it is trying to minimize errors. However, we care much more about foreclosures than we do about loans that aren’t foreclosed on. Thus, we’ll pass balanced to the class_weight keyword argument of the [LogisticRegression][40] class, to get the algorithm to weight the foreclosures more to account for the difference in the counts of each class. This will ensure that the algorithm doesn’t predict False for every row, and instead is penalized equally for making errors in predicting either class. ### Making predictions