Towards Better Keras Modeling – Part VI

Articles From: The Alpha Scientist
Website: The Alpha Scientist

See the previous installment in this series to learn about Univariate Relationships.

Multivariate Effects

Of course, reality is non-linear and we can’t think about each of these parameters in isolation. Below are a few ways to look at pairs of factors that are logically related.

df_grid = df.reset_index().groupby([“first_neuron”, “hidden_neuron”]).val_loss_improvement.mean().unstack()
ax = sns.heatmap(data=df_grid,cmap = (sns.diverging_palette(10, 220, sep=80, n=7)),annot=True)
ax.set_title(‘Log-Loss Improvement for Varying Shapes’)

# Unsurprisingly, bigger on both layer types is better.

Towards Better Keras Modeling

df_grid = df.reset_index().groupby([“hidden_layers”, “hidden_neuron”]).val_loss_improvement.mean().unstack()
ax = sns.heatmap(data=df_grid,cmap = (sns.diverging_palette(10, 220, sep=80, n=7)),annot=True)
ax.set_title(‘Log-Loss Improvement for Varying Shapes’)

df_grid = df.reset_index().groupby([“dropout”, “hidden_neuron”]).val_loss_improvement.mean().unstack()
ax = sns.heatmap(data=df_grid,cmap = (sns.diverging_palette(10, 220, sep=80, n=7)),annot=True)
ax.set_title(‘Log-Loss Improvement vs Dropout/Size’)

# Surprisingly, dropout didn’t help even at larger geometries

metric = ‘hidden_layers’
ax = sns.boxplot(x=metric, y=”val_loss”, data=df.reset_index(),color=’salmon’)
ax.set_title(f’Validation Loss as function of {metric}’)

# Very interestingly, no hidden layers is MUCH better. Possibly a consequence of
# some deep models with too few neurons to properly represent data

Stay tuned for the next installment in this series to learn more about Relative Importance of Features.

Visit The Alpha Scientist blog to download the complete code:
https://alphascientist.com/hyperparameter_optimization_with_talos.html

The Alpha Scientist blog – Chad is a full-time quantitative trader who has been working on data analytics since before it was cool. He has long balanced his interest in computer science (MS in EE/CS from MIT) with a fascination in markets (CFA designation in 2009). Prior to becoming a full-time quant, he built analytics products and managed teams at software companies across Silicon Valley. If you’ve found this post useful, please follow @data2alpha on Twitter and forward to a friend or colleague who may also find this topic interesting. https://alphascientist.com/

Disclosure: Interactive Brokers

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from The Alpha Scientist and is being posted with its permission. The views expressed in this material are solely those of the author and/or The Alpha Scientist and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.