088b10a9b6621472af54635e761bda0dd775836f,Orange/classification/majority.py,MajorityLearner,__call__,#MajorityLearner#Any#,8

Before Change


                "Majority learner does not support multiple classes")
        class_var = data.domain.class_var
        y = data.Y
        if isinstance(data.domain.class_var, data.ContinuousVariable):
            return DefaultClassifier(data.domain, bn.nanmedian(y))
        else:
            n_values = data.domain.class_var.values()
            if y.dtype != int:
                nans = y.isnan()
                y = np.array(y, dtype=int)
                y[nans] = len(n_values)
            if data.W.shape[-1] == 0:
                distr = np.bincount(y, minlength=n_values)
            else:
                distr = np.bincount(y, data.W, minlength=n_values)
            distr = np.asarray(distr, np.float)[:n_values]
            return DefaultClassifier(data.domain, distr=distr)


class DefaultClassifier(classification.Classifier):
    def __init__(self, value=None, distr=None):
        if value is None:
            mx = np.max(distr)

After Change



        y = data.Y
        w = data.W if data.W.shape[-1] != 0 else None
        assert np.issubdtype(y.dtype, int)

        n_values = data.domain.class_var.values()
        dist = np.bincount(y, w, minlength=n_values).astype(float)[:n_values]
        N = sum(dist)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 8

Instances


Project Name: biolab/orange3
Commit Name: 088b10a9b6621472af54635e761bda0dd775836f
Time: 2012-09-26
Author: janez.demsar@fri.uni-lj.si
File Name: Orange/classification/majority.py
Class Name: MajorityLearner
Method Name: __call__


Project Name: asyml/texar
Commit Name: af461df627ef660d1a71b6981dedb4e4b504ba9a
Time: 2017-09-25
Author: junxianh2@gmail.com
File Name: txtgen/modules/connectors/connectors.py
Class Name: StochasticConnector
Method Name: _build


Project Name: commonsense/conceptnet5
Commit Name: 44cc88ad35afd37853c55d1f333fe326259c0578
Time: 2011-09-30
Author: rspeer@mit.edu
File Name: conceptnet5/graph.py
Class Name: ConceptNetGraph
Method Name: get_or_create_assertion


Project Name: dgasmith/opt_einsum
Commit Name: af9bb0361a841fff2af69b0609b6b36282cc3c45
Time: 2017-07-19
Author: malorian@me.com
File Name: test/test_paths.py
Class Name:
Method Name: assert_contract_order