fix input shape warning for LGBMClassifier, add sample_weights/eval_weights
This commit is contained in:
parent
96d2f61812
commit
4c0fda400f
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user