Parameters in GridSearchCV in scikit-learn I am trying to build a model in scikit-learn. I used RandomForestClassifier as my method for classification. In order to improve the score and efficiency of my model, I thought about using GridSearchCV.

Here is the code:

import pandas as pd
import numpy as np
from sklearn.cross_validation import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score,roc_auc_score
from sklearn.grid_search import GridSearchCV

..................................... ## code for cleaning data

X_train, X_test, y_train, y_test = train_test_split(train,output, test_size=0.2, random_state =7)


# In[18]:

clf = RandomForestClassifier(n_estimators =100)
param_grid = {'max_depth' : [None, 10,20],
              'max_features' : ['auto',None],
              'n_estimators' :[100,200,300],
              'random_state': 7}
## This line is throwing the error shown below
validator = GridSearchCV(clf, param_grid= param_grid) 
vaildiator.fit(X_train,y_train)


The error being thrown by my code is:

ValueError     Traceback (most recent call 

last)
&lt;ipython-input-22-3711af477b0c&gt; in &lt;module&gt;()
      3          "max_depth" : [5,10,50],
      4          "random_state" : 7}
----&gt; 5 grid = GridSearchCV(clf, param_grid=param, n_jobs=1)
      6 grid.fit(X_train,y_train)

C:\Anaconda3\envs\DeepLearning\lib\site-packages\sklearn\grid_search.py in __init__(self, estimator, param_grid, scoring, fit_params, n_jobs, iid, refit, cv, verbose, pre_dispatch, error_score)
    785             refit, cv, verbose, pre_dispatch, error_score)
    786         self.param_grid = param_grid
--&gt; 787         _check_param_grid(param_grid)
    788 
    789     def fit(self, X, y=None):

C:\Anaconda3\envs\DeepLearning\lib\site-packages\sklearn\grid_search.py in _check_param_grid(param_grid)
    326             check = [isinstance(v, k) for k in (list, tuple, np.ndarray)]
    327             if True not in check:
--&gt; 328                 raise ValueError("Parameter values should be a list.")
    329 
    330             if len(v) == 0:

ValueError: Parameter values should be a list.


Please help me in figuring out the above error and why is this happening?
Well the error message is quite clear. GridSearchCV accepts only lists. Therefore 'random_state': [7]} will solve the issue.

However when you have only one value with this parameter, it makes more sense put it directly into the classifier as you did with n_estimators.