小编ALT*_*ALT的帖子

Python:float() 参数必须是字符串或数字,而不是“pandas._libs.interval.Interval”

我正在尝试解决 Analytics Vidhya 的贷款预测的机器学习练习问题。当我使用随机森林分类器时,它显示:

TypeError:float() 参数必须是字符串或数字,而不是“pandas._libs.interval.Interval”

代码:

train['Loan_Status']=np.where(train['Loan_Status']=='Y', 1,0)

train_test_data=[train,test]

#Gender Feature
for dataset in train_test_data:
  dataset["Gender"]=dataset["Gender"].fillna('Male')
for dataset in train_test_data:
  dataset["Gender"]=dataset["Gender"].map({ "Female" : 1 , "Male" : 0}).astype(int)

#Married Feature 
for dataset in train_test_data:
  dataset['Married']=dataset['Married'].fillna('Yes')
for dataset in train_test_data:
  dataset['Married']=dataset['Married'].map({"Yes" : 1 , "No" : 0}).astype(int)

#Education Feature
for dataset in train_test_data:
  dataset['Education']=dataset['Education'].map({'Graduate' : 1 , 'Not Graduate' : 0}).astype(int)

#Combine Applicant income and coapplicant income
for dataset in train_test_data:
dataset['Income']=dataset['ApplicantIncome']+dataset['CoapplicantIncome']
train['IncomeBand']= pd.cut(train['Income'] , 4)
print(train[['IncomeBand' , 'Loan_Status']].groupby(['IncomeBand'] , …
Run Code Online (Sandbox Code Playgroud)

python classification machine-learning pandas

5
推荐指数
1
解决办法
7530
查看次数

Juypter 笔记本 pandas_profiling:无法从“pandas_profiling.report”导入名称“to_html”

我正在尝试导入熊猫分析。

import pandas as pd !pip install pandas_profiling import pandas_profiling as pp

但是,有一条错误消息说无法从“pandas_profiling.report”导入名称“to_html”

python pandas-profiling

5
推荐指数
1
解决办法
1664
查看次数