raise ValueError(x and y must be the same size) ValueError: x and y must be the same
Fantastic news! We've Found the answer you've been seeking!
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 I try to plot it. Can you pleaseshow me the correct way to implement this and plot it on a scatterplot?
Transcribed Image Text:
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() 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()
Expert Answer:
Answer rating: 100% (QA)
To plot the given data on a scatterplot you need to make sure that the X and Y data are the same siz... View the full answer
Related Book For
Fundamentals of Cost Accounting
ISBN: 978-0077398194
3rd Edition
Authors: William Lanen, Shannon Anderson, Michael Maher
Posted Date:
Students also viewed these programming questions
-
To plot y = sin(x), we must define vectors of x and y values and then use the plot command. This can be done as follows: x = 0:0.1:6.3; y = sin(x); plot(x, y) (a) Let us define a rotation matrix and...
-
I can get Mickey to download any data I need from the Web or our server to my PC, DeWitt Miwaye, an upper-level manager for Yumtime Foods (a Midwest food wholesaler), tells you. Getting data is no...
-
Plot the following lines: a. y = 4 + x b. y = 5 - 2x c. y = -4 + 3x d. y = -2x e. y = x f. y = .50 + 1.5x
-
CPA firm brings in a yoga instructor during the tax busy season to help relieve stress of the employees. Which is true about the CPA firm's ability to take a deduction for the yoga instructor's...
-
The Ethical Dimension At one point in their dispute, the Biglanes blocked off two parking lots that served the Saloon. Was this an unreasonable interference with the Saloons rights? Explain.
-
Using the supply-and-demand analysis of interest, explain how each of the following would affect interest rates in capital theory: a. An innovation that increased the marginal product of capital at...
-
Convert \(24 \%\) to fraction form and reduce completely.
-
Telly Savalas owns the Bonita Barber Shop. He employs four barbers and pays each a base rate of $1,000 per month. One of the barbers serves as the manager and receives an extra $500 per month. In...
-
undefined Assignment for ACC 420 FBC & ABC Question Lotus Ltd has identified the following overhead costs and cost drivers for next year Overhead Items Power Maintenance cost Ordering cost Set ups...
-
Martha Millon, financial manager for Fish & Chips Inc., has been asked to perform a lease-versus-buy analysis on a new computer system. The computer system has an after-tax cost of $975,000, and if...
-
Q:Question:A loan officer compares the interest rates for 48 -month fixed-rate auto loans and 48 -month variable-rate auto loans. Two independent, random samples of auto loan rates are selected. A...
-
2. Find Longest Ride Given the dataset of taxi rides completed in a pandas dataframe, process the dataframe as follows: Drop all the rows where the pickup time or dropoff time is missing. Find the...
-
Define what is non-verbal communication and give some examples? What are the components of a professional email ? Please be specific What is included in the written media?
-
What ratios can be used to determine whether the company has collection issues...please explain? How does secured borrowing differ transactionally from a sale of receivables? Please explain When a...
-
Could you elucidate the nuances of the term structure of interest rates and the various theories, such as the expectations theory, liquidity preference theory, and market segmentation theory, that...
-
Use the following link to access the assigned cases: https://hbsp.harvard.edu/import/1010405 Going with the Flow: Agile Development at Dell | Harvard Business Publishing Education Case Study...
-
There is a spinner with 13 equal areas, numbered 1 through 13. If the spinner is spun one time, what is the probability that the result is a multiple of 2 or a multiple of 5?
-
What are some of the features of the Unified Process (UP)?
-
For each of the following costs incurred in a manufacturing firm, indicate whether the costs are fixed (F) or variable (V) and whether they are period costs (P) or product costs (M) under full...
-
We have discussed two methods for process costing, weighted average and FIFO. Your colleague recommends last-in, first-out (LIFO) process costing to the controller as a new system. The controller is...
-
As a marketing manager for an airline, would you sell a seat to a passenger who walked up to the gate at the last minute at the variable (marginal) cost? Why or why not? Do the costs from the...
-
How will organizing your financial documents help you manage your money?
-
What steps would you take to create a home filing system?
-
What are the advantages of using a safe deposit box to store your personal financial documents?
Study smarter with the SolutionInn App