'ValueError: could not convert string to float: 'Default'
I am getting a Value Error, when fitting Logistic Regression model onto Corporate Default dataset. Error is:
ValueError: could not convert string to float: 'Default'
Can someone advise the reason for such an error and how to resolve it? Here is my code for reference.
features=data_select_new.drop('Default', axis=1)
df['Label']= 'Default'
X_train, X_test, Y_train, Y_test = train_test_split(features,df['Label'], test_size=0.30, random_state=42)
lr=LogisticRegression()
lr.fit(X_train, Y_train)
Solution 1:[1]
df['Label']= 'Default' creates a column with 'Default' on each row.
As you You probably want to predict the column 'Default' from the original daset, you can write instead:
df['Label'] = data_select_new['Default']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rehaqds |
