NVE / avalanche_ml

Applying machine learning in the Norwegian Avalanche warning Service
MIT License
2 stars 1 forks source link

Enable class_weights on BulletinMachine #10

Closed widforss closed 4 years ago

widforss commented 4 years ago

Resolves #7.

BulletinMachine now has two more parameters, sk_prim_class_weight and sk_class_weight. These are used to set the class_weight parameter on sklearn models. Since the exact configuration of the model outputs change depending on the data, this has to be generated internally.

sk_prim_class_weight is used for the model calculating the danger_level, emergency_warning, problem_1 etc. sk_class_weight is applied to the "CLASS" models on the subproblem, i.e. things like cause and dsize.

Each parameter defaults to None. "balanced" and "balanced_subsample" is passed directly to the model.

However, to fine-tune the weights, a dict can be sent. If we specifically want to change the weight of danger level 4, send a dict as {"danger_level": {'4': {0: 2, 1: 2}}} to sk_prim_class_weight. This way, each weight can be changed individually.