Skip to content

Instantly share code, notes, and snippets.

webdancer seaslee

Block or report user

Report or block seaslee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
seaslee / zh.r
Last active Aug 29, 2015
simple stats
View zh.r
d = read.csv('a.csv', head=T, sep=',')
p <-unlist(d)
pt <- ts(p, frequency=12, start=c(2015))
fit <- auto.arima(pt)
forecast(fit, h=2)
View sigir 13'.R
## read from txt file
path = 'd:/sigir_full.txt'
f <- file(path,open='rt')
con <- readLines(f)
## get the tile from the content
paperTitles <- con[grepl("^Title: ",con)]
seaslee / r_resources
Last active Dec 24, 2015
R resources
View r_resources
1. [John Cook写的不错的关于R语言的一个基本介绍](
2. [R 官方的入门手册](
3. [电子书“The R Inferno”]
1. [Edwen Chen写的一个不错的入门,很简单的qplot的用法]
2. [ggplot2的文档](
1. [Google's R Style Guide](
2. [另一个简洁的R编码规范,ggplot2的作者](
seaslee / gist:6436522
Last active Aug 13, 2018
logistic regression examples using scikit-learn
View gist:6436522
# -*- coding:utf-8 -*-
from sklearn import datasets
from sklearn import linear_model
from sklearn.metrics import f1_score
##### load data and split into train and test ####
data_digits = datasets.load_digits()
data =
target =
train_ratio = 0.8
data_num = data.shape[0]
seaslee / gist:6435194
Created Sep 4, 2013
linear model example using scikit-learn
View gist:6435194
#! /usr/bin/env python
# -*- coding:utf-8 -*-
from sklearn import datasets
from sklearn import linear_model
from sklearn.metrics import mean_squared_error
##### load data and split into train and test ####
data_boston = datasets.load_boston()
data =
target =
train_ratio = 0.8
seaslee / gist:5276281
Created Mar 30, 2013
walk the two level files like following: ====dir ||subdir ||files ||subdir ||files ...
View gist:5276281
def imgs(imgsdir):
for dirname, subdirnames, subfiles in os.walk(imgsdir):
#subdir for each query of images
for subdir in subdirnames:
for dirname1, subdirnames1, subfiles1 in os.walk(os.path.join(dirname, subdir)):
#each image in the directory of one query
for img in subfiles1:
imgpath = os.path.join(dirname1, img)
yield imgpath
seaslee / gist:5274998
Created Mar 30, 2013
select images for codebook generation
View gist:5274998
# -*- coding: utf8 -*-
import csv
import os
def listimgs(metafilepath, imgfilepath, n):
#metafilepath: the path of the meta info of result
#n: the number of a query to generate the codebook
seaslee / gist:5088906
Created Mar 5, 2013
"mkdir -p" python implementation
View gist:5088906
def mkdir_p(path):
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
else: raise
seaslee / normalize.m
Created Dec 4, 2012
A fast and easy way to normalize the matrix
View normalize.m
X = X./( ones(size(X)) * diag(sum(abs(X))) ); %L1-normalization
X = X./( ones(size(X)) * sqrt(diag(diag(X'*X))) ); %L2-normalization
seaslee / computerUniform.m
Created Nov 22, 2012
computer the number of 1->0 and 0->1 transitions in binary string
View computerUniform.m
%use in computer the lbp descriptor
j = bitset(bitshift(i,1,samples),1,bitget(i,samples)) %rotate left; cyclic shift
numt = sum(bitget(bitxor(i,j),1:samples)) %number of 1->0 and
%0->1 transitions
%in binary string
%x is equal to the
%number of 1-bits in
%XOR(x,Rotate left(x))
You can’t perform that action at this time.