【问题标题】:How to set up and use sample weight in the Orange python package?如何在 Orange python 包中设置和使用样本权重?
【发布时间】:2015-08-11 06:05:50
【问题描述】:

我是用于数据挖掘的 Orange python 包的新手。我正在使用橙色 2.7。

我的数据集有一个二元目标(好和坏)。 Good 实例以 10 的抽样权重进行下抽样。如何在 Windows 和 Linux 版本的 Orange 中设置和使用权重进行分类分析?感谢您的帮助!

【问题讨论】:

    标签: python orange


    【解决方案1】:

    您必须在数据中添加一个新的元列,其中包含实例权重(请参阅Meta attributesTable.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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-22
      • 1970-01-01
      • 2020-09-09
      • 2017-10-14
      • 2019-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多