Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Evaluate the Model | Polynomial Regression
Linear Regression with Python
course content

Conteúdo do Curso

Linear Regression with Python

Evaluate the Model

In this challenge, you are given the good old housing dataset, but this time only with the 'age' feature.

Let's build a scatterplot of this data.

Fitting a straight line to this data may not be a great choice. The price gets higher for either brand-new or really old houses. Fitting a parabola looks like a better choice. And that's what you will do in this challenge.

But before you start, recall the PolynomialFeatures class.

The fit_transform(X) method requires X to be a 2-D array (or a DataFrame).
Using X = df[['column_name']] will get your X suited for fit_transform().
And if you have a 1-D array, use .reshape(-1, 1) to make a 2-D array with the same contents.

The task is to build a Polynomial Regression of degree 2 using PolynomialFeatures and OLS.

Tarefa

  1. Assign the X variable to a DataFrame containing column 'age'.
  2. Create an X_tilde matrix using the PolynomialFeatures class.
  3. Build and train a Polynomial Regression model.
  4. Print the model's parameters.
  5. Reshape X_new to be a 2-D array.
  6. Preprocess X_new the same way as X.

Tarefa

  1. Assign the X variable to a DataFrame containing column 'age'.
  2. Create an X_tilde matrix using the PolynomialFeatures class.
  3. Build and train a Polynomial Regression model.
  4. Print the model's parameters.
  5. Reshape X_new to be a 2-D array.
  6. Preprocess X_new the same way as X.

Tudo estava claro?

Seção 3. Capítulo 5
toggle bottom row

Evaluate the Model

In this challenge, you are given the good old housing dataset, but this time only with the 'age' feature.

Let's build a scatterplot of this data.

Fitting a straight line to this data may not be a great choice. The price gets higher for either brand-new or really old houses. Fitting a parabola looks like a better choice. And that's what you will do in this challenge.

But before you start, recall the PolynomialFeatures class.

The fit_transform(X) method requires X to be a 2-D array (or a DataFrame).
Using X = df[['column_name']] will get your X suited for fit_transform().
And if you have a 1-D array, use .reshape(-1, 1) to make a 2-D array with the same contents.

The task is to build a Polynomial Regression of degree 2 using PolynomialFeatures and OLS.

Tarefa

  1. Assign the X variable to a DataFrame containing column 'age'.
  2. Create an X_tilde matrix using the PolynomialFeatures class.
  3. Build and train a Polynomial Regression model.
  4. Print the model's parameters.
  5. Reshape X_new to be a 2-D array.
  6. Preprocess X_new the same way as X.

Tarefa

  1. Assign the X variable to a DataFrame containing column 'age'.
  2. Create an X_tilde matrix using the PolynomialFeatures class.
  3. Build and train a Polynomial Regression model.
  4. Print the model's parameters.
  5. Reshape X_new to be a 2-D array.
  6. Preprocess X_new the same way as X.

Tudo estava claro?

Seção 3. Capítulo 5
toggle bottom row

Evaluate the Model

In this challenge, you are given the good old housing dataset, but this time only with the 'age' feature.

Let's build a scatterplot of this data.

Fitting a straight line to this data may not be a great choice. The price gets higher for either brand-new or really old houses. Fitting a parabola looks like a better choice. And that's what you will do in this challenge.

But before you start, recall the PolynomialFeatures class.

The fit_transform(X) method requires X to be a 2-D array (or a DataFrame).
Using X = df[['column_name']] will get your X suited for fit_transform().
And if you have a 1-D array, use .reshape(-1, 1) to make a 2-D array with the same contents.

The task is to build a Polynomial Regression of degree 2 using PolynomialFeatures and OLS.

Tarefa

  1. Assign the X variable to a DataFrame containing column 'age'.
  2. Create an X_tilde matrix using the PolynomialFeatures class.
  3. Build and train a Polynomial Regression model.
  4. Print the model's parameters.
  5. Reshape X_new to be a 2-D array.
  6. Preprocess X_new the same way as X.

Tarefa

  1. Assign the X variable to a DataFrame containing column 'age'.
  2. Create an X_tilde matrix using the PolynomialFeatures class.
  3. Build and train a Polynomial Regression model.
  4. Print the model's parameters.
  5. Reshape X_new to be a 2-D array.
  6. Preprocess X_new the same way as X.

Tudo estava claro?

In this challenge, you are given the good old housing dataset, but this time only with the 'age' feature.

Let's build a scatterplot of this data.

Fitting a straight line to this data may not be a great choice. The price gets higher for either brand-new or really old houses. Fitting a parabola looks like a better choice. And that's what you will do in this challenge.

But before you start, recall the PolynomialFeatures class.

The fit_transform(X) method requires X to be a 2-D array (or a DataFrame).
Using X = df[['column_name']] will get your X suited for fit_transform().
And if you have a 1-D array, use .reshape(-1, 1) to make a 2-D array with the same contents.

The task is to build a Polynomial Regression of degree 2 using PolynomialFeatures and OLS.

Tarefa

  1. Assign the X variable to a DataFrame containing column 'age'.
  2. Create an X_tilde matrix using the PolynomialFeatures class.
  3. Build and train a Polynomial Regression model.
  4. Print the model's parameters.
  5. Reshape X_new to be a 2-D array.
  6. Preprocess X_new the same way as X.

Seção 3. Capítulo 5
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt