Answered step by step
Verified Expert Solution
Question
1 Approved Answer
raise ValueError(x and y must be the same size) ValueError: x and y must be the same size That is the error I get when
raise ValueError("x and y must be the same size")
ValueError: x and y must be the same size
That is the error I get when I try to plot it. Can you pleaseshow me the correct way to implement this and plot it on a scatterplot?
X = data.iloc [:,:-1].values Y = data.iloc [:,-1].values labelencoder_X1 = LabelEncoder () X[:,1] = labelencoder_X1.fit_transform (X[:,1]) labelencoder_X4 = LabelEncoder () X[:,4] = labelencoder_X4.fit_transform(X[:,4]) labelencoder_X5 = LabelEncoder () X[:,5] = labelencoder_X5.fit_transform (X[:,5]) oneHotEncoder = OneHotEncoder (categorical_features X = oneHotEncoder.fit_transform (X).toarray() X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.2) poly_reg X_poly = poly_reg.fit_transform(X) LinearRegression() pol_reg pol_reg.fit(X_poly, Y) = PolynomialFeatures (degree=2) = [1]) plt.scatter (X, Y, color='red') plt.plot(X, pol_reg.predict (poly_reg.fit_transform(X)), color='blue') plt.show()
Step by Step Solution
★★★★★
3.47 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
To plot the given data on a scatterplot you need to make sure that the X and Y data are the same siz...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started