Comments on: Multivariate Polynomial Regression Python (Full Code) https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/ All Machines Learn Thu, 22 Feb 2024 09:47:33 +0000 hourly 1 https://wordpress.org/?v=6.4.5 By: Ody https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/#comment-252 Sat, 08 Apr 2023 19:54:59 +0000 https://enjoymachinelearning.com/?p=849#comment-252 Hi Dylan,
Thanks so much for this code, I used it and it worked for multivariate polynomial regression. However, if I want to visualise it to see the polynomial fit, I get the the error that my X (2 variables) and y (1 variable) are not of same dimension. How can I view my polynomial fit using scatter or line plot.
Thanks

]]>
By: Dylan https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/#comment-84 Fri, 20 Jan 2023 22:08:02 +0000 https://enjoymachinelearning.com/?p=849#comment-84 In reply to Renald.

Hello! what do you mean by the output?

You’ll need to use it to predict something to get an output for a model.

Dylan

]]>
By: Renald https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/#comment-83 Fri, 20 Jan 2023 14:07:01 +0000 https://enjoymachinelearning.com/?p=849#comment-83 Dear Dylan,

Thank you for great explanation. I need to ask 1 thing.
I want to check the regression output after fitting the model. How to do that?

Thanks

]]>
By: Dylan https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/#comment-52 Thu, 01 Dec 2022 19:34:48 +0000 https://enjoymachinelearning.com/?p=849#comment-52 In reply to ChienChi.

Hi ChienChi,

poly_model is defined in the for loop!

A normal “fit” method won’t have any output, as it’s not transforming (as seen in the for loop).

a fit_transform is a little different than a fit method.

Dylan

]]>
By: ChienChi https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/#comment-51 Thu, 01 Dec 2022 03:22:23 +0000 https://enjoymachinelearning.com/?p=849#comment-51 Dear Dylan Kaplan,

The code is useful and thanks for sharing it.
I put the sample code below and need your help to
confirm one question:

At line 10, the parameter values passed to mean_squared_error()
are “y_value” and “y_pred”.
“y_value” is the result fetched from the Excel file.
“y_pred” is the result returned by line 8.

But at line 4, “poly_model.fit(poly_x_values, y_values)” is executed.
What does this line take effect?
This line doesn’t generate any result.
What is the relation between line 4 and line 10?

Thanks very much.

======================================================

1 poly_model = PolynomialFeatures(degree=degree)
2
3 poly_x_values = poly_model.fit_transform(x_values)
4 poly_model.fit(poly_x_values, y_values)
5
6 regression_model = LinearRegression()
7 regression_model.fit(poly_x_values, y_values)
8 y_pred = regression_model.predict(poly_x_values)
9
10 plt_mean_squared_error.append(mean_squared_error(y_values, y_pred, squared=False))

Sincerely
ChienChi

]]>
By: Dylan https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/#comment-42 Sat, 08 Oct 2022 00:37:18 +0000 https://enjoymachinelearning.com/?p=849#comment-42 In reply to Dominique.

Hey Dominique,

I’m glad that the code worked!

Sometimes many think they’re after this post but are really after something like a regression spine.

Maybe this article will help (it’s from someone else’s blog)

]]>
By: Dominique https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/#comment-41 Thu, 06 Oct 2022 14:09:14 +0000 https://enjoymachinelearning.com/?p=849#comment-41 Hi there.

I have a data set that contains 10 independent variables and 1 dependent variable. Using the code in this article, it computed that my polynomial should be of degree 4.

When I fit my ‘linear’ regression model, is it actually forming polynomial relationships of degree 4, or is it just performing normal linear regression? The accuracy is not very good if I set my degree to 4.

Is this actually multivariate polynomial regression? If not, do you know how I can do this?

Thank you!

]]>
By: Craig https://enjoymachinelearning.com/blog/multivariate-polynomial-regression-python/#comment-39 Wed, 28 Sep 2022 17:49:55 +0000 https://enjoymachinelearning.com/?p=849#comment-39 This was very helpful thank you! Exactly what I was looking for!

]]>