Introduction to Regression with statsmodels in Python

Start Free Preview

Buying via our links supports this free directory · Affiliate disclosure.
Course facts
  • Payment: Free Preview (Paid Upgrade)
  • Learning style: Self-paced, start anytime
  • Format: Text & Interactive
  • Video access: Streaming Only
  • Before you start: Introduction to Data Visualization with Seaborn; Introduction to Statistics in Python
DataCamp details
  • Chapters: 4
Created byDataCamp
Available onDataCamp

Course Details
Learning Style

Start Anytime

Level

Intermediate

Study Mode

100% Online

Duration

Short (< 10 Hours)

Languages
Audio Language

English

Outcomes
Certificate

Certificate of Completion

Price & Terms
Pricing Model

Free Preview (Paid Upgrade)

Technical
Content Medium

Text & Interactive

Video Access

Streaming Only

Specification
Access

Subscription

SKU: introduction-regression-statsmodels-python Category: Tag: Brand:

Fit linear and logistic regression models in Python with statsmodels, make predictions, and check model fit with diagnostic plots and confusion matrices.

At a glance
Duration4 hrs
LevelIntermediate
CertificateCertificate of Completion
LanguageEnglish
AccessSubscription
Add your review
Add to wishlistAdded to wishlistRemoved from wishlist 0
Add to compare
Shared lessons. This course shares its lessons with Introduction to Regression in R; the exercises use Python and statsmodels instead of R.

Regression models describe how a response variable changes with an explanatory one, and they let you predict values you have not observed. You fit straight-line models in Python’s statsmodels with numeric and categorical explanatory variables, turn them into predictions, and test whether the fit can be trusted using residuals, leverage and influence. A second kind of model handles yes-or-no outcomes, such as a bank customer closing an account, and expresses its predictions as probabilities and odds.

What You Will Achieve

  • Fit a linear regression in statsmodels and describe how the response changes with its explanatory variable
  • Predict new values from a fitted model and judge when extrapolation makes a prediction unreliable
  • Diagnose problems with model fit from diagnostic plots and flag the observations that drive the model
  • Predict a yes-or-no outcome as a probability and report how often a logistic model classifies correctly


Program Overview

Simple Linear Regression and Predictions

Fits straight-line models with ols() and uses them to predict Taiwanese house prices and Facebook advert clicks.

  • Response and explanatory variables, intercept and slope
  • Categorical explanatory variables and means by category
  • Predictions, their limits and model objects
  • Regression to the mean and variable transformation

Assessing Linear Model Fit

Measures how well a linear model fits the data and finds the observations with the most pull on it.

  • Coefficient of determination and residual standard error
  • Residuals vs. fitted values, Q-Q and scale-location plots
  • Outliers, leverage and influence

Simple Logistic Regression Modeling

Predicts whether a bank customer closes an account and measures how well the logistic model performs.

  • Fitting logistic models with logit()
  • Probabilities, odds, log odds and most likely outcome
  • Confusion matrix and mosaic plot
  • Accuracy, sensitivity and specificity

Certificate Awarded (Paid)


Job Outlook

Regression with statsmodels is used wherever analysts explain or predict a numeric value or a yes-or-no outcome from data, such as house prices, motor insurance claims, advert clicks and customers closing bank accounts.


Our take

Good for: Python users who want to fit, interpret and check simple linear and logistic regression models in statsmodels code.

Keep in mind: Each model has one explanatory variable, since the course keeps to simple linear and logistic regression rather than models with several predictors.

Bottom line: A code-first look at regression output in statsmodels that spends as much time checking fit as fitting.

Frequently Asked Questions

What does statsmodels do?

Statsmodels is a Python library for estimating statistical models and running statistical tests. In these lessons you fit linear models with its ols() function and logistic models with logit(), then pull coefficients and other elements out of the model objects.

Which real-world datasets appear in the exercises?

The exercises draw on motor insurance claims, house prices in Taiwan, fish sizes, Facebook advert clicks and consecutive portfolio returns, and the logistic regression chapter uses data on bank customers who close their accounts.

How does statsmodels differ from scikit-learn?

Both can fit regression models. Statsmodels is a statistical package aimed at understanding a model, while scikit-learn is a machine learning package aimed at prediction. The lessons here work in statsmodels, and the better choice depends on the task at hand.

User Reviews

0.0 out of 5
★★★★★
0
★★★★★
0
★★★★★
0
★★★★★
0
★★★★★
0

No reviews yet. Be the first to review this course.

There are no reviews yet.

Write your review

Reviews can only be posted by registered learners. Log in or create a free account, then you will return here to post.

×

    Report this page
    Introduction to Regression with statsmodels in Python
    Introduction to Regression with statsmodels in Python
    LiveTalent
    Logo
    Compare items
    • Total (0)
    Compare
    0