# My Take on Facebook AI Interview Questions with Interactive Code — Part 1

So I found this amazing blogger Vimarsh Karbhari and he have some amazing stuffs on his blog! So please check him out, also he is the creator of Acing AI. And today, I’ll try to answer his Facebook AI Interview question from this blog. And please note that my solution would be not optimized.

Also, I am not going to answer question in numeric order. And for every question I’ll try to find the right answer and link them. However, ** I am always open to learning and growing**, so if you know a more optimal solution please comment down below.

**Use a python built-in package to manipulate ‘csv’ data.**

Lets start with an easy one, for csv files python’s Python Data Analysis Library is the best library in my opinion. Also, I am going to use publicly available data from this website.

I just read the csv data and added some noise, we can see that values for mean, std, and variance have changed. Also for more example of manipulating csv data please check out this website.

**If a PM says that they want to double the number of ads in Newsfeed, how would you figure out if this is a good idea or not?**

I think this is another good use case for A/B Testing, the one problem with this approach is the that fact we are making a decision after doubling the number of ads in the Newsfeed. Because we are going to compare the reaction of users before/after the change in number of ads. Another good method I could think of would be making a survey for the users and asking their opinion on what do they think about doubling the number of ads in the Newsfeed, if most of them gives a positive reaction it may be a good sign.

I was actually able to find the exact question by one simple google search, it seems like A/B Testing is a good way. Please click here to see the answers.

**Make a histogram of 2 variables.**

I believe the question is asking for something like above, and this stackoverflow post helped me alot.

I found another blog post that does a similar thing, if anyone is interested please click here to check out more.

**What metric would you show small businesses if you were trying to have them sign up for Facebook Ads?**

I am not a PM but if I had to put myself in the owners who owns small business I would want to see how many active users are there who are interested in my product (or the category of the product that I sell). For example, if I own a small sports shoes company, I won’t necessary care how many active users who are interested in shoes, rather I would want to know specifically how many active users are there who are interested in sports shoes.

The above user gave a detailed answer, I think their way of approaching this question is correct, please click here to view the answer. My answer was just too simple and did not have enough details. Also, if anyone is interested Facebook themselves have posted a ‘How to Guide’ for advertising, to view it please click here.

**Write a sorting algorithm for a numerical dataset in Python.**

For this time, I decided to use insertion sort, again it may not be the most fastest algorithm, but it is easy to understand.

Also, the I learned a lot from the video linked below.

Answers that I found from glassdoor just used the built in function method, which is a good idea since they are super fast. To see the answers please click here.

**Interactive Code**

*For Google Colab, you would need a google account to view the codes, also you can’t run read only scripts in Google Colab so make a copy on your play ground. Finally, I will never ask for permission to access your files on Google Drive, just FYI. Happy Coding!*

To Access the code on Google Colab, please click here.

**Final Words**

I heard once or twice that A/B Testing is very important, but as I do this questions I realized how much it can be used in the industry.

If any errors are found, please email me at jae.duk.seo@gmail.com, if you wish to see the list of all of my writing please view my website here.

Meanwhile follow me on my twitter here, and visit my website, or my Youtube channel for more content. I also did comparison of Decoupled Neural Network here if you are interested.

**Reference**

- Facebook AI Interview Questions — Acing the AI Interview. (2018). Medium. Retrieved 8 April 2018, from https://medium.com/acing-ai/facebook-ai-interview-questions-acing-the-ai-interview-5982add0af55
- Python Data Analysis Library — pandas: Python Data Analysis Library. (2018). Pandas.pydata.org. Retrieved 8 April 2018, from https://pandas.pydata.org/
- Python, U. (2018). UnicodeDecodeError when reading CSV file in Pandas with Python. Stackoverflow.com. Retrieved 8 April 2018, from https://stackoverflow.com/questions/18171739/unicodedecodeerror-when-reading-csv-file-in-pandas-with-python
- Series?, H. (2018). How to get the first column of a pandas DataFrame as a Series?. Stackoverflow.com. Retrieved 8 April 2018, from https://stackoverflow.com/questions/15360925/how-to-get-the-first-column-of-a-pandas-dataframe-as-a-series
- Loading CSV data in Python with pandas — PythonHow. (2018). PythonHow. Retrieved 8 April 2018, from https://pythonhow.com/data-analysis-with-python-pandas/
- Download Sample CSV Files For Demo Use. (2018). Sample-videos.com. Retrieved 8 April 2018, from http://www.sample-videos.com/download-sample-csv.php
- Pandas read CSV — Python Tutorial. (2018). Pythonspot.com. Retrieved 8 April 2018, from https://pythonspot.com/pandas-read-csv/
- Facebook Interview Question: If a PM says that they want t… | Glassdoor. (2018). Glassdoor.com. Retrieved 8 April 2018, from https://www.glassdoor.com/Interview/If-a-PM-says-that-they-want-to-double-the-number-of-ads-in-Newsfeed-how-would-you-figure-out-if-this-is-a-good-idea-or-not-QTN_1975756.htm
- matplotlib, P. (2018). Plot two histograms at the same time with matplotlib. Stackoverflow.com. Retrieved 8 April 2018, from c
- », V. (2011). Basic Data Plotting with Matplotlib Part 3: Histograms. Bespoke Blog. Retrieved 8 April 2018, from https://bespokeblog.wordpress.com/2011/07/11/basic-data-plotting-with-matplotlib-part-3-histograms/
- Facebook Interview Question: What metric would you show sm… | Glassdoor.ca. (2018). Glassdoor.ca. Retrieved 8 April 2018, from https://www.glassdoor.ca/Interview/What-metric-would-you-show-small-businesses-if-you-were-trying-to-have-them-sign-up-for-Facebook-Ads-QTN_2236044.htm
- Help Centre. (2018). Facebook.com. Retrieved 8 April 2018, from https://www.facebook.com/business/help/1438417719786914
- Facebook Interview Question: What metric would you show sm… | Glassdoor.ca. (2018). Glassdoor.ca. Retrieved 8 April 2018, from https://www.glassdoor.ca/Interview/What-metric-would-you-show-small-businesses-if-you-were-trying-to-have-them-sign-up-for-Facebook-Ads-QTN_2236044.htm
- Insertion sort algorithm. (2018). YouTube. Retrieved 8 April 2018, from https://www.youtube.com/watch?v=i-SKeOcBwko
- Facebook Interview Question: Write a sorting algorithm for… | Glassdoor. (2018). Glassdoor.com. Retrieved 8 April 2018, from https://www.glassdoor.com/Interview/Write-a-sorting-algorithm-for-a-numerical-dataset-in-Python-QTN_930438.htm