Merge pull request #7236 from freqtrade/fix-lgbm-warning

Fix input shape for LighGBMClassifier
This commit is contained in:
Matthias 2022-08-16 13:49:25 +02:00 committed by GitHub
commit c865814a8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -26,13 +26,18 @@ class LightGBMClassifier(BaseClassifierModel):
if self.freqai_info.get('data_split_parameters', {}).get('test_size', 0.1) == 0: if self.freqai_info.get('data_split_parameters', {}).get('test_size', 0.1) == 0:
eval_set = None eval_set = None
test_weights = None
else: else:
eval_set = (data_dictionary["test_features"], data_dictionary["test_labels"]) eval_set = (data_dictionary["test_features"].to_numpy(),
X = data_dictionary["train_features"] data_dictionary["test_labels"].to_numpy()[:, 0])
y = data_dictionary["train_labels"] test_weights = data_dictionary["test_weights"]
X = data_dictionary["train_features"].to_numpy()
y = data_dictionary["train_labels"].to_numpy()[:, 0]
train_weights = data_dictionary["train_weights"]
model = LGBMClassifier(**self.model_training_parameters) model = LGBMClassifier(**self.model_training_parameters)
model.fit(X=X, y=y, eval_set=eval_set) model.fit(X=X, y=y, eval_set=eval_set, sample_weight=train_weights,
eval_sample_weight=[test_weights])
return model return model

View File

@ -27,13 +27,17 @@ class LightGBMRegressor(BaseRegressionModel):
if self.freqai_info.get('data_split_parameters', {}).get('test_size', 0.1) == 0: if self.freqai_info.get('data_split_parameters', {}).get('test_size', 0.1) == 0:
eval_set = None eval_set = None
eval_weights = None
else: else:
eval_set = (data_dictionary["test_features"], data_dictionary["test_labels"]) eval_set = (data_dictionary["test_features"], data_dictionary["test_labels"])
eval_weights = data_dictionary["test_weights"]
X = data_dictionary["train_features"] X = data_dictionary["train_features"]
y = data_dictionary["train_labels"] y = data_dictionary["train_labels"]
train_weights = data_dictionary["train_weights"]
model = LGBMRegressor(**self.model_training_parameters) model = LGBMRegressor(**self.model_training_parameters)
model.fit(X=X, y=y, eval_set=eval_set) model.fit(X=X, y=y, eval_set=eval_set, sample_weight=train_weights,
eval_sample_weight=[eval_weights])
return model return model