12
返回列表 发新帖
楼主: 雨天愁浪
跳转到指定楼层
上一主题 下一主题
收起左侧

跳槽DS准备打卡贴

🔗
 楼主| 雨天愁浪 2019-5-8 13:15:31 | 只看该作者
全局:
上周看了 Udacity AB testing 的课,确实学到了挺多的,总结一下。

有清晰的控制和试验组,metrics,容易收集data并且时间不长的话,都可以用AB testing。还要考虑user有足够时间适应新feature。不能测试缺少了什么,或者太general的结果。
CTR, CTP. Rate 更适合用于usability test,比如increase button size

需要考虑每个事件是独立的
当N*p_hat>5 & N*(1-p_hat)>5时,可以近似正态分布
Null hypothesis: Pexp – Pcont = 0; Alternative Hypothesis: Pexp-Pcont != 0; calculate P(Pexp=Pcont|H0)
Alternative 可选用双尾检验或单尾检验. 1point 3 acres
2% change is big.

样本量越小,越容易reject,越不能detect true difference,beta越大,alpha低;样本量越大,分布越集中,beta越小,但alpha不变
practical significance level 越大,beta会越小, beta一般取80%,alpha一般取5%

如果数据密度达到了一定程度,无法从数据中识别出个人,则不认为是敏感信息。HIPAA 明确规定时间戳是有可能包含能确定到某个人的信息,所以是可识别至个人的信息。所以,任何与健康相关的时间戳都是敏感信息。
.1point3acres
用多个单独的metrics比用单个Overall Evaluation Criteria/Objective function (OEC)好,因为OEC不能考虑所有情况
如果很难获得数据,或者花费时间太久,则不适合做metrics。
可以用一下方法收集数据
1.        Use External Data: market share data; user survey company; summary level data; published papers
2.        Gather own in-depth data: User Experience Research (most in-depth and intensive, <=10 users, good for brainstorming, can use special equipment, need to validate results); Focus Groups (hundreds of people together, get feedback on hypotheticals, risk of group think); Survey (>1000 users, useful for metrics you cannot directly measure, but user may not give full answers)
3.        Retrospective Analysis: look back logs of users, generating ideas for AB tests and for validating metrics. Can only prove correlation, not casualty
4.        Long-term prospective experiments: run long term test and build models to see what short-term metrics best predict the long-term effects
5.        Human Evaluation: pay professionals to evaluate the website
External data and retrospective analyses are best for validating metrics: the data is usually collected at scale. If you have no idea about what metrics to gather in the first place, more detailed, qualitative, brainstorming type of interactions, such as user experience research studies or focus groups work well.  If you have no way of getting the data, because the interactions aren’t on your site, something like a survey might work well.  If it’s an issue of time to measure, then something like retrospective analyses paired with long-term experiments might work.

Summarized metrics: Sum/count, mean/median/25%/75%/90%percentiles, CTP, CTR, ratio

Spikes/Anomalies: check week-over-week, year-over-year 图表, 把数据按不同组分类,比如按国家. AA testing 可测试 sensitivity, robust, and variability, 寻找潜在的会影响结果的变量. 还可以比较结果,预测variance和计算CI, 也可以将数据排序后直接获得CI。AA testing 做的越多,效果越差。
SE is proportional to sqrt(N) .

做实验步骤:1. Choose subject (unit of diversion); 2. Choose population/sample size; 3. Determine size; 4. Duration/Timing
做关于learning effects, retention,增加user activity等任何需要user 慢慢建立的实验,可以用cohort代替population
需要考虑实验用多少比例的总流量,大的有风险的变化要用小比例,还要考虑其他实验。但一般不要超过几周时间

sanity check: 检查 invariant variables 在实验组和控制组间是相同的
effective size test和sign test
多个metrics时要用Bonforroni correction

这周刷些概率的题目,然后看ML

评分

参与人数 2大米 +2 收起 理由
qxtracy + 1 很有用的信息!
Blanchey218 + 1 赞一个

查看全部评分

回复

使用道具 举报

全局:
和lz背景很像 最近投了几个都是hr轮就拒了 lz能微信交流一下吗 我也在刷题
回复

使用道具 举报

🔗
 楼主| 雨天愁浪 2019-5-10 14:19:43 | 只看该作者
全局:
Lenin 发表于 2019-5-9 12:16
和lz背景很像 最近投了几个都是hr轮就拒了 lz能微信交流一下吗 我也在刷题

我微信chanryduan,欢迎交流
回复

使用道具 举报

🔗
qxtracy 2019-5-10 22:15:04 | 只看该作者
全局:
雨天愁浪 发表于 2019-5-8 13:15
上周看了 Udacity AB testing 的课,确实学到了挺多的,总结一下。. .и

有清晰的控制和试验组,metrics,容 ...

. ----我之前也上过一个AB testing的课 是谷歌开的 我忘记了在哪学的了 当时感觉巨有用
回复

使用道具 举报

🔗
 楼主| 雨天愁浪 2019-5-11 13:19:26 | 只看该作者
全局:
qxtracy 发表于 2019-5-10 22:15
我之前也上过一个AB testing的课 是谷歌开的 我忘记了在哪学的了 当时感觉巨有用

我们上的应该是同一个
回复

使用道具 举报

🔗
qxtracy 2019-5-11 23:19:29 | 只看该作者
全局:
雨天愁浪 发表于 2019-5-11 13:19
我们上的应该是同一个
. Χ
hahah 原来在udacity上 那我再去复习一下 谢谢楼主!
回复

使用道具 举报

🔗
 楼主| 雨天愁浪 2019-5-19 15:20:38 | 只看该作者
全局:
这周刷了些概率题,国内的概率题真是大开眼界,有很多感觉像是智力题。
这周主要是看ML,stanford的CS229 notes特别好,就是作业在piazza上不能看,而且这个学期的notes还没有都放出来。。。现在只看到model selection。
下面总结下看过的ML知识点. From 1point 3acres bbs

Gradient descent 一般指 batch gradient descent在每一步update都要看所有sample. 1point3acres.com
When only one obs: Least Mean Squares (Widrow-Hoff). 每次的Update与error term 成比例
Linear regression 的cost function 是convex ,local optima就是global optima
Stochastic gradient descent(incremental GD): 每一步update只看一个sample。比batch GD快得多,不会converge到minimum,只会在minimum附近徘徊,但足够接近了,常用于sample size很大
Normal equation:   
If we write y as function of x and an error term which captures unmodeled effects or random noise.  , and assume every sample is iid, ε is normally distributed with mean 0, then if we want maximum log likelihood of L(θ), it’s same as minimize mean square.

Locally Weighted Linear Regression (LWR):    weights 取决于training samples距离你想测试的那一点的距离,距离越近,weight越大。τ是bandwidth, 决定了权重根据距离缩小而增大的速度
LWR 是non-parametric algorithm. 总是需要所有的training set来做prediction。相反,Parametric有确定有限的parameters,一旦训练完成,则不再需要training set

If we use   and same stochastic GD rule, it’s a Perceptron Learning Algorithm
Newton method:  ; Newton-Raphson method(multidimension version):  ,    is vector of partial derivatives of l(θ) on θi; H is Hessian matrix where  . .и
Newton比 batch GD快,iteration少得多,但是每次iteration比较慢,因为要求H的逆矩阵,总的来说如果θ dimension不大,Newton快很多。
用Newton求logistic regression 的maximumn log likelihood的方法,叫做Fisher Scoring

Exponential Family Distribution

Bernoulli and Gaussian distribution; The multinomial, the Poisson (for mod-elling count-data; also see the problem set); the gamma and the exponential (for modelling continuous, non-negative random variables, such as time-intervals); the beta and the Dirichlet (for distributions over probabilities);and many more are in exponential family.. 1point 3acres

Generalized Linear Models (GLM), ordinary least squares, logistic regression, softmax regression are all GLM.
For multinominal response variable, canonical response function is also called softmax function:  
Softmax regression extension of logistic regression, use GLM to do multi-classification :    .--

Gussian Discriminative Analysis model 是generative learning algorithm. 他假设X是multivariate Gussian distribution, y是二项分类。他和logistic regression一样,只是多假设了multivariate Gussian,假设更严格。如果假设正确,GDA更efficient,更fit model。当sample size大的时候,GDA总是更好。如果假设错误,logistic更robust,less sensitive to wrong assumption. E.g. If x|y= 0~Poisson(λ0), and x|y= 1~Poisson(λ1), then p(y|x) will be logistic.  Logistic regression will also work well on Poisson data like this.
..
Naïve Bayes是classification 算法,要求x都是discrete. 如果x is continuous, 可以把它分成几个区间而分类。如果continuous x 不是很follow multivariate normal distribution, 分区间用Naïve Bayes比GDA结果好。NB大多情况下都不错
. ----
Neural Network 由 neuron组成,只要提供input layer和output layer, NN 会自己算出 hidden units/hidden layer。所以NN是black box,中间的hidden feature很难让人类理解。NN自己学习hidden layer的过程叫end-to-end learning. Fully connected layer指上一层每个变量和这一层每个变量都相关
NN的每一步由两个步骤组成,第一步是上一步units的线性组合求出z,第二步是求z的non-linear结果即a。所有过程要对每个sample x(i)进行i=1,…n. a[0]=x
-baidu 1point3acres
Activation function 一般是non-linear function,可以是   
ReLU is Rectified Linear Unit。如果activation function是linear的,linear function of linear function is a linear function,那就只是相当于跑一个linear regression,失去NN的意义
For loops对NN来说太慢了infeasible,要用vectorizaiton和matrix algebra才快.
W,b 的初始值不能为0,否则gradient一直相同,所有layer都一样,无法训练,应该随机选一些小值,比如N(0,0.1)。所有W,b都一样的值也不行,每次同一层的neuron学习的东西都一样,造成symmetry。更好的办法是Xavier/He initialization   n[l]is the number of neurons in layer l..--
确定初始值后,求出y_hat, cost, 然后根据 gradient descent update 每个parameter。Update倒着来节省计算,从output layer往后一层一层update W,b.
batch GD cost function more accurate but more noise than stochastic GD. Batch GD 很难为所有sample计算activation。
实际中常用Mini-batch GD.  ,with momentum technique.

Cost function J 可以加regularization  . check 1point3acres for more.
.google  и
Has bias = underfit = model too simple; has variance = overfit = model too complex;large noise 也会导致MSE大 ..
Empirical risk = training error. Empirical risk minimization (ERM). check 1point3acres for more.
Dropout,data augmentation,adding more data 也是regularization

Hold-out cross validation(simple cross validation) 在选定model之后可以用整个dataset再train一遍,除非model对initiation比较敏感。SCV一般选25%-35%数据,比较浪费data。K-fold cross validation,k一般选10. 如果k=N,则为leave-one-out cross validation.
Wrapper model feature selection 包括forward search and backward search. Computational expensive. O(n2).
Filter feature selection,根据每个feature多informative来评分,选分高的几个,可以用cross validation来确定选多少个feature。评分标准是feature和y的correlation,或者mutual information; 对discrete features , 测量p(xi, y) 和p(xi)p(y) pdf的不同。.1point3acres

也可以用Bayesian statistics 克服overfitting。假设prior distribution p(θ), posterior distribution is  , p(y(i)|x(i), θ)根据所选model计算,经常要算积分,计算量太大,常用maximum a posteriori 近似 ,这就是maximum likelihood estimate, 只是p(θ)是prior。实际中,常假设θ~ N(0, τ2I),用prior使θMAP更小,所以修正了overfitting,所以Bayesian logistic regression在text classification表现很好。. From 1point 3acres bbs

Error analysis就是把整个系统分成几个部分,和各自的perfect performance作比较,确认哪部分改进空间大,或者是去看错误预测的数据的共同点,确认哪部分需要优化。Ablative analysis是一个一个拿掉feature,看performance怎么变化来确认哪个feature重要

下周继续看完stanford ML然后开始做一些Kaggle project练手,并且开始投简历了. 1point 3acres

补充内容 (2019-5-20 15:19):.1point3acres
好多公式都是图片,好像都没搞上去。。
回复

使用道具 举报

🔗
 楼主| 雨天愁浪 2019-5-29 11:52:37 | 只看该作者
全局:
这周看完了Stanford 课程,上网刷了些常见题目,mL就先到这里了。下周开始投简历,做kaggle,为take home练手写模板。.1point3acres

ML剩余部分总结:
lasso path: 逐渐加大regularize parameter,训练模型,看什么时候feature开始起作用 ..

Binary classification有两类model:1. 直接output分类(KNN, decision tree),2. Output score(margin-SVM, probability-logistic regression, neural network).需要确定分类标准.
rank view, 对error analysis有用,从最高的negative 或最低的positive sample开始。prevalance =  ,决定class imbalance. 如果太多sample,就用class-wise histogram-baidu 1point3acres
Confusion matrix. False Positive = Type 1 error, True Negative = Type 2 error. Accuracy = 多少比例预测正确。Precision(Positive Prediction Value, PPV) = quality of Positive prediction. Recall(sensitivity) = what fraction of positive is picked out. Negative Recall (Specificity) = what fraction of negatives is picked out? F1 score = Harmonic mean of Precision and Recall. G score = Geometric mean of Precision and Recall. Precision和specificity有一点正相关,sensitivity和specificity负相关,precision和recall负相关。ROC curve是y=specificity和x=sensitivity的曲线,AUC(area under curve)= C-statistics(concordance score)表明rank score的好坏。对角线为随机猜。Precision recall curve. Area under PRC = Average Precision, the expected precision by randomly picking threshold.
. 1point 3 acres
Log-loss = p(x)*y + (1-p(x))*(1-y), rewards confident correct predictions and heavily penalizes confident wrong predictions.
If prevalence <5%, high imbalanced. 选择metrics的好坏Accuracy  <<  AUROC  <<  AUPRC。对search engine results, grammar correction等问题,重视FP,要保持高precision同事optimize recall。对medical test,重视FN,要保持高recall,optimize precision。
Multi-class. Confusion matrix is NxN,除了accurcy,大多数metrics都是 1 vs many。Imbalance很常见

