Search this site
Embedded Files
AIMD GPDS Courses
  • Home
  • Courses
  • Contact
AIMD GPDS Courses
  • Home
  • Courses
  • Contact
  • More
    • Home
    • Courses
    • Contact

日本語  ❯

Lesson 5    ❮    Lesson List    ❮    Top Page

5.1  Preprocessing with sklearn

❯  5.2  Linear Regression

5.3  Logistic Regression

5.4  Classification Methods

5.5  Clustering Methods

⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
EXPECTED COMPLETION TIME
❲▹❳  Video   7m 49s
☷  Interactive readings   5m

Using Linear Regression  for Prediction

Making the Model

Linear regression can be used to predict numerical attributes. The regression class in Scikit-learn is part of the linear_model module. 

We will scale the data first using scale and we will see how to fit our data into the model.

Showing the Regression Coefficients & Score

We can use the scoring method to report the R^2 measure (ranges from 0 to 1). The closer the number to 1, the better the model.

To see which attributes affect the estimation the most in the multiple regression model, you have to look at the coef_ attribute, which is an array containing the regression coefficients. The highest the absolute value, the more it affects the model. 

You can also see the intercept using intercept_

Finally, the zip function will generate an iterable of both attributes, and you can print it for reporting. 

Plotting the Regression Line

While we cannot plot more than two dimension, we can try to plot two variables to see what the regression line looks like by using regplot in seaborn library.

> The attributes age and indus don't influence the result as much because the absolute value of their beta coefficients is lower compared to the others.
©2023. All rights reserved.  Samy Baladram,
Graduate Program in Data Science - GSIS - Tohoku University
Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse