Mid-level interview questionAsked at Coinbase · interview write-up
In a live notebook, clean a messy tabular dataset with missing values and inconsistent strings, and build a sound baseline binary classifier.
Model answer
from sklearn.compose import ColumnTransformer
from sklearn.impute import SimpleImputer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import StandardScaler
def baseline(df, num, cat, y):
df = df.copy()
for c in cat:
df[c] = df[c].str.strip().str.lower()
nums = make_pipeline(SimpleImputer(strategy="median"),
StandardScaler())
cats = make_pipeline(
SimpleImputer(strategy="most_frequent"),
OneHotEncoder(handle_unknown="ignore"))
prep = ColumnTransformer([("n", nums, num),
("c", cats, cat)])
clf = LogisticRegression(max_iter=1000)
model = make_pipeline(prep, clf)
return cross_val_score(model, df[num + cat], df[y],
cv=5, scoring="roc_auc")
Look first: types, missing rates, label balance, and columns that leak the target, like anything recorded after the outcome. Normalise strings, and keep imputation, scaling and encoding inside a pipeline so they're fitted only on training folds. Compare against predicting the majority class, with ROC AUC or PR AUC under stratified cross-validation.
Practise the rest
35 Training questions, 492 in all, each with a model answer. Free.
More from Coinbase interview questions.
More Training interview questions
- Implement masked cross-entropy in NumPy that stays numerically stable, with label smoothing and a temperature.
- Build a pipeline that finds math documents in web crawls and scores their quality.
- Explain KL divergence for language models: which direction is which, what happens when supports don't match, and how it's used as a regulariser.
- When would you use mean squared error versus cross-entropy? And what is LoRA?
- Explain Adam and its bias correction, and why AdamW decouples weight decay.
- Explain policy types in RL and modern policy-gradient methods such as TRPO, PPO and GAE, then compare linear attention and grouped-query attention.