I was given a dataset containing information on Student Academics and was asked to perform 5 machine learning algorithms.

from sklearn.ensemble import RandomForestRegressor
random_forest = RandomForestRegressor(n_estimators=100, random_state=0)
random_forest.fit(X_train, y_train)
   Y_prediction = random_forest.predict(X_test)
   random_forest.score(X_train, y_train)
   acc_random_forest = round(random_forest.score(X_train, y_train) * 100, 2)
except ValueError

I keep getting ValueError: could not convert string to float 'Enrolled'

  • 1
    $\begingroup$ It would be helpful to show how you load and preprocess the data. Based on the error message, I assume that you are missing sime preprocessing steps. You could for example try some one-hot-encoding for the categorical variables. $\endgroup$
    – Broele
    Mar 10 at 10:21


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.