skills/tabular/tabular-to-image-cnn/SKILL.md
Reshapes tabular features into 2D pseudo-images via random feature permutation, enabling CNN-based feature interaction learning.
npx skillsauth add wenmin-wu/ds-skills tabular-tabular-to-image-cnnInstall 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.
Convert flat tabular features into a 2D grid by repeating the feature vector with random permutations, then apply 2D convolutions. Each row of the "image" is a different random ordering of features, so the CNN learns local interactions between different feature pairs. This captures non-linear feature interactions that tree models and MLPs may miss.
import numpy as np
import tensorflow as tf
from random import choice
def build_tabular_cnn(n_feats, n_repeats=50):
# Create random permutation mask
mask = np.zeros((n_repeats, n_feats), dtype=np.int32)
for i in range(n_repeats):
indices = list(range(n_feats))
for j in range(n_feats):
mask[i, j] = indices.pop(choice(range(len(indices))))
inp = tf.keras.layers.Input(shape=(n_feats,))
x = tf.keras.layers.Lambda(lambda x: tf.gather(x, mask, axis=1))(inp)
x = tf.keras.layers.Reshape((n_repeats, n_feats, 1))(x)
x = tf.keras.layers.Conv2D(32, (n_repeats, n_feats), activation='relu')(x)
x = tf.keras.layers.Flatten()(x)
x = tf.keras.layers.Dense(64, activation='relu')(x)
out = tf.keras.layers.Dense(1)(x)
return tf.keras.Model(inp, out)
data-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