KatInterview

Fitting Simplex-Constrained Action Weights for a Usage Score

Statistics & ExperimentsModel answer
HardModel answerStatistics & Experimentsconstrained-regressionmulticollinearitybootstrap

Last updated

Estimate non-negative, sum-to-one weights for four user actions predicting time spent, handle collinearity, quantify uncertainty, stabilize with priors, and tune Elastic Net by cross-validation.

Scenario

You work on the data science team of a large social app. You want a single "usage score" per user built from four kinds of actions taken in the past 30 days: likes (L), comments (C), shares (S) and saves (V). You have data for 1 million users, including each user's total time spent in the app, T.

You propose a linear model:

T = wL·L + wC·C + wS·S + wV·V + ε

Questions

  1. Estimating the weights

    • How would you estimate the weights if each must be non-negative and all four must sum to 1?
    • Likes and shares are strongly correlated. How do you deal with that?
  2. Uncertainty and stability

    • Describe how you would produce a 95% confidence interval for each weight.
    • The model fits the training data well but its estimates vary a lot on held-out data. How would Bayesian priors help stabilize them?
  3. Implementation

    • Suppose you drop the hard constraints and use Elastic Net instead. Outline, in pseudo-code or a clear logic flow, k-fold cross-validation to choose the regularization parameters.

Considerations

  • The four counts are on different scales and heavily right-skewed.
  • Newer users often have zeros for some actions simply because they have been around briefly.
  • State explicitly what you assume about the distribution of the error term ε, and justify it.

Hints

Hint 1

Ask what units the weights have. If T is in minutes, can the weights meaningfully sum to 1? Consider separating an overall scale factor from the relative importance of each action.

Hint 2

With only four parameters, the constrained fit is a small convex quadratic program. Think about KKT conditions, and about why weights that sit exactly at 0 break standard asymptotic confidence intervals.

Hint 3

A Gaussian prior on coefficients corresponds to ridge, and a Dirichlet prior is the natural choice on the simplex. For cross-validation, ask which steps (log transform, scaling) must be fit inside each fold to avoid leakage.