我是用于数据挖掘的 Orange python 包的新手。我正在使用橙色 2.7。
我的数据集有一个二元目标(好和坏)。Good 实例以 10 的抽样权重进行下抽样。如何在 Windows 和 Linux 版本的 Orange 中设置和使用权重进行分类分析?谢谢您的帮助!
您必须在数据中添加一个新的元列,其中包含实例权重(请参阅元属性和Table.add_meta_attribute。存储元列的 ID 并使用该元 ID 调用学习器。
import Orange
iris = Orange.data.Table("iris")
# Add some weights to the iris dataset
weight = Orange.feature.Continuous("weight")
weight_id = -10
iris.domain.add_meta(weight_id, weight)
iris.add_meta_attribute(weight, 1.0)
for i in range(50, 150):
iris[i][weight] = 10
# Train a tree classifier on weighted data.
clsf = Orange.classification.tree.TreeLearner(iris, weight_id)
# Evaluate learner performance on weighted data
results = Orange.evaluation.testing.cross_validation(
[Orange.classification.tree.TreeLearner,
Orange.classification.bayes.NaiveLearner],
(iris, weight_id) # Note how you pass the weight id to testing functions
)
auc = Orange.evaluation.scoring.AUC(results)
ca = Orange.evaluation.scoring.CA(results)