【发布时间】:2020-09-18 23:47:59
【问题描述】:
任务: 有两位老师。他们给学生的作业打分。有一个期末成绩。如果他们给出相同的分数,它就等于老师的分数。或者如果老师的成绩不同,最终成绩为-1。 我想教计算机看这个逻辑。
数据:
- Rate1 - 第一次教师评估
- Rate2 - 第二次教师评估
- 结果 - 最终评估
示例:
0,1; 0,1 => 0,1
0,7; 0,7 => 0,7
0,3; 0,2 => -1
我的代码:
import pandas
MyData = pandas.read_excel("train.xlsx")
input_data = MyData.drop("Result", axis=1)
target = MyData.Result
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
model.fit(input_data, target)
在那之后,我得到了下一个错误。如果我所有的估计都是整数,则不存在此错误。但我必须处理分数。
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-51-433a918946a9> in <module>
----> 1 model.fit(input_data, target)
~\anaconda3\lib\site-packages\sklearn\ensemble\_forest.py in fit(self, X, y, sample_weight)
319 self.n_outputs_ = y.shape[1]
320
--> 321 y, expanded_class_weight = self._validate_y_class_weight(y)
322
323 if getattr(y, "dtype", None) != DOUBLE or not y.flags.contiguous:
~\anaconda3\lib\site-packages\sklearn\ensemble\_forest.py in _validate_y_class_weight(self, y)
539
540 def _validate_y_class_weight(self, y):
--> 541 check_classification_targets(y)
542
543 y = np.copy(y)
~\anaconda3\lib\site-packages\sklearn\utils\multiclass.py in check_classification_targets(y)
167 if y_type not in ['binary', 'multiclass', 'multiclass-multioutput',
168 'multilabel-indicator', 'multilabel-sequences']:
--> 169 raise ValueError("Unknown label type: %r" % y_type)
170
171
ValueError: Unknown label type: 'continuous'
附言我的数据是here。
如何处理小数?
【问题讨论】:
-
请尝试阅读how to ask并帮助我们为您提供帮助
-
您阅读我发布的链接了吗?请花一些时间阅读它会对您有所帮助。关于您的问题I think this will help
-
这能回答你的问题吗? Calculating large fractions in Python?
-
你需要机器学习来获得这样一个简单的规则吗?
-
我确实阅读了任务。这根本不需要机器学习,就像你描述的那样。
标签: python machine-learning scikit-learn random-forest