I'm trying to use recursive feature elimination with gradient boosting and grid 
search as shown below


    gbr = GradientBoostingClassifier()
    parameters = {'learning_rate': [0.1, 0.01, 0.001],
                  'max_depth': [1, 4, 6],
                  'min_samples_leaf': [3, 5, 9, 17],
                  'max_features': [1.0, 0.3, 0.1]}
    clf = grid_search.GridSearchCV(estimator=gbr, param_grid=parameters, 
n_jobs=16)
    rfecv = RFECV(estimator=clf, step=1, cv=10, scoring='accuracy')
    rfecv.fit(x_train, y_train)

    # prediction
    y_predicted = rfecv.estimator_.predict(x_test)

However, I'm getting this error and I don't know how to fix it:

Traceback (most recent call last):
  File "./gbr_rfe.py", line 92, in <module>
    rfecv.fit(x_train, y_train)
  File 
"/usr/local/lib/python2.7/dist-packages/sklearn/feature_selection/rfe.py", line 
376, in fit
    ranking_ = rfe.fit(X_train, y_train).ranking_
  File 
"/usr/local/lib/python2.7/dist-packages/sklearn/feature_selection/rfe.py", line 
163, in fit
    if estimator.coef_.ndim > 1:
AttributeError: 'GridSearchCV' object has no attribute 'coef_'


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to