1,793 views
1 1 vote
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
0% Accept Rate Accepted 0 answers out of 1 questions

1 Answer

0 0 votes

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())

Related questions

1 1 vote
1 answers 1 answer
4.9k
4.9k views
tofighi asked Feb 18, 2020
4,920 views
Assuming we have a linear regression equation and some data points (sample), how can we calculate residual error for each data point, and total cost based on the metrics ...
1 1 vote
0 0 answers
967
967 views
kmr1994 asked Apr 29, 2019
967 views
Here is LSTM predict model and i want to convert Linear Regression.... model.fit(x_train, y_train, epochs=10, batch_size=16) trainPredict = model.predict(x_train) testPre...
0 0 votes
1 answers 1 answer
1.8k
1.8k views
tofighi asked Apr 11, 2019
1,815 views
For the following dataset, calculate the regression equation $\hat{y} = ax+b$datasetxy1423501075161002615036200
1 1 vote
0 0 answers
7.8k
7.8k views
TomGoncalves asked Mar 24, 2019
7,825 views
Hi everyone.I'm currently working on my final project for a Data Science degree and after a month of literature review, exploratory analysis and model testing, I'm not su...
0 0 votes
1 1 answer
1.3k
1.3k views