title: ValueError: x and y must have same first dimension, but have shapes (10, 1) and (90,)
body: <p>I'm learning ML from Udemy. From one of the lectures of Polynomial Regression, the following code is as follows:</p>
  
  <pre><code># importing libraries
  import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  
  # importing dataset
  dataset = pd.read_csv("Position_Salaries.csv")
  x = dataset.iloc[:, 1:2].values
  y = dataset.iloc[:, 2].values
  print(x.shape)
  print(y.shape)
  # fitting LR to the dataset
  from sklearn.linear_model import LinearRegression
  linreg = LinearRegression()
  linreg.fit(x, y)
  
  # fitting PR to the dataset
  from sklearn.preprocessing import PolynomialFeatures
  polreg = PolynomialFeatures(degree=2)
  x_poly = polreg.fit_transform(x)
  linreg2 = LinearRegression()
  linreg2.fit(x_poly, y)
  
  
  # visualising the polynomial regression results
  x_grid = np.arange(min(x), max(x), 0.1)
  x_grid = x_grid.reshape((len(x_grid), 1))
  plt.scatter(x, y, color = "red")
  plt.plot(x, linreg2.predict(polreg.fit_transform(x_grid)), color = "blue" )
  plt.title("Truth or Bluff PR")
  plt.xlabel("Position")
  plt.ylabel("Salary")
  plt.show()
  </code></pre>
  
  <p>I got error as follows:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/ashutosh/Machine Learning A-Z Template Folder/Part 2 - Regression/Section 6 - Polynomial Regression/P14-Polynomial-Regression/Polynomial_Regression/plr.py", line 29, in &lt;module&gt;
      plt.plot(x, linreg2.predict(polreg.fit_transform(x_grid)), color = "blue" )
    File "/usr/local/lib/python3.7/dist-packages/matplotlib/pyplot.py", line 2795, in plot
      is not None else {}), **kwargs)
    File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_axes.py", line 1666, in plot
      lines = [*self._get_lines(*args, data=data, **kwargs)]
    File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py", line 225, in __call__
      yield from self._plot_args(this, kwargs)
    File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py", line 391, in _plot_args
      x, y = self._xy_from_xy(x, y)
    File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py", line 270, in _xy_from_xy
      "have shapes {} and {}".format(x.shape, y.shape))
  ValueError: x and y must have same first dimension, but have shapes (10, 1) and (90,)
  </code></pre>
  
  <p>the data set can be downloaded from here:
  <a href="https://sds-platform-private.s3-us-east-2.amazonaws.com/uploads/P14-Polynomial-Regression.zip" rel="nofollow noreferrer">https://sds-platform-private.s3-us-east-2.amazonaws.com/uploads/P14-Polynomial-Regression.zip</a></p>
  
  <p>What can I do?</p>