Skip to content

Commit

Permalink
add small constant to MissForest to avoid zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
Bribak committed Jul 17, 2023
1 parent 00a80a0 commit 213444b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion build/lib/glycowork/motif/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ def replace_zero_with_random_gaussian_knn(df, group_sizes, mean = 0.01,

return df.T


class MissForest:
"""Parameters
(adapted from https://github.com/yuenshingyan/MissForest)
Expand Down Expand Up @@ -530,7 +531,8 @@ def fit_transform(self, X: pd.DataFrame) -> pd.DataFrame:

# Replace missing values in the current column with predictions
X_transform.loc[X_nan[column], column] = y_missing_pred

# Avoiding zeros
X_transform += 1e-6
return X_transform


Expand Down
4 changes: 3 additions & 1 deletion glycowork/motif/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ def replace_zero_with_random_gaussian_knn(df, group_sizes, mean = 0.01,

return df.T


class MissForest:
"""Parameters
(adapted from https://github.com/yuenshingyan/MissForest)
Expand Down Expand Up @@ -530,7 +531,8 @@ def fit_transform(self, X: pd.DataFrame) -> pd.DataFrame:

# Replace missing values in the current column with predictions
X_transform.loc[X_nan[column], column] = y_missing_pred

# Avoiding zeros
X_transform += 1e-6
return X_transform


Expand Down

0 comments on commit 213444b

Please sign in to comment.