[Solved] Predicting numerical features based on string features using sk-learn

Below is tested and fully working code of yours: data_train = pd.read_csv(r”train.csv”) data_test = pd.read_csv(r”test.csv”) columns = [‘Id’, ‘HomeTeam’, ‘AwayTeam’, ‘Full_Time_Home_Goals’] col = [‘Id’, ‘HomeTeam’, ‘AwayTeam’] data_test = data_test[col] data_train = data_train[columns] data_train = data_train.dropna() data_test = data_test.dropna() data_train[‘Full_Time_Home_Goals’] = data_train[‘Full_Time_Home_Goals’].astype(int) from sklearn import preprocessing def encode_features(df_train, df_test): features = [‘HomeTeam’, ‘AwayTeam’] df_combined = pd.concat([df_train[features], … Read more