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
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))
plot(pt)
library(forecast)
fit <- auto.arima(pt)
forecast(fit, h=2)
View sigir 13'.R
library(tm)
## read from txt file
path = 'd:/sigir_full.txt'
f <- file(path,open='rt')
con <- readLines(f)
close(f)
## get the tile from the content
paperTitles <- con[grepl("^Title: ",con)]
@seaslee
seaslee / r_resources
Last active Dec 24, 2015
R resources
View r_resources
####入门
1. [John Cook写的不错的关于R语言的一个基本介绍](http://www.johndcook.com/R_language_for_programmers.html)
2. [R 官方的入门手册](http://www.r-project.org/)
3. [电子书“The R Inferno”]
####ggplot
1. [Edwen Chen写的一个不错的入门,很简单的qplot的用法]http://blog.echen.me/2012/01/17/quick-introduction-to-ggplot2/)
2. [ggplot2的文档](http://docs.ggplot2.org/current/)
####规范
1. [Google's R Style Guide](http://google-styleguide.googlecode.com/svn/trunk/Rguide.xml#filenames)
2. [另一个简洁的R编码规范,ggplot2的作者](http://stat405.had.co.nz/r-style.html)
@seaslee
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 = data_digits.data
target = data_digits.target
train_ratio = 0.8
data_num = data.shape[0]
@seaslee
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 = data_boston.data
target = data_boston.target
train_ratio = 0.8
@seaslee
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
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
seaslee / gist:5088906
Created Mar 5, 2013
"mkdir -p" python implementation
View gist:5088906
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise
@seaslee
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
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.