Skip to content

Commit cd87725

Browse files
author
kgued
committed
do not srew up the weighting config if the feature you ask for is invalid
1 parent 49d15fd commit cd87725

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

dataikuapi/dss/ml.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,11 @@ def use_sample_weighting(self, feature_name):
437437
Uses a feature as sample weight
438438
:param str feature_name: Name of the feature to use
439439
"""
440-
self.remove_sample_weighting()
441440
if not feature_name in self.mltask_settings["preprocessing"]["per_feature"]:
442441
raise ValueError("Feature %s doesn't exist in this ML task, can't use as weight" % feature_name)
442+
443+
self.remove_sample_weighting()
444+
443445
self.mltask_settings['weight']['weightMethod'] = 'SAMPLE_WEIGHT'
444446
self.mltask_settings['weight']['sampleWeightVariable'] = feature_name
445447
self.mltask_settings['preprocessing']['per_feature'][feature_name]['role'] = 'WEIGHT'

0 commit comments

Comments
 (0)