Transcript
0:00 hey how's it going good how are you doing very good so thank you for being a interviewee for this mock interview so this small interview is going to mimic a facebook data scientist um analytic interview um interview style um and this is gonna be a three minute round and what we're gonna do is we're gonna go through some statistics questions for the first 10 minutes follow my um sql questions for 15 minutes
0:30 yeah and then we'll use the remainder of the time on an analytic case study do you have any questions on that before we proceed no that sounds good thank you okay awesome all right so i'm gonna go ahead and actually use this quarter pad and feel free to make notes um as much as you want um really you know just treat this as so it's your uh it's your white board okay so let's start with the first question
0:55 can you can you explain to me um what is a beta coefficient of a multiplier regression uh yeah for sure so the beta if we um sorry let me think about how to frame it um so a multivariate regression describes the relationship between the left hand side variable the outcome and a series of right hand side variables
1:26 let's call them the independent variables and the beta coefficient describes how the outcome changes in relationship to changes in the independent variables so if the independent variable changed by one and the beta coefficient is on that variable is beta for example then the outcome would change by beta is um that makes sense so how would you actually derive the coefficient
1:58 of the uh of a linear model in this case um yeah there's a sort of a well-known solution um analytically which is that i can write it actually here which is that the beta beta vector is um x prime y um times
2:28 x prime the inverse of x prime x and here the um the x is uh the here x represents the matrix the independent variables and y represents the vector of outcomes yeah okay that makes uh that makes perfect sense yeah so prime in this case would be your uh your transpose yeah exactly got it um now how would you
2:59 how would you um how would you estimate it without using so i believe what you're using the least squares approach but is there any other ways a different way of estimating the beta coefficient um yeah so we could use a maximum likelihood estimation for it um for example um and do like a optimization exercise on that to maximize the the likelihood function okay got it all right that makes it
3:30 make sense all right so let's talk about the next question um now suppose that your target variable is inflated with zero um how would you actually going about approaching that problem um so if my data is um zero uh if my target variable is zero inflated i think the first question that i would ask is is there some type of censoring that is happening
4:01 with um the target variable to cause these zeros or are these zeros like actually um the values of uh that we're interested in got it that's a really good point um but now let's just presume that in this case um it is an actual value um and let's see that the presence of zero so this is actually a non-negative um continuous distribution and um the presence of zero uh is uh has is it's about eighty percent of your um
4:34 of your observations um in this case how would you how would your model uh model this type of data yeah that's a great question um i believe that there are statistical methods that help you deal with variables that are that follow distributions like this so the probit model or the tobit model for example can handle target variables that are
5:05 particular like this one if we so that's that's sort of one statistical modeling approach that we can take alternatively i think just for like sanity checks and um understanding the data more we can also just model the target variable as being zero versus not running maybe a regression to see um how the beta coefficients look like and then proceeding with like the original
5:36 modeling with the original variables okay got it all right that makes sense um now let's move on to the next question um can you just can you um explain what a confidence interval is of a logistic regression model uh yeah so and the confidence interval meaning um the confidence intervals on the beta coefficients i'm assuming yeah yeah yeah so the confidence intervals um
6:08 represents uh so let's say we have like a 95 percent confidence interval um and the statistical interpretation of that is that um they're like 95 of the time the actual beta coefficient will fall into the confidence interval that we estimated um and and that represents sort of um our our uncertainty around this this variable okay got it
6:39 well now what if um so the the uh the beta coefficients of the logistic regression could either be in logos or alts ratio right um now let's presume that there's a presence of zero um in either one of those cases what does that mean presence of zero in the confidence interval then what would that mean in terms of the statistical significance
7:11 of of its uh predictor oh i see so um you you're asking what does it mean if your confidence interval includes zero yes yes in either cases where it's either already in log odds or odds ratio uh beta coefficient because the logistic regression model can be in both forms yeah exactly um so i think my interpretation with that
7:42 would be that the beta coefficients are not statistically distinguishable distinguishable from zero um and yeah uh if you were to do hypothesis testing on that coefficient then you would not reject the null hypothesis okay so if it's uh so if the coefficient is already it's in the log odds form um uh would it be possible to have a value of zero
8:15 oh i see um right so yeah in that case i don't think that's possible right because it would be yeah sorry if the predictor doesn't is uncorrelated with the um outcome variable then the logos ratio should actually be one instead of zero um and it's not actually possible to have a
8:47 zero value for that okay now what if it wasn't uh what if it was involved ratio if the if the confidence interval has has um one what does that mean in terms of its uh statistical significance so let's just say that the odds ratio confidence interval falls somewhere between um point two [Music] four and point
9:19 one uh one point two four what does it mean in terms of its statistical significance um then in in which case because it includes one it's uh if you were to do a hypothesis testing exercise you would not find that it's statistically significant okay got it all right thank you um okay so we're going to move on to the uh x sql question um so i'm going to go ahead and paste the table
9:49 so this is a a basically a snippet of uh of the message um table set um and it contains your user id username the date and the message the number of message sent and the message the number of message received a given user on a day-to-day basis now go ahead and try to address the first question which is for each day return the name of
10:20 the user or in this case you can return the user id who receive the highest message sent to message received ratio and this message ratio is your message sent divided by message received got it um yes i think the first question that i would or the first thing that i would check for in this data database would be whether there are
10:51 missing values in either um in you know any of these columns and in the following analysis i'm just going to pre i'm just going to assume that there aren't any missing values and the second thing that i would think is important is whether message received could be zero because then you have a division by zero issue that may need to be addressed okay so i'm not
11:26 select so
12:08 so [Music] um
12:41 so here i'm creating uh you know i'm selecting the user name variable and i'm also creating a new variable called uh sent to sent to received ratio which computes the ratio between message sent and message received and here i'm marking the message received variable as null if it's equal to zero so that the division will also result in a null okay
13:18 um oh and i guess the question that i then want to ask is how we want to um treat these users do we um do we see them as having the highest ratio yeah like basically like okay for october 1st 2020 user xyz
13:51 had the highest ratio i say so you actually want to set it to like a really high number um so that it would come on top when you sort um when you sort it precisely off of a given day so you want to you want to do some kind of screening on a given day got it okay in that case i think marking it as a null may not be the best idea um
14:22 let's actually kind of simplify this for a bit so let's just presume that um there is no zero in the denominator and it's already it's always populated so how would you go ahead and proceed with that problem then okay yeah that sounds good um in that case um i'll just do a simple division to calculate the ratio um and we want to group by date um so that we
14:53 return one user for each date and the other question is do we are we interested in returning um multiple users for each day if they have the same highest ratio for each day good question so in this case um let's let's presume that um it's just you just return one user in that case okay so any user in that alien user yeah okay yeah it sounds good um
15:26 um i think in this case i want to do like a a window function so um i'll create another new variable which is let's call it rank
16:03 and since you said that it's okay to just return one user i'll calculate row numbers over partition by date order by the ratio
16:49 um oh actually i don't need to group by date um i just have to select all right because equal to one which is the highest um center received ratio but user what's the highest ratio um
17:24 okay so final solution or do you want to make any kind of revision um yeah i think that's the final solution okay got it um so i'm going to give you another question so in this case um now let's just say that uh for each user return the first date when the user received zero message
17:58 mm-hmm return the first date when the user received zero message and uh if the user never received zero message um do we then in that case like those users wouldn't wouldn't matter so basically for user we just want to see uh what so among the users who receive zero messages when when was it that they received that
18:29 zero message for the first time got it yeah that makes sense um so i would select uh let's say we return username um messages which is database and we are only interested in cases where message received is equal to zero um and we also return the first day
19:03 which is min date as um wait for each user um oh actually um sorry my bad we we only return one observation for each user so i'm gonna group my username assuming that both user id and username are unique okay yeah
19:36 okay so what you're basically doing is you're aggregating at the user level uh after you apply the filter where you're only looking at the entries that have zero in the method you see um and then for each of the user you wanna you're extracting the minimum date yeah exactly okay got it um all right so that's uh that's pretty much it for the sql um let's move on to the next uh section which is on the analytic case
20:04 study so this is so the so this this uh question is based on instagram and what instagram is trying to do is identify users who are influencers so how would you help instagram define um whom the who who which users are influencers or not yeah to kind of getting to to get
20:35 started on this question i think the first um clarifying question maybe that i would ask is how we define a user as an influencer um and i think there might be several ways to defining them um definition we could determine that a user is an influencer if they have you know a huge amount of influence on instagram so maybe if their number of followers
21:09 exceeds a threshold then we define them as an influencer or if they're if or if they have specific posts that are particularly popular so maybe not many people follow them but some of their posts went viral and so maybe the number of overall views of your posts could also be used as a criteria for determining
21:41 whether an user is an influencer the other thing um that you know moving away from these definitions a little bit is whether a user is being paid for certain content that they post on instagram so um whether they do any paid ads um and maybe if they do we can define them as an influencer uh should i proceed with any particular one of these definitions or uh well i think so i think those are
22:12 good so number of uh number of followers that they have number of uh overall views that they have on posts and then if they have any paid ads um those are the criteria criteria that you would use to um to identify the user as an influencer or not right yeah okay um now now uh so the so those are the measures now how would you actually bend the users into influencer or not bucket um yeah i guess
22:45 in order to do that i would love to understand a little bit more about like what this definition is used for um so is is the team instagram interested in maybe getting more users into the influencer bucket to promote their business or um are we trying to cluster users into influencer versus not in order to do some kind of targeted experiment or targeted
23:15 feature design or something like that in this in this in this um uh case uh we want so instagram um you know wants to promote um wants to match advertisers with influencers so uh we need to identify with the you know who the users are are they influencers or are they you know just regular consumers um this is where you need to help the team um define that
23:45 yeah that's very helpful context um and so i guess in that case uh i can refine my previous criteria a little bit more so we are not primarily interested in who is being paid for ads um but instead like who has the potential to um serve as an influencer on instagram and generate ads revenue for advertisers um yeah and um
24:17 sorry what was the sorry what was your previous question so so uh so like how would you actually define that criteria saying okay these are the users who are influencers yeah it's kind of like if you were building like a fraud model saying okay this is a buster or not mm-hmm yeah representative um so similarly how would you should do that for the users bucket them into influencer or not
24:50 and have the model so i think there are two ways of approaching this problem and i would classify them into um you know the unsupervised approach uh versus supervised approach um in the unsupervised approach um we are interested in finding clusters within the
25:21 user um within the list of users of instagram and trying to find the clusters that are that has a huge amount of influence in the supervised approach we would essentially try to obtain some type of labels on whether a user is currently an influencer um and try to classify the remaining users into having the potential to to become an influencer versus not okay
25:52 yeah so and and i think the key distinction between these two approaches is that um in the supervised approach we have to come up with some ways of creating the label in the first place okay um so how would you go on about creating a label yeah so if we were proceeding with this um approach one way is to try to collect information on whether they have any paid ads in their um current
26:25 in instagram posts okay and um i am not a hundred percent sure if this is true but i remember seeing some of the um influencer having these posts that are kind of labeled as advertisement and if instagram collects that sort of data then um that could serve as a useful label for this problem okay um all right now i'm gonna i have i have a follow-up
26:55 um so now let's suppose that you do have this uh instagram influencer bucket now how would you go ahead and um and segment the influencer population so i'm going to paste the question here yeah and i imagine that the reason that we want to segment these influencers maybe
27:26 to group them into different um categories so that advertisers with different needs can be matched to different groups of influencer is that right got it yeah and so i think you know what type of influence they have would be um really the prime the primary um variable of interest to us because we are interested in knowing what type of population they attract so if they are like a fashion blogger um
28:00 let me write some potential categories um maybe they are like a fashion blogger or they are i am uh they post mainly political content um etc and so they their posts the content of their posts may say uh may wrap may generate a good signal for um what type of crowd they attract um so and so
28:31 treating this as one of the features is um content uh content of posts and maybe we can do some computer vision type analysis or uh natural language processing analysis on the content of these posts to extract keywords and group them into categories um the other feature that i have in mind is the type of um users that follow them so they're followers um
29:03 and if their users um [Music] you know label themselves and then you weigh on the instagram profile then we can get a pretty good sense of how what type of population they're attracting and the potential advertisement revenue they can generate yeah so these are the two main types of features that i can think of i don't
29:35 care at this moment you identify the signals um now now with using the signals how would you actually perform the segmentation itself yeah um so say that we um use maybe some machine type of machine learning models to analyze their posts and the text that they post um and we can get uh sort of embeddings of um and we can get like
30:05 embeddings of their content then we can perform a unsupervised clustering algorithm to try to group these influencers into different groups so one of the simplest models that we can i can think of is the k-means clustering okay there are many modifications of this that serves different purposes but yeah this may be a good starting point okay um and one last
30:38 question and then we're done with the session um is how would you evaluate your cluster then um that's um that's a good question so evaluation um i think you know one way that i can think of on top of my head is if we get some human raiders human labelers to look at these influencers and then group them into categories
31:09 and we can compare the human evaluation with the results that are generated from the algorithms okay got it got it all right yeah so that wraps up the session um thank you for uh being a participant as an interviewee for this mock interview um and i hope you have a good day yeah thank you so much for this question appreciate it yeah thank you
Summary
- Beta coefficients in multivariate regression indicate how changes in independent variables affect the outcome.
- Alternative methods for estimating coefficients include maximum likelihood estimation.
- Zero-inflated target variables may require models like probit or tobit for accurate analysis.
- Confidence intervals indicate the uncertainty around beta coefficients; if they include zero, the coefficients are not statistically significant.
- SQL queries involve calculating message ratios and identifying users with specific messaging behaviors.
- Influencer identification can be approached through unsupervised clustering or supervised classification based on user engagement metrics.
- Key features for influencer segmentation include content type and follower demographics, analyzed using machine learning techniques like k-means clustering.
- Evaluation of clustering results can involve comparison with human labeling for accuracy.