First time here? Checkout the FAQ!
x
+1 vote
768 views
asked in Programming by (130 points)  
def cross_val_score(estimator,X,y,scoring,cv):
    scores=cross_val_score
    scores_rmse=np.sqrt(-scores)
    print('Scores: ',scores_rmse)
    print("Mean:", scores_rmse.mean())
    print("Standard deviation:", scores_rmse.std())

This is the def I created and passed to below

cross_val_score(SGDRegressor,X_train,y_train,scoring='neg_mean_squared_error',cv=5) 

I am getting below error...

ValueError                                Traceback (most recent call last)
<ipython-input-181-275d240df219> in <module>()
----> 1 plot_validation_curve(lin_reg_SGD,X_train,y_train,'alpha', [0.001,0.01],scoring='neg_mean_squared_error',cv=5)
3 frames

/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
    203     if len(uniques) > 1:
    204         raise ValueError("Found input variables with inconsistent numbers of"
--> 205                          " samples: %r" % [int(l) for l in lengths])
    206 
    207 

ValueError: Found input variables with inconsistent numbers of samples: [13903, 13903, 22]
SEARCH STACK OVERFLOW
  
commented by (115k points)  
Could you please share your code with more details? I did not get it

1 Answer

0 votes
answered by (115k points)  

It seems you have a problem in defining the function. I do not understand why did you create the following function?! Why did not you use this library?

def cross_val_score(estimator,X,y,scoring,cv):
    scores=cross_val_score
    scores_rmse=np.sqrt(-scores)
    print('Scores: ',scores_rmse)
    print("Mean:", scores_rmse.mean())
    print("Standard deviation:", scores_rmse.std())
...