skills/tabular/rmsle-keras-metric/SKILL.md
Custom Keras RMSLE metric using K.log with K.clip to safely evaluate price and count regression during training
npx skillsauth add wenmin-wu/ds-skills tabular-rmsle-keras-metricInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Root Mean Squared Logarithmic Error (RMSLE) penalizes under-prediction more than over-prediction, making it ideal for price, sales, or count regression. Implement it as a custom Keras metric so it displays during training alongside loss. Use K.clip to avoid log(0).
from tensorflow.keras import backend as K
def rmsle(y_true, y_pred):
first_log = K.log(K.clip(y_pred, K.epsilon(), None) + 1.)
second_log = K.log(K.clip(y_true, K.epsilon(), None) + 1.)
return K.sqrt(K.mean(K.square(first_log - second_log), axis=-1))
model.compile(optimizer='adam', loss='mse', metrics=['mae', rmsle])
rmsle as a function of (y_true, y_pred) using Keras backend ops[epsilon, inf) before log to prevent NaNmetrics=[rmsle] in model.compileK.clip is safer — relu zeros out negatives silentlysklearn.metrics.mean_squared_log_error works for evaluation only, not as a Keras metricdata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF