• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

freqtrade / freqtrade / 9394559170

26 Apr 2024 06:36AM UTC coverage: 94.656% (-0.02%) from 94.674%
9394559170

push

github

xmatthias
Loader should be passed as kwarg for clarity

20280 of 21425 relevant lines covered (94.66%)

0.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/freqtrade/freqai/base_models/FreqaiMultiOutputRegressor.py
1
from sklearn.multioutput import MultiOutputRegressor, _fit_estimator
1✔
2
from sklearn.utils.parallel import Parallel, delayed
1✔
3
from sklearn.utils.validation import has_fit_parameter
1✔
4

5

6
class FreqaiMultiOutputRegressor(MultiOutputRegressor):
1✔
7

8
    def fit(self, X, y, sample_weight=None, fit_params=None):
1✔
9
        """Fit the model to data, separately for each output variable.
10
        Parameters
11
        ----------
12
        X : {array-like, sparse matrix} of shape (n_samples, n_features)
13
            The input data.
14
        y : {array-like, sparse matrix} of shape (n_samples, n_outputs)
15
            Multi-output targets. An indicator matrix turns on multilabel
16
            estimation.
17
        sample_weight : array-like of shape (n_samples,), default=None
18
            Sample weights. If `None`, then samples are equally weighted.
19
            Only supported if the underlying regressor supports sample
20
            weights.
21
        fit_params : A list of dicts for the fit_params
22
            Parameters passed to the ``estimator.fit`` method of each step.
23
            Each dict may contain same or different values (e.g. different
24
            eval_sets or init_models)
25
            .. versionadded:: 0.23
26
        Returns
27
        -------
28
        self : object
29
            Returns a fitted instance.
30
        """
31

32
        if not hasattr(self.estimator, "fit"):
1✔
33
            raise ValueError("The base estimator should implement a fit method")
×
34

35
        y = self._validate_data(X="no_validation", y=y, multi_output=True)
1✔
36

37
        if y.ndim == 1:
1✔
38
            raise ValueError(
×
39
                "y must have at least two dimensions for "
40
                "multi-output regression but has only one."
41
            )
42

43
        if sample_weight is not None and not has_fit_parameter(
1✔
44
            self.estimator, "sample_weight"
45
        ):
46
            raise ValueError("Underlying estimator does not support sample weights.")
×
47

48
        if not fit_params:
1✔
49
            fit_params = [None] * y.shape[1]
×
50

51
        self.estimators_ = Parallel(n_jobs=self.n_jobs)(
1✔
52
            delayed(_fit_estimator)(
53
                self.estimator, X, y[:, i], sample_weight, **fit_params[i]
54
            )
55
            for i in range(y.shape[1])
56
        )
57

58
        if hasattr(self.estimators_[0], "n_features_in_"):
1✔
59
            self.n_features_in_ = self.estimators_[0].n_features_in_
1✔
60
        if hasattr(self.estimators_[0], "feature_names_in_"):
1✔
61
            self.feature_names_in_ = self.estimators_[0].feature_names_in_
1✔
62

63
        return
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc