Sql Ml Features logo

Sql Ml Features

Community
damusix
sql-ml-features

Use when preparing data for machine learning from SQL Server — feature engineering in T-SQL, building training/test datasets, statistical aggregations for ML pipelines, sampling strategies, data normalization and encoding in SQL, writing queries that feed pandas or scikit-learn, exporting to Parquet or CSV for model training, or when a data scientist asks for a 'feature table' or 'training set' from a SQL Server database.

Overview

Publisherdamusix
Repositoryskills
Skill namesql-ml-features
Stars
63
Forks
3
Bundled files
5
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by damusix on GitHub. Read the source before you install it.

Installation

Install the Sql Ml Features AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/damusix/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/sql-ml-features .claude/skills/sql-ml-features
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Sql Ml Features in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Sql Ml Features on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Sql Ml Features is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

SQL for Machine Learning

Patterns for extracting ML-ready features from SQL Server — turning normalized relational data into the wide, denormalized, NULL-free datasets that models consume.

When to Use

  • Building a feature table or training dataset from application data
  • Feature engineering in T-SQL (rolling aggregations, lag features, RFM scoring)
  • Encoding categorical variables (one-hot, ordinal, frequency encoding)
  • Handling NULLs for ML (imputation strategies in SQL)
  • Sampling and train/test splitting from SQL Server
  • Exporting large datasets to CSV, Parquet, or pandas
  • Preventing data leakage in temporal feature queries
  • Writing queries that feed scikit-learn, XGBoost, or PyTorch pipelines

When NOT to use: application schema design (table design, naming conventions, access control), query performance tuning (execution plans, index tuning, wait stats), BI dashboards and summary reports (GROUPING SETS, pivot tables, dashboard queries), or running R/Python inside SQL Server (SQL Server ML Services).

Feature Table Build Workflow

Follow these steps in order. Each step has a validation checkpoint.

  1. Set snapshot date — Anchor all features to a fixed @SnapshotDate. Never use GETDATE() inside feature queries.

    • Validate: SELECT @SnapshotDate returns the intended date.
  2. Build base entity tableSELECT DISTINCT the entity key into a temp table #Base. One row per entity, primary key only — no features yet.

    sql
    SELECT DISTINCT CustomerId
    INTO #Base
    FROM Customers
    WHERE SignupDate < @SnapshotDate;
    • Validate: SELECT COUNT(*), COUNT(DISTINCT CustomerId) FROM #Base — counts must match (no duplicates).
  3. Join features with temporal bounds — LEFT JOIN each feature set to #Base. Bound every join with AND EventDate <= @SnapshotDate.

    sql
    SELECT b.CustomerId,
           DATEDIFF(DAY, f.LastOrder, @SnapshotDate) AS Recency,
           f.OrderCount AS Frequency
    FROM #Base b
    LEFT JOIN FeatureCTE f ON f.CustomerId = b.CustomerId;
    • Validate: Row count equals #Base row count. No feature references dates after @SnapshotDate.
  4. Impute NULLs — Replace every NULL with an explicit value. Use COALESCE with mean, median, zero, or a sentinel depending on the column semantics.

    • Validate: SELECT SUM(CASE WHEN col IS NULL THEN 1 ELSE 0 END) FROM FeatureTable returns 0 for every column.
  5. Encode categoricals — One-hot, ordinal, or frequency encode all non-numeric columns.

    • Validate: SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'FeatureTable' — all columns are numeric types (int, float, decimal, bit).
  6. Split train/test — Use hash-based split for cross-sectional data or cutoff-date split for time series.

    • Validate: SELECT SplitLabel, COUNT(*) FROM FeatureTable GROUP BY SplitLabel — verify expected proportions (e.g., 80/20).
  7. Export — BCP, pandas.read_sql, or FOR JSON depending on the consumer.

Feature Engineering Taxonomy

CategoryExamplesT-SQL tools
NumericRaw values, LOG(col + 1) for skewed, ratios, z-scoresLOG(col + 1), SQRT, window AVG/STDEV
CategoricalOne-hot encoding, ordinal, frequencyCASE, PIVOT, DENSE_RANK, COUNT ratios
TemporalRecency, duration, day-of-weekDATEDIFF, DATEPART, DATENAME
Rolling window7-day sum, 30-day averageSUM/AVG OVER (ROWS BETWEEN ...)
Lag / offsetPrevious value, delta from priorLAG, LEAD
InteractionProduct, ratio of two featuresComputed expressions in SELECT
Text signalsLength, keyword presenceLEN, CHARINDEX, PATINDEX
MissingnessIs this value missing?CASE WHEN col IS NULL THEN 1 ELSE 0 END

Quick Reference: SQL Pattern → ML Concept

