を予測する私は、次のコードを書いた:Sklearnは、複数の出力
from sklearn import tree
# Dataset & labels
# Using metric units
# features = [height, weight, style]
styles = ['modern', 'classic']
features = [[1.65, 65, 1],
[1.55, 50, 1],
[1.76, 64, 0],
[1.68, 77, 0] ]
labels = ['Yellow dress', 'Red dress', 'Blue dress', 'Green dress']
# Decision Tree
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
# Returns the dress
height = input('Height: ')
weight = input('Weight: ')
style = input('Modern [0] or Classic [1]: ')
print(clf.predict([[height,weight,style]]))
このコードは、その彼女に、より良いフィットドレスを返し、その後、使用者の身長と体重を受けます。複数のオプションを返す方法はありますか?たとえば、2つ以上のドレスを返します。
UPDATE
from sklearn import tree
import numpy as np
# Dataset & labels
# features = [height, weight, style]
# styles = ['modern', 'classic']
features = [[1.65, 65, 1],
[1.55, 50, 1],
[1.76, 64, 1],
[1.72, 68, 0],
[1.73, 68, 0],
[1.68, 77, 0]]
labels = ['Yellow dress',
'Red dress',
'Blue dress',
'Green dress',
'Purple dress',
'Orange dress']
# Decision Tree
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
# Returns the dress
height = input('Height: ')
weight = input('Weight: ')
style = input('Modern [0] or Classic [1]: ')
print(clf.predict_proba([[height,weight,style]]))
ユーザーは1.72メートルと68キロであれば、私は緑と紫のドレスの両方を表示したいです。この例では、緑のドレスの100%を返します。
それが1以上のものを返します:あなたはそれでこのような何かを行うことができ
?最も可能な順序でそれらを返すことを意味しますか? – erip