I have created a custom model in python using scikit-learn, and I want to use cross validation.
The class for the model is defined as follows:
clas
The easiest way to make the error go away is to pass scoring="accuracy"
or scoring="hamming"
to cross_val_score
. The cross_val_score
function itself doesn't know what kind of problem you are trying to solve, so it doesn't know what an appropriate metric is. It looks like you are trying to do multi-label classification, so maybe you want to use the hamming loss?
You can also implement a score
method as explained in the "Roll your own estimator" docs, which has as signature
def score(self, X, y_true)
. See http://scikit-learn.org/stable/developers/#different-objects
By the way, you do know about the OneVsRestClassifier
, right? It looks a bit like you are reimplementing it.