machine learning in coding(python):根据关键字合并多个表(构建组合feature)

三张表;train_set.csv;test_set.csv;feature.csv。三张表通过object_id关联。


import pandas as pd
import numpy as np

# load training and test datasets
train = pd.read_csv('../input/train_set.csv')
test = pd.read_csv('../input/test_set.csv')
features = pd.read_csv('../input/feature.csv')
train = pd.merge(train,features,on='object_id',how='inner')
test = pd.merge(test,features,on='object_id',how='inner')

# drop useless columns and create labels
test = test.drop(['id', 'object_id'], axis = 1)
labels = train.cost.values
train = train.drop(['object_id', 'cost'], axis = 1)
# convert data to numpy array  
train = np.array(train)  
test = np.array(test)  


from:kaggle



你可能感兴趣的:(ML,in,coding,scikit-learn,machine,learning,in,coding)