Command Palette

Search for a command to run...

Назад к скиллам
скилл № 57827

ds-utils-strings

String preprocessing, split-safe tag encoding, and significant term extraction. Use for converting comma-separated tag columns into model-ready features…

БесплатноБез исполняемых скриптов
idanmoradarthasот idanmoradarthas★ 37 звёзд на GitHub

Установить ds-utils-strings в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

ds-utils-strings

Text analytics, split-safe tag feature binarization, and significant term extraction.

Purpose

ds_utils.strings provides specialized string operations for feature engineering and text cohort analysis. It converts delimited tag fields into one-hot indicator columns while enforcing strict split-safety, and surfaces statistically overrepresented keywords in text subsets (such as churned customer complaints).

  • When to use: Encoding comma-separated metadata tags into binary features across train and test sets, or extracting distinctive vocabulary from specific document cohorts.
  • When NOT to use: For dense semantic sentence embeddings (use ds-utils-transformers), multi-label list pipelines with persistent estimators (use MultiLabelBinarizerTransformer in ds-utils-transformers), or tabular feature distributions (use ds-utils-preprocess).

Prerequisites

  • Python 3.11 or higher.
  • data-science-utils package installed (pip install data-science-utils).
  • Core dependencies: numpy, pandas, scikit-learn.

Instructions

Task-to-Approach Map

Text Processing Goal Function Split-Safety Guarantee Output
Encode comma-separated tags into binary columns append_tags_to_frame(X_train, X_test, field_name) Vocabulary fit on train only Tuple[DataFrame, DataFrame]
Find terms distinguishing a target cohort extract_significant_terms_from_subset(data_frame, subset_data_frame, field_name) Corpus vs. cohort comparison Pandas Series of scores

Full parameter specifications, return schemas, and common mistakes are documented in references/api_reference.md.


End-to-End Strings Feature Engineering Workflow

              Raw Data with String / Text Columns
                               │
               ┌───────────────┴───────────────┐
               ▼                               ▼
       Categorical Tags                 Freeform Text
               │                               │
       Profile Tag Column               Isolate Sub-Cohort
               │                         (e.g., churned users)
               ▼                               ▼
       Train / Test Split          Significant Term Extraction
               │                   (extract_significant_terms)
               ▼                               │
   Split-Safe Tag Binarization                 ▼
    (append_tags_to_frame)         Targeted Keyword Discovery
               │
               ▼
   Aligned Feature Matrices

Inputs you need

The steps below assume:

  • A DataFrame df with a comma-delimited tag column, an optional freeform text column, and an optional cohort indicator flag.
  • Your training and testing partitions (train_df and test_df).
import pandas as pd

# Load your text / tag dataset (replace with your data)
df = pd.read_csv("your_dataset")
# train_df, test_df = train_test_split(df, test_size=0.25, random_state=42)

Step 1: Profile the tag column before encoding

Question: which tags exist in the data, how common are they, and how messy is the delimiter formatting?

tag_col = "skills"  # replace with your tag column name

# 1. Tag prevalence across rows
tag_counts = df[tag_col].dropna().str.split(",").explode().str.strip().str.lower().value_counts()
print("Top 10 tags:\n", tag_counts.head(10))

# 2. Tag cleanliness and missingness
missing_ratio = df[tag_col].isna().mean()
raw_unique = df[tag_col].dropna().str.split(",").explode().str.strip().nunique()
lower_unique = len(tag_counts)
tags_per_row = df[tag_col].dropna().str.split(",").apply(len).describe()
print(f"Missing ratio: {missing_ratio:.2%}")
print(f"Unique tags (raw casing): {raw_unique}, Unique tags (lowercased): {lower_unique}")
print("Tags per row summary:\n", tags_per_row)
  • What to look for: Discrepancies between lowercase and raw unique counts (casing variants), extreme long tails of one-off tags, and high missingness.
  • Action: Use the observed tag frequencies to configure lowercase=True, cap vocabulary with max_features (default 500), and choose a clear column prefix.
  • Caution: Missing values produce all-zero indicator rows without errors; confirm if missing tags should be imputed or handled explicitly.

Step 2: Split-Safe Tag Feature Extraction (append_tags_to_frame)

Question: how do we binarize multi-label tag strings into numeric columns without leaking test tags into training?

from ds_utils.strings import append_tags_to_frame

train_encoded, test_encoded = append_tags_to_frame(
    train_df,
    test_df,
    field_name=tag_col,
    prefix="tag_",
    max_features=50,
    lowercase=True,
)
print("Engineered train columns:", [c for c in train_encoded.columns if c.startswith("tag_")][:5])
assert list(train_encoded.columns) == list(test_encoded.columns)
  • What to look for: Identical column names and order across train and test sets.
  • Action: Pass
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/api_reference.md

FAQ

Что делает скилл ds-utils-strings?

String preprocessing, split-safe tag encoding, and significant term extraction. Use for converting comma-separated tag columns into model-ready features across train/test splits, or discovering distinctive text terms in document cohorts. Do NOT use for sentence embeddings or general tabular preprocessing.

Как установить скилл ds-utils-strings?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл ds-utils-strings запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить ds-utils-strings с