Generation

generate functionMon, 27 Mar 2023

There is a dataframe df with two columns: Category and Message in the following format: Category Message 0 ham Go until jurong point, crazy... Available only ... 1 ham Ok lar... Joking wif u oni... 2 spam Free entry in 2 a wkly comp to win FA Cup fina... 3 ham U dun say so early hor... U c already then say... 4 ham Nah I don't think he goes to usf, he lives aro... Split it into samples X = df['Message'] y = df['Category'] so that there are float numbers instead of object text everywhere.

from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)

Questions about programming?Chat with your personal AI assistant