GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (4082)

Orange/regression/mean.py (3 issues)

1
import numpy
0 ignored issues
show
The import numpy could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
2
3
from Orange.regression import Learner, Model
4
from Orange.data import ContinuousVariable
0 ignored issues
show
Unused ContinuousVariable imported from Orange.data
Loading history...
5
from Orange.statistics import distribution
6
7
__all__ = ["MeanLearner"]
8
9
10
class MeanLearner(Learner):
11
    """
12
    Fit a regression model that returns the average response (class) value.
13
    """
14
15
    name = 'mean'
16
17
    def fit_storage(self, data):
18
        """
19
        Construct a :obj:`MeanModel` by computing the mean value of the given
20
        data.
21
22
        :param data: data table
23
        :type data: Orange.data.Table
24
        :return: regression model, which always returns mean value
25
        :rtype: :obj:`MeanModel`
26
        """
27
        if not data.domain.has_continuous_class:
28
            raise ValueError("regression.MeanLearner expects a domain with a "
29
                             "(single) continuous variable")
30
        dist = distribution.get_distribution(data, data.domain.class_var)
31
        return MeanModel(dist)
32
33
34
# noinspection PyMissingConstructor
35
class MeanModel(Model):
36
    """
37
    A regression model that returns the average response (class) value.
38
    Instances can be constructed directly, by passing a distribution to the
39
    constructor, or by calling the :obj:`MeanLearner`.
40
41
    .. automethod:: __init__
42
43
    """
44
    def __init__(self, dist, domain=None):
0 ignored issues
show
The __init__ method of the super-class ModelRegression is not called.

It is generally advisable to initialize the super-class by calling its __init__ method:

class SomeParent:
    def __init__(self):
        self.x = 1

class SomeChild(SomeParent):
    def __init__(self):
        # Initialize the super class
        SomeParent.__init__(self)
Loading history...
45
        """
46
        Construct :obj:`Orange.regression.MeanModel` that always returns the
47
        mean value computed from the given distribution.
48
49
        If the distribution is empty, it constructs a model that returns zero.
50
51
        :param dist: domain for the `Table`
52
        :type dist: Orange.statistics.distribution.Continuous
53
        :return: regression model that returns mean value
54
        :rtype: :obj:`MeanModel`
55
        """
56
        # Don't call super().__init__ because it will raise an error since
57
        # domain is None.
58
        self.domain = domain
59
        self.dist = dist
60
        if dist.any():
61
            self.mean = self.dist.mean()
62
        else:
63
            self.mean = 0.0
64
65
    # noinspection PyPep8Naming
66
    def predict(self, X):
67
        """
68
        Return predictions (that is, the same mean value) for each given
69
        instance in `X`.
70
71
        :param X: data for which to make predictions
72
        :type X: :obj:`numpy.ndarray`
73
        :return: a vector of predictions
74
        :rtype: :obj:`numpy.ndarray`
75
        """
76
        return numpy.full(len(X), self.mean)
77
78
    def __str__(self):
79
        return 'MeanModel({})'.format(self.mean)
80