I have created a string array and called a method with that array along with Train, test data. The purpose of the method is to find Kfold results of each algorithm specifies in the array. Everything works fine except in cross_val_score(model,X,y), it considers the model variable as a simple string instead of a callable model. If I put it like this cross_val_score(RandomForestClassifier(),X,y) it works perfectly fine. Now, how to convert the string model to a callable model. I am new to ML and I may not be able to make you understand the problem properly. Please let me know if you have any question. Thank you.
strarray = ['RandomForestClassifier()','LogisticRegression()','SVC()'] def checkall(array,X,y,Kfold): for model in strarray: values = cross_val_score(model,X,y) print(values) checkall(strarray,X,y,5)