Question: 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

X = data.iloc [:,:-1].values Y = data.iloc [:,-1].values labelencoder_X1 = LabelEncoder ()

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

1 Expert Approved Answer
Step: 1 Unlock

To plot the given data on a scatterplot you need to make sure that the X and Y data are the same siz... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!