Sunday, June 30, 2019

iTerm2

https://mp.weixin.qq.com/s/zbFQPdZ4Qh9fBrGP8C09Pg

Install Homebrew and Homebrew Cask

brew tap caskroom/cask

Install iTerm2

brew cask install iterm2

选择Iterm菜单 > Preferences > Profiles,
选择你在使用的 Profile(默认是Default),
在General标签页中的Working Directory部分中
选择Reuse previous seesion's directory。

iTerms2>Preferences>Profiles>Colors Tab
Open the Color Presets...>drop-down in the bottom right corner
Select Import... from the list
Select the Dracular.itermcolors file
Select the Dracular form Color Presets...

brew install zsh
echo $SHELL
which zsh

chsh -s /usr/bin/zsh
install Oh My Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Plugin

git、z 、zsh-autosuggestions、zsh-syntax-highlighting


Control的常用组合键


移动类 :

Control-F 前进光标 (效果同右方向键)

Control-B 后退光标(效果同左方向键)

Control-F 前进光标 (效果同右方向键)

Control-B 后退光标(效果同左方向键)

Control-P 光标上移(效果同上方向键)

Control-N 光标下移(效果同下方向键)

Control-A 光标移动到行首

Control-E 光标移动到行尾



删除类:

Control-D 删除光标后面的一个字符

Control-H 删除光标前面的一个字符

Control-K 删除当前行光标以后的所有字符

Control-W 删除光标前的一个单词

Control-U 删除当前行的所有字符


其他类:

Control-T 交换光标两边的字符,

Control-L 清屏(仅适用于终端下)


Thursday, May 16, 2019

Hacker News Metrics

Effects of gravity (G) and time (T)
Gravity and time have a significant impact on the score of an item. Generally these things hold true:
  • the score decreases as T increases, meaning that older items will get lower and lower scores
  • the score decreases much faster for older items if gravity is increased
To see this visually we can plot the algorithm to Wolfram Alpha.

How score is behaving over time
As you can see the score decreases a lot as time goes by, for example a 24 hour old item will have a very low score regardless of how many votes it got.

How gravity parameter behaves
As you can see by the graph the score decreases a lot faster the larger the gravity is.

def calculate_score(votes, item_hour_age, gravity=1.8):
    return (votes - 1) / pow((item_hour_age+2), gravity)

Saturday, April 20, 2019

A/B Test

https://www.linkedin.com/pulse/summary-udacity-ab-testing-course-kelly-yuwei-peng/

Can we test everything?

No. there are situations we cannot analyze through A/B test.
For example, if you are adding a new experience and want to test it, old users may resist against the new version, or old users may all go for the new experience, then the test set has everything or nothing.
For example, a home rental webseit test its referral effect, but a customer may not return even in six months, it is very hard to measure through A/B testing. If this is the case, what shall we do?
- Analyze the user activity logs
- Conduct retrospective analysis
- Conduct user experience research
- Focus groups and surveys
- Human evaluation

How to do an A/B test?
1, Choose and characterize metrics to evaluate your experience, what do you care about? How do you want to measure the effect?

2. Choose significant level, statistical power and practical level you really want to launch the change if the test is statistically significant

3. Calculate required sample size

4. Take sample for control/treatment groups and run the test

5. Analyze the results and draw valid conclusions


Sunday, March 3, 2019

Python direct sampling

## Direct Sampling
import numpy as np

def X1_sample(p=0.35):
    return np.random.binomial(1, p)

def X2_sample(p=0.65):
    return np.random.binomial(1, p)

def X3_sample(x1, x2, p1=0.75, p2=0.4):
    if x1 == 1 and x2 == 1:
        return np.random.binomial(1, p1)
    else:
        return np.random.binomial(1, p2)
   
def X4_sample(x3, p1=0.65, p2=0.5):
    if x3 == 1:
        return np.random.binomial(1, p1)
    else:
        return np.random.binomial(1, p2)

N = 4
Nsamples = 5000

S = np.zeros((N, Nsamples))
Fsamples = {}

for t in range(Nsamples):
    x1 = X1_sample()
    x2 = X2_sample()
    x3 = X3_sample(x1, x2)
    x4 = X4_sample(x3)
   
    sample = (x1, x2, x3, x4)
   
    if sample in Fsamples:
        Fsamples[sample] += 1
    else:
        Fsamples[sample] = 1

samples = np.array(list(Fsamples.keys()), dtype=np.bool_)
probabilities = np.array(list(Fsamples.values()), dtype=np.float64) / Nsamples

for i in range(len(samples)):
    print('P{} = {}'.format(samples[i], probabilities[i]))

p4t = np.argwhere(samples[:, 3]==True)
print(np.sum(probabilities[p4t]))

Tuesday, February 26, 2019

Jupyter lab

brew info python

brew install python3

pip3 install virtualenv

virtualenv -p python3 /Users/ling/Desktop/Git/Deep-Learning

source bin/activate

python3 -m pip install -U jupyter matplotlib numpy pandas scipy scikit-learn
Collecting jupyter

python3 -c "import jupyter, matplotlib, numpy, pandas, scipy, sklearn"

https://blog.jupyter.org/jupyterlab-is-ready-for-users-5a6f039b8906

conda install -c conda-forge jupyterlab

-- install R Jupyter lab

pip install rpy2

%load_ext rpy2.ipython
%R require(ggplot2)

-- install homebrew
(base) new-host-2:~ ling$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercont

-- install jdk
brew cast install java

-- install
iTerms2>Preferences>Profiles>Colors Tab
Open the Color Presets...>drop-down in the bottom right corner
Select Import... from the list
Select the Dracular.itermcolors file
Select the Dracular form Color Presets...