码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2015-08-02 18:18:32      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:机器学习   scikit-learn   合并多张表   组合特征   

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


<pre name="code" class="python"><strong><span style="font-size:18px;">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)</span></strong>



版权声明:本文为博主原创文章,未经博主允许不得转载。

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

标签:机器学习   scikit-learn   合并多张表   组合特征   

原文地址:http://blog.csdn.net/mmc2015/article/details/47208939

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!