title: how to visualize dependence of model performance & alpha with matplotlib?
body: <p>I fit a Ridge Regression with GridSearchCV but am having trouble using <code>matplotlib</code> to show the model performance versus regularizer(alpha) </p>
  
  <p>Could anyone please help?</p>
  
  <p>My code:</p>
  
  <pre><code>from sklearn.datasets import fetch_california_housing
  cal=fetch_california_housing()
  X = cal.data
  y = cal.target 
  
  from sklearn.model_selection import train_test_split
  X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
  
  param_grid = {'alpha': np.logspace(-3, 3, 13)}
  print(param_grid)
  grid = GridSearchCV(Ridge(normalize=True), param_grid, cv=10)
  grid.fit(X_train, y_train)
  print("Best cross-validation score: {:.2f}".format(grid.best_score_))
  print("Best parameters: ", grid.best_params_)
  
  import matplotlib.pyplot as plt
  alphas = np.logspace(-3, 3, 13)
  plt.semilogx(alphas, grid.fit(X_train, y_train), label='Train')
  plt.semilogx(alphas, grid.fit(X_test, y_test), label='Test')
  
  plt.legend(loc='lower left')
  plt.ylim([0, 1.0])
  plt.xlabel('alpha')
  plt.ylabel('performance')
  
  # the error code I got was "ValueError: x and y must have same first dimension"
  </code></pre>
  
  <p>Basically, I want to see the something like the following:</p>
  
  <p><a href="https://i.stack.imgur.com/30n7R.png" rel="noreferrer"><img src="https://i.stack.imgur.com/30n7R.png" alt="change of alpha"></a></p>