我正在使用 Lending Club 数据。我正在使用以下代码。
我有一个包含所有预测列的数据框 X 和包含输出的 Y 是贷款是好还是坏
#Here we change the good loans to 1 and bad loans to 0
mask = (Y['loan_condition'] == 'Good Loan')
Y['loan_condition'] = np.where(mask, 1, 0)
#Train Test Split and performing SMOTE
from sklearn.model_selection import train_test_split
from imblearn.over_sampling import SMOTE
os = SMOTE(random_state=0)
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.3,
random_state=0)
columns = X_train.columns
os_data_X,os_data_Y=os.fit_sample(X_train, Y_train)
os_data_X = pd.DataFrame(data=os_data_X,columns=columns )
os_data_Y= pd.DataFrame(data=os_data_Y,columns=['loan_condition'])
X=np.array(os_data_X)
Y=np.array(os_data_Y)
#Performing Logistic Regression
import statsmodels.api as sm
logit_model=sm.Logit(Y,X)
result=logit_model.fit()
print(result.summary2())
错误/警告:
警告:已超过最大迭代次数。当前函数值:inf 迭代次数:35
LinAlgError:奇异矩阵
有人可以在这里帮助我吗?帮助将不胜感激
萧十郎
相关分类