Probability and Machine Learning

I use python for a little machine learning.

I have a python nd array with 2000 elements. Each entry contains information about some items and at the end has a logical meaning to tell me whether they are a vampire or not.

Each entry in the array is as follows:

[height(cm), weight(kg), stake aversion, garlic aversion, reflectance, shiny, IS_VAMPIRE?]

My goal is to enable the new subject to be a vampire, given the data shown above for the subject.

I used sklearn to teach some machines:

clf = tree.DecisionTreeRegressor()

clf=clf.fit(X,Y)


print clf.predict(W)

Where W is the data array for the new object. script I wrote return booleans, but I would like it to return probabilities. How to change it?

+4
source share
3 answers

DecisionTreeClassifier predict_proba. ( scikit.)

:

clf = tree.DecisionTreeClassifier()

clf=clf.fit(X,Y)


print clf.predict_proba(W)
+2

DecisionTreeRegressor(), R ^ 2 .

, .

http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeRegressor.html#sklearn.tree.DecisionTreeRegressor

( 10 )

from sklearn.model_selection import cross_val_score


clf = tree.DecisionTreeRegressor()

clf=clf.fit(X,Y)

cross_val_score(clf, X, Y, cv=10)

print clf.predict(W)

, ,

array([ 0.61..., 0.57..., -0.34..., 0.41..., 0.75...,
        0.07..., 0.29..., 0.33..., -1.42..., -1.77...])
+2

You want to use a classifier that gives you credibility. In addition, you will want to make sure that in your test array W the data points are not replicas of any of your training data. If it exactly matches any of your training information, he thinks it is definitely a vampire or definitely not a vampire, so he will give you 0 or 1.

0
source

All Articles