high variance fix: 获得更多数据,加feature,
high bias fix: 减feature, email header feature。
optimization algo有问题: GD多跑几遍iteration,用不同方法,SGD,GD,Newton。。。optimization objective fix: hyper-parameter,用不同的regularizer, 用不同的model
如果test error太大, 如果train error= test error ,需要加feature;如果train error < test error, overfitting. 需要Regularize, 用simple model。如果trainer error来回摇摆巨大, you optimization algorithm需要改进.1point3acres

k-means 保证会converge,但可能会到local optima。可以用不同的initial values跑k-means很多次,选最终结果k-mean最小的。
k-means初始值 uniformly chosen, 没效率,K-means++ 改进了初始值选取, O(log k). check 1point3acres for more.
1a. Take one centerc1, chosen uniformly at random from X.
1b. Take a new center ci, choosing x∈X with probability D(x)2Px∈XD(x)
2.1c. Repeat Step 1b. until we have taken k centers altogether.
2-4. Proceed as with the standard k-means algorithm.. 1point 3 acres

Mixture of Gaussians用来做clustering. 假设z为某一cluster的中心,z~Multinomial(φ) (φj是z为第j个cluster的中心的概率),对每一个sample x(i), 都在某个cluster里,都有对应的z(i), 假设(x(i)|z(i)=j)~ N(μj,Σj).这里z是假设的unobeserved变量。可以用EM/ Estimation-Maximization求, E-step soft guess z,M-step根据猜的z求parameter的最优解。和K-means很像,也保证converge,也可能陷入local optima,需要多试几个初始值,但EM不做hard cluster assignment,而用soft guess wj,只求分到某个cluster的概率   .--
repeat until converge

Principal Component Analysis, 要先标准化,然后投影到某vector,u上而使variation基本不变/尽可能大,因为已经过标准化,就是要x在u上投影离远点尽量远,距离为xTu.就是要maximize  ,就是covariance matrix。所以选取Σ的top k eigenvalue为u1,u2…uk即可,就是principal component.PCA有助于数据可视化;在train model前做PCA可以降低计算量,并且减少overfitting;还可以减少noise
. check 1point3acres for more.
Esemble model的好处:Averaging out biases. Reducing the variance. Avoiding overfitting.
. Waral dи,
Reinforcement learning 不给正确与否,而是给reward function,好的就reward,bad就punish。应用:autonomous helicopter flight, robot legged locomotion, cell-phone networkrouting, marketing strategy selection, factory control, and efficient web-page indexing.. check 1point3acres for more.
Markov decision processes (MDP)

Entropy描述混乱程度,在decision tree中测量分类impurity的程度。Information gain = Entropy(x) — ([weighted average] * entropy(children for feature)), 每次分类按能使information gain 最大的feature 来分类。Gini impurity 是指stop division when we have x number of fewer number of elements left
Decision tree parameter tuning: minimum sample split(某一组数据量小于这个值则不再继续分类);criterion(分类标准是gini还是entropy)

KNN 有三种方法计算距离,1.直接算O[DN2],2. K-D Tree,如果A离B很远,B离C很近,那么不计算也知道A离C很远 O[D N *log(N)],3. Ball Tree, 假设data在高维空间并建立nested hyper sphere. O[Dlog(N)]. 数据量小dimention小,直接算。对小dimention高分散型数据,KD tree比ball tree好。大dimention大数据量用ball tree。
KNN parameters:n_neighbors, algorithm({‘auto’, ‘ball_tree’, ‘kd_tree’, ‘brute’})

Random Forest 取majority vote,也可以根据每个树的error rate加权求majority vote,error小的权大。
RF parameters:n_estimators(tree的数量),criterion(decision tree的algorithm),min_sample_split (每组数据量达到多小时不再继续分类)

Adaboost 每次取不同的training dataset来训练,根据每个model的accuracy加权求最终结果。选Training dataset不是random,上一个model中misclassified data points会获得更大的权重,更可能被选上。如果accuracy为50%,Model的权重是0,如果小于50%,权重为负。. 1point 3acres
回复

使用道具 举报

🔗
AmyFBKX 2019-6-5 23:36:03 | 只看该作者
全局:
谢谢楼主的分享
回复

使用道具 举报

🔗
 楼主| 雨天愁浪 2020-2-9 14:51:41 | 只看该作者
全局:
更新下帖子,为这段找工作经历画个句号,6月七月基本都在刷面经和面试了,8月接了亚麻的offer。现在已经入职4个月了。感谢地里的资料
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表