A side note: if you are not familiar with terminal, you can find a lot of related resources by googling. I found a video and a web page that may be helpful:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x1 | x2 | x3 | x4 | x5 | |
---|---|---|---|---|---|
18.111123267989484 | 0.9413535720603655 | blue | 21.461557236715407 | 24.564564564564563 | |
20.777182965390768 | 0.9254882601025508 | red | 50.9811019286979 | 42.1021021021021 | |
16.419984794385705 | 0.30857677822338525 | blue | 6.708702983134573 | 30.36036036036036 | |
13.491654081695486 | 0.7397988735986664 | red | 9.37693608222175 | 46.75675675675676 | |
18.94383945783266 | 0.04137615910651404 | green | 25.216686004245922 | 28.85885885885886 | |
6.905085356512098 | 0.8934767495838009 | green | 6.062177604293495 | 23.843843843843842 | |
19.195264404503213 | 0.00404794853091317 | green | 38.934832457935734 | 28.31831831831832 | |
24.136736612950912 | 0.1469761380555349 | red | 67.99375967919259 | 30.99099099099099 | |
21.369679538896957 | 0.5368152632079091 | green | 26.116198203606416 | 32.73273273273273 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add Homebrew `/usr/local/bin` and User `~/bin` to the `$PATH` | |
#PATH=$HOME/bin:$PATH | |
export PATH=/usr/local/bin:$PATH | |
if [ -f $(brew --prefix)/etc/bash_completion ]; then | |
. $(brew --prefix)/etc/bash_completion | |
fi | |
export PATH="/usr/local/opt/sqlite/bin:$PATH" | |
export PATH="/usr/local/opt/openssl/bin:$PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import statsmodels.formula.api as smf | |
from statsmodels.stats.outliers_influence import variance_inflation_factor | |
def get_vif(data): | |
d = {data.columns.values[i]: variance_inflation_factor(data.values, i)\ | |
for i in range(data.shape[1])} | |
vif_series = pd.Series(d) | |
return vif_series |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def get_coef_table(lin_reg): | |
''' lin_reg is a fitted statsmodels regression model | |
Return a dataframe containing coefficients, pvalues, and the confidence intervals | |
''' | |
err_series = lin_reg.params - lin_reg.conf_int()[0] | |
coef_df = pd.DataFrame({'coef': lin_reg.params.values[1:], | |
'ci_err': err_series.values[1:], | |
'pvalue': lin_reg.pvalues.round(4).values[1:], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy as sp | |
import pandas as pd | |
import seaborn as sns | |
from matplotlib import pyplot as plt | |
%matplotlib inline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy import stats | |
def pearsonr_ci(x,y,alpha=0.05): | |
''' calculate Pearson correlation along with the confidence interval using scipy and numpy | |
Parameters | |
---------- | |
x, y : iterable object such as a list or np.array | |
Input for correlation calculation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy as sp | |
def jsd(p, q, base=np.e): | |
''' | |
Implementation of pairwise `jsd` based on | |
https://en.wikipedia.org/wiki/Jensen%E2%80%93Shannon_divergence | |
''' | |
## convert to np.array | |
p, q = np.asarray(p), np.asarray(q) |
This gist will be a place for some interesting data source I found but have no time to collect/think about yet.
__author__ = "Zhiya Zuo"
__email__ = "zhiyazuo@gmail.com"
This section lists datasets to play with or experiment with (e.g., test/evaluate/validate/learn new algorithms.)
This article was moved to https://zhiyzuo.github.io/installation-rattle/ !