Skip to content

Instantly share code, notes, and snippets.

HongleiXie

Block or report user

Report or block HongleiXie

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
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 / cs212_hw1.py
Created Apr 29, 2016
Udasity CS 212 HW1
View cs212_hw1.py
# Udasity CS 212, hw1-1: 7-card stud
#
# -----------------
# User Instructions
#
# Write a function best_hand(hand) that takes a seven
# card hand as input and returns the best possible 5
# card hand. The itertools library has some functions
# that may help you solve this problem.
#
@HongleiXie
HongleiXie / call_analytics.R
Last active Mar 30, 2016
text mining in predictive modelling
View call_analytics.R
#######################################################################
# Author: Honglei Xie
# Purpose: Analysis of call center data including texts
# Source function: maxBAC.R and rocplot.R functions
#######################################################################
library(readxl);
library(pROC);
library(graphics);
library(tm);
library(wordcloud);
@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.