Reputation: 121
I need to fit a linear model to Wine Quality dataset. And then find MSE for each k-fold. Following is my code
regressor = LinearRegression()
regressor.fit(Features_train, Quality_train)
scores = cross_val_score(regressor, Features, Quality, cv=10,
scoring='mean_squared_error')
print scores
Problem here is that one or two values of MSE are negative. Following is the scores array:
[-0.47093648 -0.40001874 -0.46928925 -0.4317235 -0.37665658 -0.52359841
-0.40046081 -0.42944953 -0.36179521 -0.48792052]*
According to the formula, it shoud not be negative.
Upvotes: 1
Views: 7331
Reputation: 1119
Do refer to this thread below: scikit-learn cross validation, negative values with mean squared error
In summary, this is supposed to happen. The actual MSE is simply the positive version of the number you're getting. Hope this helps!
Upvotes: 1