machine learning in coding
文章平均质量分 56
主要分享一些machine learning方面的python代码,更关注实践与代码。
mmc2015
北大信科学院,关注深度强化学习。http://net.pku.edu.cn/~maohangyu/
展开
-
machine learning in coding(python):polynomial curve fitting,python拟合多项式
下面给出一个拟合多项式的例子:[python] view plaincopyimport pandas as pd import numpy as np import scipy as sp import matplotlib.pyplot as plt from sklearn.pipeline原创 2015-09-07 10:54:53 · 1919 阅读 · 0 评论 -
machine learning in coding(python):使用交叉验证【选择模型超参数】
# Hyperparameter selection loopscore_hist = []Cvals = [0.001, 0.003, 0.006, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.1]for C in Cvals: model.C = C score = cv_loop(Xt, y, model, N) score_hi原创 2015-08-11 20:45:18 · 1910 阅读 · 0 评论 -
machine learning in coding(python):使用贪心搜索【进行特征选择】
print "Performing greedy feature selection..."score_hist = []N = 10good_features = set([])# Greedy feature selection loopwhile len(score_hist) score_hist[-2][0]: scores = [] for f in ran原创 2015-08-11 20:32:06 · 1502 阅读 · 0 评论 -
machine learning in coding(python):拼接原始数据;生成高次特征
拼接原始数据:train_data = pd.read_csv('train.csv')test_data = pd.read_csv('test.csv')all_data = np.vstack((train_data.ix[:,1:-1], test_data.ix[:,1:-1]))numpy下的合并数组vstack和hstack函数:>>> a = np.ones((原创 2015-08-10 21:33:02 · 1423 阅读 · 0 评论 -
machine learning in coding(python):使用xgboost构建预测模型
接上篇:def xgboost_pred(train,labels,test): params = {} params["objective"] = "reg:linear" params["eta"] = 0.005 params["min_child_weight"] = 6 params["subsample"] = 0.7 params["colsample原创 2015-08-05 22:06:37 · 6925 阅读 · 5 评论 -
machine learning in coding(python):pandas数据包DataFrame数据结构简介
导入模块:import pandas as pdimport numpy as np #pandas依赖于numpyfrom sklearn import preprocessingimport xgboost as xgb常用功能简介:#load train and test train = pd.read_csv('train.csv', index_co原创 2015-08-05 22:02:39 · 3119 阅读 · 2 评论 -
machine learning in coding(python):根据关键字合并多个表(构建组合feature)
三张表;train_set.csv;test_set.csv;feature.csv。三张表通过object_id关联。import pandas as pdimport numpy as np# load training and test datasetstrain = pd.read_csv('../input/train_set.csv')test = pd.re原创 2015-08-02 17:14:38 · 2312 阅读 · 0 评论