adriangb / scikeras

Scikit-Learn API wrapper for Keras.
https://www.adriangb.com/scikeras/
MIT License
239 stars 47 forks source link

Fix handling of class_weight=balanced #245

Closed adriangb closed 3 years ago

adriangb commented 3 years ago

Fixes use of class_weight parameter.

Currently, the class_weight parameter passed to the KerasClassifier constructor gets passed to Keras, which breaks class_weight="balanced" and any other values that are supported by Scikit-Learn (which we want to support in SciKeras) but no in Keras.

github-actions[bot] commented 3 years ago

📝 Docs preview for commit 75bb357 at: https://www.adriangb.com/scikeras/refs/pull/245/merge/

codecov-commenter commented 3 years ago

Codecov Report

Merging #245 (75bb357) into master (6de5a04) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #245   +/-   ##
=======================================
  Coverage   98.91%   98.92%           
=======================================
  Files           6        6           
  Lines         740      743    +3     
=======================================
+ Hits          732      735    +3     
  Misses          8        8           
Impacted Files Coverage Δ
scikeras/wrappers.py 98.00% <100.00%> (+0.01%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6de5a04...75bb357. Read the comment docs.

adriangb commented 3 years ago

Are any other values accepted besides sample_weight="balanced"?

Nope, just "balanced" (and None): https://scikit-learn.org/stable/modules/generated/sklearn.utils.class_weight.compute_class_weight.html