Machine Learning Interviews: Ranking and Recommendation
Table of Contents
Overview
- Terms Defined:
- Click Prediction Model
- App Install prediction model
- Sampling techniques:
- How would you sample k items from a list of n items without replacement in O(n) time? Stackoverflow answer https://stackoverflow.com/questions/2140787/select-k-random-elements-from-a-list-whose-elements-have-weights
- Implementing ML algorithms
- Implement k-means clustering algorithm
SELECT
A.company_name,
COUNT(CASE WHEN A.year = 2020 THEN A.product_name END) - COUNT(CASE WHEN A.year = 2019 THEN A.product_name END) AS net_difference
FROM
your_table_name A
WHERE
A.year IN (2019, 2020)
GROUP BY
A.company_name
HAVING
COUNT(CASE WHEN A.year = 2020 THEN A.product_name END) IS NOT NULL
AND COUNT(CASE WHEN A.year = 2019 THEN A.product_name END) IS NOT NULL;
## Write a query to count the net difference between the number of products companies launched in 2020 and previous year
```sql
SELECT
A.company_name,
COUNT(CASE WHEN A.year = 2020 THEN A.product_name END) - COUNT(CASE WHEN A.year = 2019 THEN A.product_name END) AS net_difference
FROM
your_table_name A
WHERE
A.year IN (2019, 2020)
GROUP BY
A.company_name
HAVING
COUNT(CASE WHEN A.year = 2020 THEN A.product_name END) IS NOT NULL
AND COUNT(CASE WHEN A.year = 2019 THEN A.product_name END) IS NOT NULL;
```