Continuous Classification: Linear Regression Explained

Use linear regression to predict continuous numeric values by fitting a line to data.

Understand the fundamentals of linear regression and how it's applied for continuous data classification. Gain clarity on differentiating between discrete and continuous classification scenarios.

Key Insights

  • Linear regression is a method used for continuous classification scenarios, where data can take on numerous possible numeric values, such as prices or weights, rather than discrete categories like animal types or car cylinder counts.
  • A linear regression model works by plotting a line or multiple slopes (in polynomial regression cases) to find an equation that best predicts numeric outcomes based on given data points.
  • Creating a linear regression model involves minimal coding effort using libraries such as scikit-learn, yet understanding the underlying concepts requires thorough learning and comprehension.

Note: These materials offer prospective students a preview of how our classes are structured. Students enrolled in this course will receive access to the full set of materials, including video lectures, project-based assignments, and instructor feedback.

We're going to use a linear regression model, and I want to introduce exactly why we're doing that. We are classifying the data, giving a label or a value to some data. But there are two different kinds of classification, discrete and continuous classes.

Now, discrete is where there's a small number of possible classes. If you're like, is this dog or a cat? Is this a mammal, reptile, fish, bird, or amphibian? Should this car have four, six, or eight cylinders? Was this car sold or unsold? Only a couple of possible options. On the other hand, continuous classification means there's a lot of possible answers, and that's what we're looking at here.

Things like prices, or distances, or weights. These are numeric values that could be anything. It could cost $39,000.

It could cost $39,000 in one. It could cost $39,000 in two. And then we could dive into cents, right? It gets as granular as you want, and there aren't a finite number of numbers.

So, unlike, you know, hey, is this a dog? Is this a cat? We are asking it to predict any possible value. So that makes it a continuous classification, not a discrete. And that's what linear regression is for.

Data Analytics Certificate: Live & Hands-on, In NYC or Online, 0% Financing, 1-on-1 Mentoring, Free Retake, Job Prep. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Linear regression, again, it's going to plot a line, just like we did with attendance and concessions, and try to make predictions based on that. Okay, and we're going to eventually find this, or possibly more slopes, as we did with the curvy line, right, with the polynomial regression, right? It's going to find an equation that best predicts this value. That's what a linear regression is.

It's a line, and that's why we're doing a linear regression. Now, a funny thing with linear regressions is it's really pretty easy to create and then train the model. There's not much code involved.

There's a lot of work. There's a lot of concepts to understand, but it's not a lot of actual code. So, let's start with instantiating a linear regression model, meaning create it.

And the way we do that is we just say model equals linear regression, call to the function, and that's straight from scikit-learn. If we run that, great, we have a model. Now, we haven't trained it on our data next.

That'll come next.

Colin Jaffe

Colin Jaffe is a programmer, writer, and teacher with a passion for creative code, customizable computing environments, and simple puns. He loves teaching code, from the fundamentals of algorithmic thinking to the business logic and user flow of application building—he particularly enjoys teaching JavaScript, Python, API design, and front-end frameworks.

Colin has taught code to a diverse group of students since learning to code himself, including young men of color at All-Star Code, elementary school kids at The Coding Space, and marginalized groups at Pursuit. He also works as an instructor for Noble Desktop, where he teaches classes in the Full-Stack Web Development Certificate and the Data Science & AI Certificate.

Colin lives in Brooklyn with his wife, two kids, and many intricate board games.

More articles by Colin Jaffe

How to Learn Machine Learning

Master machine learning with hands-on training. Use Python to make, modify, and test your own machine learning models.

Yelp Facebook LinkedIn YouTube Twitter Instagram