Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Prediction | Building and Training Model
Explore the Linear Regression Using Python
course content

Contenido del Curso

Explore the Linear Regression Using Python

Explore the Linear Regression Using Python

1. What is the Linear Regression?
2. Correlation
3. Building and Training Model
4. Metrics to Evaluate the Model
5. Multivariate Linear Regression

Prediction

Once we've trained our module, it's time to think about test data evaluation and future predictions. We can make predictions using the method predict().

Let's look at an example. Prediction for flavanoids when the number of total phenols is 1:

12
new_total_phenols = np.array([1]).reshape(-1,1) print(model.predict(new_total_phenols))
copy

Method .reshape() gives a new shape to an array without changing its data. Input must be a 2-dimension (DataFrame or 2-dimension array will work here).

This value is the same as if we had substituted the line b + kx, where b is the estimated intersection with the model, and k is the slope. Please note that we multiply by 1 since the number of total phenols is 1 (x = 1).

1
prediction = model.intercept_ + model.coef_*1
copy

We can also put our testing data to get predictions for all amounts of flavanoids:

1
y_test_predicted = model.predict(X_test)
copy

Tarea

Predict with the previous split-train data the amount of flavanoids if the total phenols is 2.

  1. [Line #6] Import the numpy library.
  2. [Line #26] Initialize the linear regression model.
  3. [Line #30] Assign np.array() and number of total phenols as the parameter (2) to the variable new_total_phenols (don’t forget to use the function .reshape(-1,1)).
  4. [Line #31] Predict amount of flavanoids
  5. [Line #32] Print the predicted amount of flavanoids.

Tarea

Predict with the previous split-train data the amount of flavanoids if the total phenols is 2.

  1. [Line #6] Import the numpy library.
  2. [Line #26] Initialize the linear regression model.
  3. [Line #30] Assign np.array() and number of total phenols as the parameter (2) to the variable new_total_phenols (don’t forget to use the function .reshape(-1,1)).
  4. [Line #31] Predict amount of flavanoids
  5. [Line #32] Print the predicted amount of flavanoids.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 3. Capítulo 3
toggle bottom row

Prediction

Once we've trained our module, it's time to think about test data evaluation and future predictions. We can make predictions using the method predict().

Let's look at an example. Prediction for flavanoids when the number of total phenols is 1:

12
new_total_phenols = np.array([1]).reshape(-1,1) print(model.predict(new_total_phenols))
copy

Method .reshape() gives a new shape to an array without changing its data. Input must be a 2-dimension (DataFrame or 2-dimension array will work here).

This value is the same as if we had substituted the line b + kx, where b is the estimated intersection with the model, and k is the slope. Please note that we multiply by 1 since the number of total phenols is 1 (x = 1).

1
prediction = model.intercept_ + model.coef_*1
copy

We can also put our testing data to get predictions for all amounts of flavanoids:

1
y_test_predicted = model.predict(X_test)
copy

Tarea

Predict with the previous split-train data the amount of flavanoids if the total phenols is 2.

  1. [Line #6] Import the numpy library.
  2. [Line #26] Initialize the linear regression model.
  3. [Line #30] Assign np.array() and number of total phenols as the parameter (2) to the variable new_total_phenols (don’t forget to use the function .reshape(-1,1)).
  4. [Line #31] Predict amount of flavanoids
  5. [Line #32] Print the predicted amount of flavanoids.

Tarea

Predict with the previous split-train data the amount of flavanoids if the total phenols is 2.

  1. [Line #6] Import the numpy library.
  2. [Line #26] Initialize the linear regression model.
  3. [Line #30] Assign np.array() and number of total phenols as the parameter (2) to the variable new_total_phenols (don’t forget to use the function .reshape(-1,1)).
  4. [Line #31] Predict amount of flavanoids
  5. [Line #32] Print the predicted amount of flavanoids.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 3. Capítulo 3
toggle bottom row

Prediction

Once we've trained our module, it's time to think about test data evaluation and future predictions. We can make predictions using the method predict().

Let's look at an example. Prediction for flavanoids when the number of total phenols is 1:

12
new_total_phenols = np.array([1]).reshape(-1,1) print(model.predict(new_total_phenols))
copy

Method .reshape() gives a new shape to an array without changing its data. Input must be a 2-dimension (DataFrame or 2-dimension array will work here).

This value is the same as if we had substituted the line b + kx, where b is the estimated intersection with the model, and k is the slope. Please note that we multiply by 1 since the number of total phenols is 1 (x = 1).

1
prediction = model.intercept_ + model.coef_*1
copy

We can also put our testing data to get predictions for all amounts of flavanoids:

1
y_test_predicted = model.predict(X_test)
copy

Tarea

Predict with the previous split-train data the amount of flavanoids if the total phenols is 2.

  1. [Line #6] Import the numpy library.
  2. [Line #26] Initialize the linear regression model.
  3. [Line #30] Assign np.array() and number of total phenols as the parameter (2) to the variable new_total_phenols (don’t forget to use the function .reshape(-1,1)).
  4. [Line #31] Predict amount of flavanoids
  5. [Line #32] Print the predicted amount of flavanoids.

Tarea

Predict with the previous split-train data the amount of flavanoids if the total phenols is 2.

  1. [Line #6] Import the numpy library.
  2. [Line #26] Initialize the linear regression model.
  3. [Line #30] Assign np.array() and number of total phenols as the parameter (2) to the variable new_total_phenols (don’t forget to use the function .reshape(-1,1)).
  4. [Line #31] Predict amount of flavanoids
  5. [Line #32] Print the predicted amount of flavanoids.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Once we've trained our module, it's time to think about test data evaluation and future predictions. We can make predictions using the method predict().

Let's look at an example. Prediction for flavanoids when the number of total phenols is 1:

12
new_total_phenols = np.array([1]).reshape(-1,1) print(model.predict(new_total_phenols))
copy

Method .reshape() gives a new shape to an array without changing its data. Input must be a 2-dimension (DataFrame or 2-dimension array will work here).

This value is the same as if we had substituted the line b + kx, where b is the estimated intersection with the model, and k is the slope. Please note that we multiply by 1 since the number of total phenols is 1 (x = 1).

1
prediction = model.intercept_ + model.coef_*1
copy

We can also put our testing data to get predictions for all amounts of flavanoids:

1
y_test_predicted = model.predict(X_test)
copy

Tarea

Predict with the previous split-train data the amount of flavanoids if the total phenols is 2.

  1. [Line #6] Import the numpy library.
  2. [Line #26] Initialize the linear regression model.
  3. [Line #30] Assign np.array() and number of total phenols as the parameter (2) to the variable new_total_phenols (don’t forget to use the function .reshape(-1,1)).
  4. [Line #31] Predict amount of flavanoids
  5. [Line #32] Print the predicted amount of flavanoids.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 3. Capítulo 3
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt