Skip to content

Commit

Permalink
fixed test coeff normalization/standardization.
Browse files Browse the repository at this point in the history
  • Loading branch information
wendycwong committed Oct 11, 2024
1 parent 68f3a5e commit a537924
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions h2o-py/tests/pyunit_utils/utils_for_glm_hglm_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,13 @@ def normalize_coefs(coefs, numerical_cols, training_frame):
"""
intercept_adjust = 0
all_coefs_names = coefs.keys()
enum_cols = list(filter(lambda x: x not in numerical_cols, all_coefs_names))
normalized_coefs = coefs.copy()
# only numerical coefficients are changed.
for cname in numerical_cols:
cmean = training_frame[cname].mean()[0,0]
csigma = training_frame[cname].sd()
normalized_coefs[cname] = coefs[cname] * sd
intercept_adjust = intercept_adjust + normalized_coefs[cname]*cmean/sd
normalized_coefs[cname] = coefs[cname] * csigma
intercept_adjust = intercept_adjust + normalized_coefs[cname]*cmean/csigma
if "intercept" in all_coefs_names:
normalized_coefs["intercept"] = coefs["intercept"]+intercept_adjust
else:
Expand Down

0 comments on commit a537924

Please sign in to comment.