Skip to content

Instantly share code, notes, and snippets.

View zhpmatrix's full-sized avatar
🎯
Focusing

张大千 zhpmatrix

🎯
Focusing
View GitHub Profile
from keras.models import Sequential
from keras.layers import Dense
x, y = ...
x_val, y_val = ...
# 1-dimensional MSE linear regression in Keras
model = Sequential()
model.add(Dense(1, input_dim=x.shape[1]))
model.compile(optimizer='rmsprop', loss='mse')
size = map(lambda (x,y): (x, len(y)),product_set.items())
size = map(lambda (x,y): (x, len(y)),product_set.items())
# Author: Andreas Mueller <amueller@ais.uni-bonn.de>
# Mod: zhpmatrix@2017-03-16 20:17
# License: BSD 3 clause
from numpy import log1p
from sklearn.pipeline import Pipeline, FeatureUnion
from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVC
@zhpmatrix
zhpmatrix / cli_main_part.cc
Created March 15, 2017 06:44
xgboost 单机版入口代码
int CLIRunTask(int argc, char *argv[]) {
if (argc < 2) {
printf("Usage: <config>\n");
return 0;
}
rabit::Init(argc, argv);
std::vector<std::pair<std::string, std::string> > cfg;
cfg.push_back(std::make_pair("seed", "0"));
'''
desc: worker,speed up for tianchi competition using distributed method
author: zhpmatrix
date: 2017-02-19
contributor: XueFeng Liao
'''
import time, sys, queue
from task import *
from multiprocessing.managers import BaseManager
'''
desc: master,speed up for tianchi competition using distributed method
author: zhpmatrix
date: 2017-02-19
contributor: XueFeng Liao
'''
import random, time
from multiprocessing.managers import BaseManager
from multiprocessing import Queue
@zhpmatrix
zhpmatrix / compare_multiprocessing
Created February 19, 2017 05:24
multiprocessing单进程和多进程时间性能对比
import time
import multiprocessing
def profile(func):
def wrapper(*args, **kwargs):
import time
start = time.time()
func(*args, **kwargs)
end = time.time()
print 'COST: {}'.format(end - start)
return wrapper
@zhpmatrix
zhpmatrix / add_header.sh
Created January 17, 2017 11:20
cat命令添加数据header,pandas处理更加的方便
# add header to shop_info.txt
echo shop_id,city_name,location_id,per_pay,score,comment_cnt,shop_level,cate_1_name,cate_2_name,cate_3_name > show_info_header.txt
cat shop_info.txt >> shop_info_header.txt
mv shop_info_header.txt > shop_info.txt
# add header to user_view.txt
echo user_id,shop_id,time_stamp > user_view_header.txt
cat user_view.txt >> user_view_header.txt
mv user_view_header.txt > user_view.txt
@zhpmatrix
zhpmatrix / add_header.sh
Created January 17, 2017 11:20
cat命令添加数据header,pandas处理更加的方便
# add header to shop_info.txt
echo shop_id,city_name,location_id,per_pay,score,comment_cnt,shop_level,cate_1_name,cate_2_name,cate_3_name > show_info_header.txt
cat shop_info.txt >> shop_info_header.txt
mv shop_info_header.txt > shop_info.txt
# add header to user_view.txt
echo user_id,shop_id,time_stamp > user_view_header.txt
cat user_view.txt >> user_view_header.txt
mv user_view_header.txt > user_view.txt