我正在尝试预测数据集中变量的值,但无法弄清下面几行中发生的情况:
我了解下面的代码将分类值转换为连续值(不确定,只是猜测)
lis=[]
for i in range(0,df.shape[1]):
if(df.iloc[:,i].dtypes=='object'):
df.iloc[:,i]=pd.Categorical(df.iloc[:,i])
df.iloc[:,i]=df.iloc[:,i].cat.codes
df.iloc[:,i].astype('object')
lis.append(df.columns[i])
#Here are the column names from the dataset:
Index(['custAge','profession','marital','schooling','default','housing','loan','contact','month','day_of_week','campaign','pdays','previous','poutcome','emp.var.rate','cons.price.idx','cons.conf.idx','euribor3m','nr.employed','pmonths','pastEmail','responded'],dtype='object')
如果任何人都可以逐行分解正在发生的事情,那将非常有帮助。 我是这个平台的新手,所以任何错误请忽略。