ML conceptT-SQL pattern
Recency featureDATEDIFF(DAY, LastEventDate, @SnapshotDate)
Frequency featureCOUNT(*) OVER (PARTITION BY entity ORDER BY dt ROWS BETWEEN 29 PRECEDING AND CURRENT ROW)
Rolling 7-day revenueSUM(Amount) OVER (ORDER BY OrderDate ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
Lag feature (t-1)LAG(Amount, 1) OVER (PARTITION BY CustomerId ORDER BY OrderDate)
One-hot encodeCASE WHEN Category = 'A' THEN 1 ELSE 0 END AS Category_A
Ordinal encodeDENSE_RANK() OVER (ORDER BY Category)
Frequency encodeCOUNT(*) OVER (PARTITION BY Category) * 1.0 / COUNT(*) OVER ()
Log transformLOG(Amount + 1) — the +1 offset handles zero values; omit only when zeros are impossible
Quantile bucketNTILE(10) OVER (ORDER BY Score)
Row hash for split5-step chain: (1) CAST(Id AS NVARCHAR(20)) → (2) HASHBYTES('SHA2_256', ...) → (3) CAST(... AS BINARY(8)) → (4) CAST(... AS BIGINT) → (5) ABS(...) % 10
Mean imputationCOALESCE(col, AVG(col) OVER ())
Median imputationPERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY col) OVER ()
NULL indicatorCASE WHEN col IS NULL THEN 1 ELSE 0 END AS col_is_missing
Min-max scaling(col - MIN(col) OVER ()) / NULLIF(MAX(col) OVER () - MIN(col) OVER (), 0)
Date bucketingDATE_BUCKET(WEEK, 1, EventDate) (SQL Server 2022+)
Date truncationDATETRUNC(MONTH, EventDate) (SQL Server 2022+)
First value in seriesFIRST_VALUE(col) OVER (PARTITION BY entity ORDER BY dt ROWS UNBOUNDED PRECEDING)
Rolling volatilitySTDEV(col) OVER (PARTITION BY entity ORDER BY dt ROWS BETWEEN 29 PRECEDING AND CURRENT ROW)

Common Mistakes

MistakeWhat goes wrongFix
Using AVG(col) without understanding NULL exclusionAVG divides by non-NULL count, not row count — mean is inflated when NULLs represent zerosUse AVG(COALESCE(col, 0)) when NULLs mean zero
Rolling window with RANGE instead of ROWSTied timestamps include extra rows, producing different counts per rowAlways use ROWS BETWEEN n PRECEDING AND CURRENT ROW
Joining to future events in feature queryLeaks information that wasn't available at prediction timeBound all joins with AND EventDate <= @SnapshotDate
Computing global statistics before the train/test splitMean and variance incorporate test data into training featuresCompute statistics only over training rows
Using LAG without checking temporal orderLAG requires ORDER BY — missing it gives non-deterministic offsetsAlways include PARTITION BY entity ORDER BY timestamp
Forward-filling sensor NULLs across entity boundariesPARTITION BY is missing, so last value bleeds across entitiesAlways PARTITION BY entity_id in forward-fill window
HASHBYTES on NULL keyHASHBYTES(algo, NULL) returns NULL — entity lands in no splitExclude or handle NULL keys before splitting
UNPIVOT for categorical to indicator columnsUNPIVOT silently drops NULL valuesUse CROSS APPLY VALUES to preserve NULLs as zeros
Random split for time-series dataTest set leaks future patterns into training windowUse a cutoff date for time-series train/test split
Including the label column in lag featuresLAG(label) leaks ground truth about adjacent rowsExclude any derivative of the target from feature set

Reference Files

  • Feature Engineering — numeric, categorical, temporal, rolling windows, lag, RFM, text
  • Sampling and Splitting — TABLESAMPLE, hash-based splits, NTILE k-fold, stratified, time-based
  • NULL Imputation — mean/median/mode/forward-fill/constant, missingness indicators
  • Export Patterns — BCP, pandas.read_sql, chunked reads, FOR JSON, Parquet, feature stores
  • Data Leakage — temporal, target, train/test leakage; prevention patterns in SQL

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Sql Ml Features AI skill do?

Use when preparing data for machine learning from SQL Server — feature engineering in T-SQL, building training/test datasets, statistical aggregations for ML pipelines, sampling strategies, data normalization and encoding in SQL, writing queries that feed pandas or scikit-learn, exporting to Parquet or CSV for model training, or when a data scientist asks for a 'feature table' or 'training set' from a SQL Server database.

Why use Sql Ml Features on TypingMind?

Because you install it once and use it with any model. Sql Ml Features is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Sql Ml Features in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/damusix/skills/tree/main/sql-ml-features. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Sql Ml Features?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Sql Ml Features?

As many as you like. As long as a model supports skills, you can use Sql Ml Features with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Sql Ml Features AI skill free?

It is published on GitHub by damusix. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