Data and Trend Analysis with Pattern Recognition Questions
Analyzing quantitative and qualitative data to identify patterns, trends, correlations, and meaningful insights. Skills assessed include descriptive statistics, time series and trend analysis, visualization and dashboarding, hypothesis generation and testing, identifying seasonality and structural changes, distinguishing signal from noise, and synthesizing findings into clear recommendations. For qualitative inputs candidates should demonstrate coding, theme extraction, categorization, and synthesis of transcripts or survey responses. Emphasis is on choosing appropriate methods, validating patterns, avoiding common pitfalls such as confounding and spurious correlation, and communicating insights effectively to stakeholders.
Sample Answer
import pandas as pd
from statsmodels.tsa.stattools import adfuller, grangercausalitytests
from statsmodels.tsa.api import VAR
# assume df has columns 'ad_spend' and 'sales' indexed by time
# 1) stationarity test
for col in ['ad_spend','sales']:
print(col, adfuller(df[col].dropna())[:2]) # test statistic, p-value
# 2) difference if needed
df_diff = df.diff().dropna()
# 3) select lag via VAR
model = VAR(df_diff)
sel = model.select_order(maxlags=8)
print(sel.summary())
# 4) Granger causality test (maxlag = selected lag)
grangercausalitytests(df_diff[['sales','ad_spend']], maxlag=sel.aic, verbose=True)
# To test whether ad_spend causes sales, supply [sales, ad_spend] order.Sample Answer
Sample Answer
Sample Answer
Sample Answer
import pandas as pd
import numpy as np
from statsmodels.tsa.stattools import adfuller
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
# assume df with columns 'date','revenue','promo'
df.set_index('date', inplace=True)
y = df['revenue']
X = df[['promo']].astype(float)
# stationarity
print(adfuller(y.dropna())[:2])
# seasonal diff
y_sdiff = y.diff(7).dropna()
plot_acf(y_sdiff); plot_pacf(y_sdiff)
# create lagged promo
for lag in (0,1,7):
X[f'promo_lag{lag}'] = X['promo'].shift(lag).fillna(0)from statsmodels.tsa.statespace.sarimax import SARIMAX
model = SARIMAX(y, exog=X, order=(1,1,1), seasonal_order=(1,1,1,7), enforce_stationarity=False, enforce_invertibility=False)
res = model.fit(disp=False)
print(res.summary())residuals = res.resid.dropna()
plot_acf(residuals); plot_pacf(residuals)
from statsmodels.stats.diagnostic import acorr_ljungbox
print(acorr_ljungbox(residuals, lags=[7,14], return_df=True))
residuals.plot(); import scipy.stats as st; st.probplot(residuals, dist="norm", plot=plt)# prepare X_future (length h)
fc = res.get_forecast(steps=h, exog=X_future)
mean = fc.predicted_mean
ci = fc.conf_int(alpha=0.05) # 95% PIfrom sklearn.metrics import mean_absolute_percentage_error, mean_squared_error
def rolling_cv(y, X, order, sorder, initial_train, horizon):
errors=[]
for start in range(initial_train, len(y)-horizon+1):
train_y = y.iloc[:start]
train_X = X.iloc[:start]
test_y = y.iloc[start:start+horizon]
test_X = X.iloc[start:start+horizon]
m = SARIMAX(train_y, exog=train_X, order=order, seasonal_order=sorder).fit(disp=False)
pred = m.get_forecast(steps=horizon, exog=test_X).predicted_mean
errors.append(mean_squared_error(test_y, pred, squared=False)) # RMSE
return np.mean(errors)Unlock Full Question Bank
Get access to hundreds of Data and Trend Analysis with Pattern Recognition interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.