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

freqtrade / freqtrade / 6181253459

08 Sep 2023 06:04AM UTC coverage: 94.614% (+0.06%) from 94.556%
6181253459

push

github-actions

web-flow
Merge pull request #9159 from stash86/fix-adjust

remove old codes when we only can do partial entries

2 of 2 new or added lines in 1 file covered. (100.0%)

19114 of 20202 relevant lines covered (94.61%)

0.95 hits per line

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

91.3
/freqtrade/freqai/prediction_models/XGBoostRFRegressor.py
1
import logging
1✔
2
from typing import Any, Dict
1✔
3

4
from xgboost import XGBRFRegressor
1✔
5

6
from freqtrade.freqai.base_models.BaseRegressionModel import BaseRegressionModel
1✔
7
from freqtrade.freqai.data_kitchen import FreqaiDataKitchen
1✔
8
from freqtrade.freqai.tensorboard import TBCallback
1✔
9

10

11
logger = logging.getLogger(__name__)
1✔
12

13

14
class XGBoostRFRegressor(BaseRegressionModel):
1✔
15
    """
16
    User created prediction model. The class inherits IFreqaiModel, which
17
    means it has full access to all Frequency AI functionality. Typically,
18
    users would use this to override the common `fit()`, `train()`, or
19
    `predict()` methods to add their custom data handling tools or change
20
    various aspects of the training that cannot be configured via the
21
    top level config.json file.
22
    """
23

24
    def fit(self, data_dictionary: Dict, dk: FreqaiDataKitchen, **kwargs) -> Any:
1✔
25
        """
26
        User sets up the training and test data to fit their desired model here
27
        :param data_dictionary: the dictionary holding all data for train, test,
28
            labels, weights
29
        :param dk: The datakitchen object for the current coin/model
30
        """
31

32
        X = data_dictionary["train_features"]
1✔
33
        y = data_dictionary["train_labels"]
1✔
34

35
        if self.freqai_info.get("data_split_parameters", {}).get("test_size", 0.1) == 0:
1✔
36
            eval_set = None
×
37
            eval_weights = None
×
38
        else:
39
            eval_set = [(data_dictionary["test_features"], data_dictionary["test_labels"])]
1✔
40
            eval_weights = [data_dictionary['test_weights']]
1✔
41

42
        sample_weight = data_dictionary["train_weights"]
1✔
43

44
        xgb_model = self.get_init_model(dk.pair)
1✔
45

46
        model = XGBRFRegressor(**self.model_training_parameters)
1✔
47

48
        model.set_params(callbacks=[TBCallback(dk.data_path)], activate=self.activate_tensorboard)
1✔
49
        model.fit(X=X, y=y, sample_weight=sample_weight, eval_set=eval_set,
1✔
50
                  sample_weight_eval_set=eval_weights, xgb_model=xgb_model)
51
        # set the callbacks to empty so that we can serialize to disk later
52
        model.set_params(callbacks=[])
1✔
53

54
        return model
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