You have to add a new meta column to your data, containing the instance weights (see Meta attributes and Table.add_meta_attribute. Store the meta column's id and call the learner with that meta id.import Orangeiris = Orange.data.Table("iris")# Add some weights to the iris datasetweight = Orange.feature.Continuous("weight")weight_id = -10iris.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 dataresults = 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) 这篇关于如何在Orange python软件包中设置和使用样本重量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-25 05:16