Skip to content

Commit

Permalink
explicitly pass encoding as bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
alphasentaurii committed Sep 17, 2024
1 parent ccb3509 commit 4b7f3a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spacekit/preprocessor/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def tensors_to_arrays(X_train, y_train, X_test, y_test):


def hypersonic_pliers(
path_to_train, path_to_test, y_col=[0], skip=1, dlm=",", subtract_y=0.0
path_to_train, path_to_test, y_col=[0], skip=1, dlm=",", encoding=bytes, subtract_y=0.0
):
"""Extracts data into 1-dimensional arrays, using separate target classes (y) for training and test data. Assumes y (target)
is first column in dataframe. If the target (y) classes in the raw data are 0 and 2, but you'd like them to be binaries (0
Expand All @@ -887,6 +887,8 @@ def hypersonic_pliers(
skiprows parameter for np.loadtxt, by default 1
dlm : str, optional
delimiter, by default ","
encoding: str, optional
explicitly passed encoding type to numpy.loadtxt, by default bytes
subtract_y : float, optional
subtract this value from all y-values, by default 1.0
Expand All @@ -895,15 +897,15 @@ def hypersonic_pliers(
np.ndarrays
X_train, X_test, y_train, y_test
"""
Train = np.loadtxt(path_to_train, skiprows=skip, delimiter=dlm)
Train = np.loadtxt(path_to_train, skiprows=skip, delimiter=dlm, encoding=encoding)
cols = list(range(Train.shape[1]))
xcols = [c for c in cols if c not in y_col]
# X_train = Train[:, 1:]
X_train = Train[:, xcols]
# y_train = Train[:, 0, np.newaxis] - subtract_y
y_train = Train[:, y_col, np.newaxis] - subtract_y

Test = np.loadtxt(path_to_test, skiprows=skip, delimiter=dlm)
Test = np.loadtxt(path_to_test, skiprows=skip, delimiter=dlm, encoding=encoding)
X_test = Test[:, xcols]
y_test = Test[:, y_col, np.newaxis] - subtract_y
# X_test = Test[:, 1:]
Expand Down

0 comments on commit 4b7f3a1

Please sign in to comment.