You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The package is a huge dependency.
Currently, we only use sklearn in one place (in svd.py):
defSVD(
df: pd.DataFrame, svd_flip: bool=True
) ->Tuple[NDArray[Any], NDArray[Any], NDArray[Any]]:
""" ... svd_flip: bool Whether to use svd_flip on U and V or not. ... """U, s, V=linalg.svd(df, full_matrices=False)
ifsvd_flip:
U, V=sklearn.utils.extmath.svd_flip(U, V)
returnU, s, V
and the function is a couple lines long:
defsvd_flip(u, v, u_based_decision=True):
"""Sign correction to ensure deterministic output from SVD. Adjusts the columns of u and the rows of v such that the loadings in the columns in u that are largest in absolute value are always positive. [...] """ifu_based_decision:
# columns of u, rows of vmax_abs_cols=np.argmax(np.abs(u), axis=0)
signs=np.sign(u[max_abs_cols, range(u.shape[1])])
u*=signsv*=signs[:, np.newaxis]
else:
# rows of v, columns of umax_abs_rows=np.argmax(np.abs(v), axis=1)
signs=np.sign(v[range(v.shape[0]), max_abs_rows])
u*=signsv*=signs[:, np.newaxis]
returnu, v
The text was updated successfully, but these errors were encountered:
The package is a huge dependency.
Currently, we only use
sklearn
in one place (insvd.py
):and the function is a couple lines long:
The text was updated successfully, but these errors were encountered: