@pravinmhaske wrote:
I am following the steps given in this article and trying to fit various models using the generic function. However, while doing Logistic Regression and RF, I’m getting below warning.
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py:578: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
Tried ravel(), flatten(), etc. but not able to get rid of the warning.
I’ve defined the generic function like this -
def classification_model(model,data,predictors,outcome): model.fit(data[predictors],data[outcome]) predictions = model.predict(data[predictors]) # predictions on train data accuracy = metrics.accuracy_score(predictions, data[outcome]) print ("Accuracy : %s" % "{0:.3%}".format(accuracy)) #And calling it like model = LogisticRegression() data = df predictors = ['Credit_History','LoanAmount'] outcome = ['Loan_Status'] classification_model(model,data,predictors,outcome)
Posts: 2
Participants: 2