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 str_to_float(train, test): train = [float(x) for x in train] test = [float(x) for x in test] return train, test X_train, X_test = str_to_float(X_train, X_test) y_train, y_test = str_to_float(y_train, y_test)

Questions about programming?Chat with your personal AI assistant