代码拉取完成,页面将自动刷新
import os
import numpy as np
import pandas as pd
import xgboost as xgb
import lightgbm as lgb
import catboost as ctb
from tqdm import tqdm
from sklearn import preprocessing
from sklearn.model_selection import KFold, StratifiedKFold,train_test_split
from sklearn.metrics import mean_squared_error
def eval_Features(df,feature_nan= {'nan': -1}):
feature_tmp = []
for index,feature in tqdm(enumerate(df['Features'].values)):
feature_tmp.append(eval(feature,feature_nan))
feature_tmp = pd.DataFrame(feature_tmp)
feature_tmp.columns = ['feature_'+str(i) for i in range(feature_tmp.shape[1])]
return feature_tmp
def get_dataset(path = './Molecule_prediction_20220823'):
#读入数据
df_train = pd.read_csv(f'{path}/train_0312.csv')
df_test = pd.read_csv(f'{path}/test_noLabel_0312.csv')
submit_examp = pd.read_csv(f'{path}/submit_examp_0312.csv')
#处理训练集
feature_tmp = eval_Features(df_train,feature_nan= {'nan': -1})
df_train = pd.concat([df_train,feature_tmp],axis=1)
del df_train['Features']
#处理测试集
feature_tmp = eval_Features(df_test,feature_nan= {'nan': -1})
df_test = pd.concat([df_test,feature_tmp],axis=1)
del df_test['Features']
return df_train , df_test
df_train , df_test = get_dataset()
df_train.to_csv("df_train.csv" , index = None)
df_test.to_csv("df_test.csv" , index = None)
print('dataset creation finished!')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。