def standardize(df, features):
df_standardized = df.copy()
for f in features:
mu = df[f].mean()
sigma = df[f].std()
df_standardized[f] = df[f].map(lambda x: (x - mu) / sigma)
return df_standardized
features = ['delay_to_carrier', 'wait_time', 'n_orders', 'quantity','quantity_per_order', 'sales']
sellers_standardized = standardize(sellers, features)
model = smf.ols(formula=f"review_score ~ {'+ '.join(features)}", data=sellers_standardized).fit()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter