Generation

generate functionMon, 27 Mar 2023

There are variables X_train, X_test, y_train, y_test created through sklearn train_test_split. They contain text data in string format. Convert them to float numbers.

def cond_to_float(X_train, X_test, y_train, y_test): y_train = y_train.astype(np.float) y_test = y_test.astype(np.float) X_train = X_train.astype(np.float) X_test = X_test.astype(np.float) return (X_train, X_test, y_train, y_test)

Questions about programming?Chat with your personal AI assistant