Sklearn - How to predict probability for all target labels

后端 未结 3 1226
孤城傲影
孤城傲影 2021-01-05 07:47

I have a data set with a target variable that can have 7 different labels. Each sample in my training set has only one label for the target variable.

For each sampl

3条回答
  •  长发绾君心
    2021-01-05 08:22

    You can do that by simply removing the OneVsRestClassifer and using predict_proba method of the DecisionTreeClassifier. You can do the following:

    clf = DecisionTreeClassifier()
    clf.fit(X_train, y_train)
    pred = clf.predict_proba(X_test)
    

    This will give you a probability for each of your 7 possible classes.

    Hope that helps!

提交回复
热议问题