DS准备详细贴 - sophiekeke/casestudy GitHub Wiki
https://www.1point3acres.com/bbs/thread-469408-1-1.html
概括性质面经 + 对应资料
这一趴就是按内容来划分的面试问答和资料准备了。我会尽量回忆一些被问过的高频问题以及挂了之后的自己找的学习资源和资料(没错,是挂了之后(╯□╰ ))。由于 intern 和 fulltime 的面试内容其实差别并不大,所以这里不做刻意区分,只以 title 来划分一般的面试内容:
Data Scientist (偏算法)
介绍: 一般意义上的 Data Scientist,需要承担研究、优化算法或支持组内其他与数据相关的业务。
面试内容:
- Machine learning 算法(较细致和具体)
- 统计
- Online python coding test
- SQL(不多)
Data Scientist (偏产品)
介绍: 以 FB 的 DS-analytics 岗位为代表的产品分析方向的 Data Scientist,介乎于 DA 和硬核 DS 之间的一个职位。
面试内容:
- Machine learning 算法(中等难度)
- 统计
- 产品 case 分析
- Online SQL/Python coding test
- A/B testing
Data Analyst
介绍: 和上一个 DS 比较相似,但更加少了些算法的问题,多了些具体情景的 SQL 的 Online coding test 和 case。
面试内容:
- 简单的 Machine learning 算法问答(有的没有)
- 统计
- 必考 SQL
- 产品 case 分析
- Product sense
- A/B testing
总结
所以总结一下,大致有以下内容需要认真准备:
- Machine Learning
- 统计、概率与 A/B testing
- Online coding (Python + R)
- SQL
- Product sense
接下来我逐个来说,最后再做个大总结。
Machine Learning
1. 常见面试问题
- What is overfitting? / Please briefly describe what is bias vs. variance.
- How do you overcome overfitting? Please list 3-5 practical experience. / What is 'Dimension Curse'? How to prevent?
- Please briefly describe the Random Forest classifier. How did it work? Any pros and cons in practical implementation?
- Please describe the difference between GBM tree model and Random Forest.
- What is SVM? What parameters you will need to tune during model training? How is different kernel changing the classification result?
- Briefly rephrase PCA in your own way. How does it work? And tell some goods and bads about it.
- Why doesn't logistic regression use R²?
- When will you use L1 regularization compared to L2?
- List out at least 4 metrics you will use to evaluate model performance and tell the advantage for each of them. (F1 score, ROC curve, recall, etc.)
- What would you do if you have > 30% missing value in an important field before building the model?
以上是我整理出来的被问到的差不多 Top 10 的问题,至于回答的深度可以因人而异或者因岗位难度而已,简单的讲一讲概念,难的可能会发散到深一些的矩阵计算和算法原理。
- 如果以上的问题你还有都不懂的问题,那可能需要多下一番功夫了;
- 如果你大致能听懂问题,但是静下心来问自己,然后让自己回答一下,哪怕是有一点不清楚,我也建议:去花一个下午坐在那里找所有相关的资料,落到文字层面的东西,整成一个小专题,有段落摘抄有笔记有链接。然后在理解之后再确保自己可以非常简明扼要的在电面中用英语流利表达。这很重要,懂,和能让别人觉得你懂是两回事。所以面试前顺口条也是很推荐的(打辩论的职业病,会心里面准备一篇小的短稿件方便做答)。
我自己已经整理了大多部分的内容,但是我不打算发到平台上来,因为直接给鱼基本上就不会学拿杆了,而不拿杆的基本上面试都会被摁在地上摩擦,因为很容易露馅。如果哪位同学有非常具体的问题想问的话,可以留言或者顶大米,我会定期回复的。
2. 相关资料准备
- Coursera 上 Andrew Ng 的 Machine Learning 课程(课程链接)
- 算得上考古级别的课程了,内容有些老旧但是很经典,很适合商学院 BA 专业的从 0 开始补齐 ML 的背景知识。
- 15 hours of expert ML videos(视频链接)
- 我没看完,只选了自己想看的了解了一些。
- 《ISLR》(免费链接直通车)
- 入门神书不解释,可惜我第一本看的不是它,所以后来大多当作工具书用了,需要的时候才查阅一下。
- 《Practical Statistics for Data Scientists: 50 Essential Concepts》
- 很实用的一本书,专讲一些细小知识,不深但是读完会感觉多了些对 ML 的理解。
5. 书和课说完了,肯定得推一下 Medium 了
尤其是 Towards Data Science 专题,相信熟悉的人都知道里面的文章有多么实用。我比较喜欢的是里面某个作者写的 Machine Learning 101(🔗 medium.com)这个小专题,非常浅显易懂,适合初学者用具象的方式理解抽象算法。
6. StackOverflow
StackOverflow 自然也是不能漏掉的,学 data 或者编程总会遇到很细枝末节的问题,这些一般文章里没有,所以就需要求助社群的力量了。
7. 最后的最后,务必亲手写两三个 project
哪怕是调包写,也比没写过强,不然面试也会很尴尬的。
统计,概率与 A/B testing
1. 常见面试问题
- What is p-value? What is confidence interval? Explain them to a product manager or non-technical person. (很明显人家不想让你回答: 画个正态分布然后两边各卡5% ( ̄▽ ̄)" )
- How do you understand the "Power" of a statistical test?
- If a distribution is right-skewed, what's the relationship between median, mode, and mean?
- When do you use T-test instead of Z-test? List some differences between these two.
- Dice problem-1: How will you test if a coin is fair or not? How will you design the process (有时会要求编程实现)? What test would you use?
- Dice problem-2: How to simulate a fair coin with one unfair coin?
- 3 door questions. (自行 google 吧,经典题之一)
- Bayes Questions: Tom takes a cancer test and the test is advertised as being 99% accurate: if you have cancer you will test positive 99% of the time, and if you don't have cancer, you will test negative 99% of the time. If 1% of all people have cancer and Tom tests positive, what is the probability that Tom has the disease? (非常经典的 cancer screen 题,做会这一道,其他都没问题了)
- How do you calculate the sample size for an A/B testing?
- If after running an A/B testing you find the fact that the desired metric (i.e., Click Through Rate) is going up while another metric is decreasing (i.e., Clicks). How would you make a decision?
- Now assuming you have an A/B testing result reflecting your test result is kind of negative (i.e., p-value ≈ 20%). How will you communicate with the product manager?
- If given the above 20% p-value, the product manager still decides to launch this new feature, how would you claim your suggestions and alerts?
2. 相关资料准备
- A/B testing 的资料首推的是 Udacity 上免费的 A/B testing (by Google) 的课
- 同学们的评价都还不错,很适合全面的了解一下 A/B testing。
- 其余的 A/B testing 的内容大多来自于 Medium 上的好文
- 原因是 A/B testing 是一个要和实际的业界应用场景结合的东西,只知道原理和基本不懂没啥区别。所以要去看一看业界的人写的关于 A/B testing 的文章,只有带着案例看,才能懂面试中的问题都应该怎么样回答。
- 如果有在工作的学长姐、长辈等等,一定要不吝啬的问 A/B 方面的问题
- 他们说个十几二十分钟,能省下你很多时间去到处扒资料,原因同上条不解释。
- Stats 的话,有一个非常快的捡起一些统计学基础的内容是 Coursera 上的 intro to stats and prob 课程
- 很快,一个下午就可以看完。
- 我要推一波我用的很多的 Udemy 的课程了
- 他们家经常打折,我赶 9 刀一节课的时候买的,Data Science Career Guide - Interview Preparation,还是很不错的。课程轻量,学起来无压力。
- 概率题对大多数中国学生来说都没问题
- 都是高中学过的,稍加捡起就行。Udemy 的课就可以帮你捡起来。
Online coding (Python + R)
1. 我遇到的面试问题(这个考的五花八门,所以不敢说是最常见的)
- Report the biggest sum of a continuous 3 numbers in a list? With the related index?
- Dynamic programming problem: Now you have 5 types of coins (1, 2, 3, 5, 8) and a total sum (a big number, say 589). How many different combinations of coins can you find to reach this total sum?
- Please write a function to reverse the key and value in a dictionary. When you have repeated values, please only keep the first key as the new value.
- Similarly to the "gather" and "spread" functions in the tidyr package, write a one by yourself and test it using XXX dataset.
- Given a log file with rows featuring a date, a number, and then a string of names, parse the log file and return the count of unique names aggregated by month. (我的不是这个原题,但是意思很像)
- Using python to calculate a 30-day rolling profit. (大致就是要用 python 写一个 rolling window)
还有更多的我就不一一列出来了。写代码真是没什么捷径好走,我的建议是平时自己遇到问题就多搜一搜,然后能手写的时候尝试手写不要调包。久而久之就熟练了。
2. 相关资料准备
- 算法自然是逃不过 Leetcode 了
- 虽然 CS 的同学用的比较多,但是想申 DS 的话我觉得 Easy 和 Medium 水平的刷一刷有利无害。
- 讲算法的,我只看过 YouTube 上的一些视频
- 觉得非常不错,但是也只是试了试,有兴趣的同学可以多研究研究。
- 划重点,大家在面 online coding 的轮次之前,千万记得去 Glassdoor 上看一下会不会有人分享一些题目
- 遇不到原题权当练手,遇到原题了的话简直不要太爽。(glassdoor -> a company -> interview question -> title)
- 熟悉 R
- 我是和同学一起在上学期间刷完了 Datacamp 上所有的 R 的课程,入门很合适。
- 熟悉 Python
- Datacamp 刷了一些,并没刷完。我推荐的是 Udemy 家的两个课:Data Analysis with Pandas and Python 和 Python for Data Science and Machine Learning Bootcamp。非常简单易懂,上手率非常高。
- 一个好网站,同学推荐的:real python
- 手上如果还有书就更好了,甩给你们一些选项:Best Python Books
SQL
这一部分可能是我找工作的时候最有启发的部分了。因为我们的学校项目没有很重视 SQL,我个人又觉得 SQL 很简单所以一直没怎么上心。后来挂了几次之后才发现其实 SQL 考的难起来也是挺难的。所以写一些心得分享给大家。
1. 常见面试问题
- What is the difference between union and union all? where and having?
- Table [in_app_purchase]:
- uid: unique user id.
- timestamp: specific timestamp detailed to seconds.
- purchase amount: the amount of a one-time purchase.
- This is a table containing in-app purchase data. A certain user could have multiple purchases on the same day.
- Question 1: List out the top 3 names of the users who have the most purchase amount on '2018-01-01'
- Question 2: Sort the table by timestamp for each user. Create a new column named "cum amount" which calculates the cumulative amount of a certain user of purchase on the same day.
- Question 3: For each day, calculate the growth rate of purchase amount compared to the previous day. if no result for a previous day, show 'Null'.
- Question 4: For each day, calculate a 30-day rolling average purchase amount.
- Table [Friending]:
- time = timestamp of the action
- date = human-readable timestamp, i.e., 20108-01-01
- action = {'send', 'accept'}
- actor_id = uid of the person pressing the button to take the action
- target_id = uid of another person who is involved in the action
- Question: What was the friend request acceptance rate for requests sent out on 2018-01-01?
因为时间关系我没有再陈列更多,但最典型的题目我已经写出来了。
- 题目二涵盖了简单的 aggregate 问题,cumulative 问题,rolling window 问题等等。搞定这些,其他的都只是一些简单变形。
- 题目三涵盖了 self-join,并且有一些 tricky 的大于等于号的应用,有兴趣可以在地里查一下 Facebook 面经的解答。
- 其他的题目无非是多了一些 table,join 麻烦一些或者加了一些 case when,难度都不会有太大的变化。做好几个经典题,然后自己整理好就可以以不变应万变了。
2. 相关资料准备
- 扫盲网站:SQL ZOO 和 W3schools,非常实用,适合翻阅。
- 两个 Udemy 的 SQL 课
- 我女朋友用的,一周时间几乎 0 基础跟下来,进步非常快:SQL - MySQL for Data Analytics and Business Intelligence 和 The Ultimate MySQL Bootcamp。
- 刷题
- Leetcode 上有一些题,可以做一下。还有好心人直接做了个整理,在这里:summary of sql in leetcode。
- Hackerrank 上的题自然是要全刷光的,因为难度非常简单,快的话一两天也许就做完了。
- 更多网站: 18 best sql online learning resources
- 建议自己下载一个 MySQL 装到电脑上
- 模拟真实的 SQL 环境来学习。
- MySQL 里关于 Windows function 和 frame clause 的教程:
- Windows function ,Frame Clause。这个非常重要,windows function 可以说是 SQL 面试里的大杀器,非常节省时间而且思路清晰。
- 建议也学会用 WITH common_table_expression
- 可以让你的 SQL 看起来非常整洁和容易理解。
- 最最重要的来了:
- 如果你觉得刷完题或者学完以上的内容就万事大吉了,那还真的不是。我一开始也有这样的误区。实际上刷完 Hackerrank 也并不能帮你很快的做出我给的例题。
- 实际上,对于 metrics 或者 product 的了解能够帮助你很好的准备 SQL 面试,因为所有的 SQL 面试都是围绕着与 business 相关的 metrics而展开的。
- 举例而言,游戏公司一定会考 DAU(daily active user)或者 purchase rate, Facebook 就会是 friend request 相关的,以此类推。所以熟悉你申请公司的业务再针对性准备 SQL,一定会事半功倍。
Product Sense
1. 常见面试问题
- Today you immediately notice that our app's new users are doubled. What could be the reason? Do you think it's good or not?
- If we have an app with in-app purchase, name at least 4 metrics you would like to monitor in your dashboard.
- If you are running an A/B testing and find that the result is very positive, thus you decide to launch it. In the first 2 weeks, the performance of our website is very positive. However, with time flying by, all metrics seem to go back to normal. How will you explain this result?
- Assume we are Facebook and we would like to add a new 'love' button. Should we do this?
- We are running 30 tests at the same time, trying different versions of our home page. In only one case test wins against the old home page. P-value is 0.04. Would you make the change?
- If after running an A/B testing you find the fact that the desired metric (i.e., Click Through Rate) is going up while another metric is decreasing (i.e., Clicks). How would you make a decision?
- Assume that you are assigned to estimate the LTV (lifetime value) of our game app player. What kind of metrics would you like to calculate so as to make a good prediction? Assume that you already collect all that you want. How would you make this prediction/estimation?
- If you got a chance to add on new features for our app to increase our profit within a very short term. What will you do?
大概就是以上的这些问题了。你可以发现的是,大多是围绕着 metrics 和如何提高 product performance 来展开的。说实话这些对于 new grads 来说非常不友好,因为没有工作经验。我也是阅读了很多的资料之后才掌握了其中的一些门道。
2. 相关资料准备
这里看过的资料太杂了,很多都是零星的网站未能保存下来。能系统整理的不多,我就尽量以经验的方式分享给大家。基本上你要能够像一个 product manager 一样思考问题。
- Product School(https://www.productschool.com/)
- 貌似是各个湾区的 tech 公司的 DS 或 PM 大佬们来分享一些案例和学习经验。我没有买过课程但是看过 YouTube 上的免费视频,非常受益。因为 product 的事情就是在和真正做产品的人的交流中一点一点积累来的。
- Metrics
- 一个关于 Game metrics 的汇总(19 Metrics Every Mobile Game Needs to Track),也有一定的适用性可以扩展到其他 mobile app 上。
- Critical Metrics Every Product Manager Must Track
- A/B Testing
- A Collection of Data Science Takehome Challenges
- 因为版权原因不能 share,但这个真的是非常棒的资源,可以让你有机会解决很多实际的 DS 问题,并且也和 product 有关。如果你周围有朋友能拿到这个资源或者你愿意买的话,非常强烈推荐。能让你对 DS 的日常工作内容有一个本质理解上的飞跃。
- 一些个人想法
- 大多的产品问题都是围绕着产品的 metrics 或运营中遇到的问题展开的。如果针对互联网行业来说,一个典型的产品要从推出后经历以下阶段:user acquisition -> user engagement/retention -> monetization。
- 讲一个异曲同工的事件来帮助理解吧。了解头条系公司的都知道,公司内有一个流水线作业的产品工厂模式。他们只有三个最核心的职能部门:技术、user growth 和商业化。技术是保障了整体的运营,所以在整体的产品很稳定之后,就要看一下用户的留存率。如果发现用户的留存率(retention)或使用率(engagement)非常高,则进入 user growth 的推动环节,大批量的 marketing 来拉动新的用户增长(user acquisition)。最后把商业化(广告等)的内容接入产品,迅速变现。虽然顺序和我说的不太一样,但是实际上就是在这三个部分对一个产品进行不断的迭代。所以 metrics 也离不开这三个部分。user acquisition 讲求新用户注册率,user engagement 讲求 DAU(日活量),monetization 讲求 LTV 和 ARPDAU(Average Revenue Per Daily Active User)等等。逐渐加深对互联网产品的理解,就能更好地应对 metrics 的问题。面试中 metrics 的问题,本质上一切都是为了产品迭代和用户增长以及变现。
- 关于产品中被问到的 A/B testing 的问题,很多是面试官为了考察你是否能针对特定的情况来分析 A/B testing 的结果。只看 P-value 是非常学生的思维,具体情况中的 A/B testing 是要从一开始的 new feature 的想法到后来设计整体的实验再到分析结果再到最后给建议的一整个流程。面试官想要的是一个批判思维,需要你对每一个步骤都扣得非常细致,以此来确保实验和你的结论之间没有断层。
个人心得
呼....终于写完了...写了整整两天。不得不吐槽一句地里这个发帖的东西是真的不好用,动不动就草稿消失不见了,不然也不至于写这么久。
写这个初衷是为了 share 一些想法给周围的朋友,帮助他们也能拿到心仪的 offer。东西有些多,但是不希望吓到大家,只是尽可能地把自己用过的资源和材料都分享出来,也贴上了链接,方便大家取用。基本上我把所有的学习过程和资源都已经分享给大家了,除了自己的笔记之外。不 share 的理由我已经在前面写过了~希望大家能善用这些资源自己做总结,会很有收获。
如果对于面试的问题有自己的回答,可以发到留言区,我会定期查看和回复,大家也要可以交流。从开始着手修改简历到最后拿到一个自己算满意的 offer 基本上花了(1 月份5 月份) + (912 月)总共 8 个多月的时间。应该算比较久的时间。感觉我是挂掉了很多面试之后,才开始慢慢系统的整理。整理之后就思路清晰很多了。
祝小伙伴都早日上岸~
其他补充资源
- 我自己的 coding 笔记,excel 形式的,在附件 1 中。
- 一些我整理的学习笔记截图,在附件 1 中,方便大家参考。
- ML cheat sheet,在附件 1 中。
- 一本好书:《Data Science for Business》。我还在读的过程中。
- 一本能理解 Data Science 在现代企业里的作用的书:《Lean Analytics》。需要大家自己找找免费版或者买一本,我读了 70%,真的很值得一读。
- Big list of DS/ML interview resources:The Big List of DS/ML Interview Resources
- Notes and technical questions from interviewing as a Data Scientist in 2018:Notes and Technical Questions
- Videos of one of my favorite YouTuber: Joma (a DS/SDE with an amazing experience in big names):