Skip to content

Instantly share code, notes, and snippets.

View regex_email_dates.py
import re
email = 'Email: 87hello9__3w4-o.rld@comp.nus.edu.sg where hello_world=wenzy'
out = re.search(r"([a-zA-Z0-9_\.+-]+)@([a-zA-Z0-9-]+)\.([a-zA-Z0-9-\.]+)", email)
# find patterns: all chars including _ . -
print(out.group(0))
print(out.group(1))
print(out.group(2))
print(out.group(3))
View Ploty-example-2.R
###############################################################################
## Plotly example
## Plots with customized annotations
## Author: Honglei Xie
###############################################################################
library(plotly);
library(tidyr);
df_wide <- data.frame(month = seq(1:100), trough = rnorm(1:100, mean = 1), peak = rnorm(1:100, mean = 3));
View Plotly-example-1.R
###############################################################################
## Plotly example
## Plots highlighted the trough and peak by rectangles
## Author: Honglei Xie
###############################################################################
library(plotly);
library(tidyr);
df <- data.frame(resp = rnorm(100), month = seq(1:100));
@HongleiXie
HongleiXie / mh_problem.py
Last active Apr 30, 2016
Harvard CS109 HW0 -- MH Probelm Simulation
View mh_problem.py
# -*- coding: utf-8 -*-
"""
MH Probelm Simulation
@author: Honglei Xie
TODO: Add plots
"""
import numpy as np # imports a fast numerical programming library
import scipy as sp #imports stats functions, amongst other things
import matplotlib as mpl # this actually imports matplotlib
@HongleiXie
HongleiXie / mcmc.m
Created Jan 12, 2016
Matlab program to implement MCMC to estimate parameters in ordinary logistic regression
View mcmc.m
% logit_mcmc2.m file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Implement MCMC to fit logistic regression in a real data set
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function w_est = logit_mcmc2(w_init,data,labels,max_iter,lambda)
%assume data == features by samples
%w_init w_init == (features+1) by 1
%labels == samples by 1
w_est = [];
features = size(data,1);
You can’t perform that action at this time.