本文整理汇总了Python中Orange.evaluation.Results.predicted方法的典型用法代码示例。如果您正苦于以下问题:Python Results.predicted方法的具体用法?Python Results.predicted怎么用?Python Results.predicted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.evaluation.Results
的用法示例。
在下文中一共展示了Results.predicted方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_F1_multiclass
# 需要导入模块: from Orange.evaluation import Results [as 别名]
# 或者: from Orange.evaluation.Results import predicted [as 别名]
def test_F1_multiclass(self):
results = Results(
domain=Domain([], DiscreteVariable(name="y", values="01234")),
actual=[0, 4, 4, 1, 2, 0, 1, 2, 3, 2])
results.predicted = np.array([[0, 1, 4, 1, 1, 0, 0, 2, 3, 1],
[0, 4, 4, 1, 2, 0, 1, 2, 3, 2]])
res = F1(results)
self.assertAlmostEqual(res[0], 0.61)
self.assertEqual(res[1], 1.)
示例2: test_init
# 需要导入模块: from Orange.evaluation import Results [as 别名]
# 或者: from Orange.evaluation.Results import predicted [as 别名]
def test_init(self):
res = Results(nmethods=2, nrows=100)
res.actual[:50] = 0
res.actual[50:] = 1
res.predicted = np.vstack((res.actual, res.actual))
np.testing.assert_almost_equal(CA(res), [1, 1])
res.predicted[0][0] = 1
np.testing.assert_almost_equal(CA(res), [0.99, 1])
res.predicted[1] = 1 - res.predicted[1]
np.testing.assert_almost_equal(CA(res), [0.99, 0])
示例3: test_F1_binary
# 需要导入模块: from Orange.evaluation import Results [as 别名]
# 或者: from Orange.evaluation.Results import predicted [as 别名]
def test_F1_binary(self):
results = Results(
domain=Domain([], DiscreteVariable(name="y", values="01")),
actual=[0, 1, 1, 1, 0, 0, 1, 0, 0, 1])
results.predicted = np.array([[0, 1, 1, 1, 0, 0, 1, 0, 0, 1],
[0, 1, 1, 1, 0, 0, 1, 1, 1, 1]])
res = F1(results)
self.assertEqual(res[0], 1.)
self.assertAlmostEqual(res[1], 5 / 6)
res_target = F1(results, target=1)
self.assertEqual(res[0], res_target[0])
self.assertEqual(res[1], res_target[1])
res_target = F1(results, target=0)
self.assertEqual(res_target[0], 1.)
self.assertAlmostEqual(res_target[1], 3 / 4)
示例4: test_F1_target
# 需要导入模块: from Orange.evaluation import Results [as 别名]
# 或者: from Orange.evaluation.Results import predicted [as 别名]
def test_F1_target(self):
results = Results(
domain=Domain([], DiscreteVariable(name="y", values="01234")),
actual=[0, 4, 4, 1, 2, 0, 1, 2, 3, 2])
results.predicted = np.array([[0, 1, 4, 1, 1, 0, 0, 2, 3, 1],
[0, 4, 4, 1, 2, 0, 1, 2, 3, 2]])
for target, prob in ((0, 4 / 5),
(1, 1 / 3),
(2, 1 / 2),
(3, 1.),
(4, 2 / 3)):
res = F1(results, target=target)
self.assertEqual(res[0], prob)
self.assertEqual(res[1], 1.)
示例5: test_precision_binary
# 需要导入模块: from Orange.evaluation import Results [as 别名]
# 或者: from Orange.evaluation.Results import predicted [as 别名]
def test_precision_binary(self):
results = Results(
domain=Domain([], DiscreteVariable(name="y", values="01")),
actual=[0, 1, 1, 1, 0, 0, 1, 0, 0, 1])
results.predicted = np.array([[0, 1, 1, 1, 0, 0, 1, 0, 0, 1],
[0, 1, 1, 1, 0, 0, 1, 1, 1, 0]])
res = self.score(results)
self.assertEqual(res[0], 1.)
self.assertAlmostEqual(res[1], 4 / 6)
res_target = self.score(results, target=1)
self.assertEqual(res[0], res_target[0])
self.assertEqual(res[1], res_target[1])
res_target = self.score(results, target=0)
self.assertEqual(res_target[0], 1.)
self.assertAlmostEqual(res_target[1], 3 / 4)
res_target = self.score(results, average='macro')
self.assertEqual(res_target[0], 1.)
self.assertAlmostEqual(res_target[1], (4 / 6 + 3 / 4) / 2)
示例6: test_precision_multiclass
# 需要导入模块: from Orange.evaluation import Results [as 别名]
# 或者: from Orange.evaluation.Results import predicted [as 别名]
def test_precision_multiclass(self):
results = Results(
domain=Domain([], DiscreteVariable(name="y", values="01234")),
actual=[0, 4, 4, 1, 2, 0, 1, 2, 3, 2])
results.predicted = np.array([[0, 4, 4, 1, 2, 0, 1, 2, 3, 2],
[0, 1, 4, 1, 1, 0, 0, 2, 3, 1]])
res = self.score(results, average='weighted')
self.assertEqual(res[0], 1.)
self.assertAlmostEqual(res[1], 0.78333, 5)
for target, prob in ((0, 2 / 3),
(1, 1 / 4),
(2, 1 / 1),
(3, 1 / 1),
(4, 1 / 1)):
res = self.score(results, target=target, average=None)
self.assertEqual(res[0], 1.)
self.assertEqual(res[1], prob)