title: ValueError: Number of features of the model must match the input. Model n_features is 11 and input n_features is 2
body: <p>While running the below code in jupyter notebook, I am getting the value error.</p>
  <blockquote>
  <p>ValueError: Number of features of the model must match the input. Model n_features is 11 and input n_features is 2</p>
  </blockquote>
  <p>How to resolve this issue?</p>
  <pre><code># Visualising the Training set results
  from matplotlib.colors import ListedColormap
  X_set, y_set = X_train, y_train
  X1, X2 = np.meshgrid(np.arange(start = X_set[:, 0].min() - 1, stop = X_set[:, 0].max() + 1, step = 0.01),
                       np.arange(start = X_set[:, 1].min() - 1, stop = X_set[:, 1].max() + 1, step = 0.01))
  plt.contourf(X1, X2, classifier.predict(np.array([X1.ravel(), X2.ravel()]).T).reshape(X1.shape),
               alpha = 0.75, cmap = ListedColormap(('red', 'green')))
  </code></pre>
  <p>I am getting the below error:</p>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-42-bc13e66e79fe&gt; in &lt;module&gt;
        4 X1, X2 = np.meshgrid(np.arange(start = X_set[:, 0].min() - 1, stop = X_set[:, 0].max() + 1, step = 0.01),
        5                      np.arange(start = X_set[:, 1].min() - 1, stop = X_set[:, 1].max() + 1, step = 0.01))
  ----&gt; 6 plt.contourf(X1, X2, classifier.predict(np.array([X1.ravel(), X2.ravel()]).T).reshape(X1.shape),
        7              alpha = 0.75, cmap = ListedColormap(('red', 'green')))
        8 plt.xlim(X1.min(), X1.max())
  
  ~\anaconda3\lib\site-packages\sklearn\ensemble\_forest.py in predict(self, X)
      627             The predicted classes.
      628         &quot;&quot;&quot;
  --&gt; 629         proba = self.predict_proba(X)
      630 
      631         if self.n_outputs_ == 1:
  
  ~\anaconda3\lib\site-packages\sklearn\ensemble\_forest.py in predict_proba(self, X)
      671         check_is_fitted(self)
      672         # Check data
  --&gt; 673         X = self._validate_X_predict(X)
      674 
      675         # Assign chunk of trees to jobs
  
  ~\anaconda3\lib\site-packages\sklearn\ensemble\_forest.py in _validate_X_predict(self, X)
      419         check_is_fitted(self)
      420 
  --&gt; 421         return self.estimators_[0]._validate_X_predict(X, check_input=True)
      422 
      423     @property
  
  ~\anaconda3\lib\site-packages\sklearn\tree\_classes.py in _validate_X_predict(self, X, check_input)
      394         n_features = X.shape[1]
      395         if self.n_features_ != n_features:
  --&gt; 396             raise ValueError(&quot;Number of features of the model must &quot;
      397                              &quot;match the input. Model n_features is %s and &quot;
      398                              &quot;input n_features is %s &quot;
  
  ValueError: Number of features of the model must match the input. Model n_features is 11 and input n_features is 2 
  </code></pre>
  <p>Full Model Code: <a href="https://github.com/anandsinha07/Placement-prediction-system-using-ML-algos/blob/master/PREDICTION-Random%20Forest%20Classification/random_forest_classification.py" rel="nofollow noreferrer">https://github.com/anandsinha07/Placement-prediction-system-using-ML-algos/blob/master/PREDICTION-Random%20Forest%20Classification/random_forest_classification.py</a></p>