L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Design et création · SKILL.md

text-and-datasets

text-and-datasets

Use Yellowbrick dataset loaders, cache controls, and text visualizers for tabular data, corpora, and text embeddings.

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: text-and-datasets description: "Use Yellowbrick dataset loaders, cache controls, and text visualizers for tabular data, corpora, and text embeddings." disable-model-invocation: true metadata: disco-role: operating license: Apache 2.0

Yellowbrick Text and Datasets

Use this sub-skill when the task is about Yellowbrick dataset loading, dataset cache/download behavior, the load_* helpers, the hobbies corpus, or text-specific visualizers. It covers FreqDistVisualizer, TSNEVisualizer, UMAPVisualizer, DispersionPlot, WordCorrelationPlot, and PosTagVisualizer.

For package-wide Yellowbrick lifecycle, axes reuse, style, and headless saving, read shared visualizer patterns. For broad install, Matplotlib backend/font, and scikit-learn compatibility failures, read the root troubleshooting reference before applying text/dataset-specific fixes.

Use this sub-skill for

  • Choosing among Yellowbrick example datasets and matching them to regression, classification, clustering, time-series-style, or text-analysis tasks.
  • Loading tabular datasets with load_bikeshare(), load_concrete(), load_credit(), load_energy(), load_game(), load_mushroom(), load_occupancy(), load_spam(), load_walking(), or load_nfl().
  • Loading the hobbies corpus with load_hobbies() and using Corpus.data, Corpus.target, Corpus.labels, or Corpus.files.
  • Deciding between default X, y returns, return_dataset=True, to_numpy(), to_pandas(), and to_dataframe().
  • Controlling or inspecting the dataset cache with data_home, YELLOWBRICK_DATA, and the no-download cache inspector.
  • Using text visualizers after the corpus is already vectorized, tokenized, or part-of-speech tagged.
  • Explaining optional extras: pandas for DataFrame returns, umap-learn for UMAPVisualizer, and nltk/spacy plus data/models for parser-based POS tagging.

Route elsewhere when

  • The user has already loaded data and now wants classifier score plots such as reports, confusion matrices, ROC/PR curves, or threshold tuning: route to classifier visualizers.
  • The user wants residuals, prediction error, Cook's distance, or alpha selection: route to regressor visualizers.
  • The user wants feature ranking, PCA/manifold feature projections, class balance, binning, or feature-target correlation: route to feature-target visualizers.
  • The user wants clustering diagnostics, validation/learning curves, CV scores, RFECV, feature importances, or dropping curves: route to cluster-model-selection.
  • The user asks about contrib wrappers, decision boundaries, missing-value contrib plots, or statsmodels adapters: route to contrib-and-extensions.

Required read and run map

NeedRead or runWhen to use it
Dataset names, task fit, load_*, return types, Dataset/Corpus, cache rules, downloader flags, and offline behaviordatasets referenceRead before giving loader code, cache advice, or no-network guidance.
Text visualizer selection, exact input formats, optional extras, and safe file outputtext visualizers referenceRead before using any yellowbrick.text visualizer or diagnosing text input-shape errors.
Dataset cache/download/signature/offline failures, missing optional dependencies, wrong class names, parser/tagset errors, and display/font warningstext/dataset troubleshootingRead after any failure symptom or before advising a risky cleanup/download action.
Common Yellowbrick fit/score/transform/show(outpath=...), Matplotlib Agg, axes, and style rulesshared visualizer patternsRead before writing report-quality code or headless automation.
Broad installation, backend, font, or scikit-learn compatibility issuesroot troubleshootingRead when the problem is not specific to text or datasets.
No-download cache inspectioncheck_dataset_cache.pyRun when the user is offline, wants to know what is already cached, or needs signature/cache state without downloads or deletes.
Safe text plotting smoketext_smoke.pyRun to confirm yellowbrick.text can render inline synthetic text plots with Matplotlib Agg; it uses no external data and no optional downloads.

Example safe runs from an environment where Yellowbrick is importable:

python skills/disco/yellowbrick/sub-skills/text-and-datasets/scripts/check_dataset_cache.py --dataset hobbies
python skills/disco/yellowbrick/sub-skills/text-and-datasets/scripts/text_smoke.py --outdir /tmp/yellowbrick-text-smoke

Dataset quick map

LoaderObjectShape or sizeBest fitNotes
load_bikeshare()DatasetX=(17379, 12)regressionBike sharing demand examples.
load_concrete()DatasetX=(1030, 8)regressionSmall, numeric, good for regressor demos.
load_credit()DatasetX=(30000, 23)binary classification / clusteringCredit default data; can be large for quick CV examples.
load_energy()DatasetX=(768, 8)regression / multi-output source dataDefault y is the documented primary target.
load_game()DatasetX=(67557, 42)multiclass classificationCategorical features usually need encoding before sklearn estimators.
load_hobbies()Corpus448 docs, 5 labelstext analysis / classification / clusteringReturns a Corpus, not X, y; use corpus.data and corpus.target.
load_mushroom()DatasetX=(8123, 3)binary classification / clusteringCategorical mushroom attributes need preprocessing for many estimators.
load_occupancy()DatasetX=(20560, 5)binary classificationMultivariate time-series-style occupancy data.
load_spam()DatasetX=(4600, 57)binary classification / threshold analysisUseful for threshold and imbalance demonstrations.
load_walking()DatasetX=(149332, 4)clustering / time-series-style diagnosticsLarge row count; sample for quick visual checks.
load_nfl()DatasetX=(494, 23)clusteringFootball receiver clustering examples.

Text visualizer quick map

VisualizerInput requiredBest fitConstraints
FreqDistVisualizerCount-vectorized document matrix plus feature namesTop-token counts in a corpus or by classUse FreqDistVisualizer, not FrequencyVisualizer, in public guidance.
TSNEVisualizerNumeric vectorized corpus matrix2D document embedding and class/cluster separationt-SNE is expensive; vectorize first and lower perplexity for tiny samples.
UMAPVisualizerNumeric vectorized corpus matrix2D document embedding with UMAPRequires optional umap-learn; use metric="cosine" for many text vectors.
DispersionPlotTokenized documents: list/generator of token listsLexical dispersion of known terms across documentsSearch terms must survive tokenization and casing.
WordCorrelationPlotRaw text documents: list/generator of stringsWord or phrase co-occurrence heatmapEvery requested word/phrase must appear in the corpus.
PosTagVisualizerPre-tagged nested docs or raw text with parserPOS tag distributionsPrefer pre-tagged tuples for no-optional-dependency smoke checks.

Canonical dataset pattern

from yellowbrick.datasets import load_concrete, load_hobbies

# Tabular data: pandas DataFrame/Series if pandas is installed, otherwise numpy arrays.
X, y = load_concrete()

# Request the object when you need metadata or explicit return control.
dataset = load_concrete(return_dataset=True)
X_np, y_np = dataset.to_numpy()

# Text corpus loaders return Corpus objects, not X/y directly.
corpus = load_hobbies()
docs = corpus.data
target = corpus.target
labels = corpus.labels

Canonical text pattern

import matplotlib
matplotlib.use("Agg")  # set before pyplot in headless sessions

from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
from yellowbrick.text import FreqDistVisualizer, TSNEVisualizer

count_vectorizer = CountVectorizer()
X_counts = count_vectorizer.fit_transform(docs)
features = count_vectorizer.get_feature_names_out()

freq = FreqDistVisualizer(features=features)
freq.fit(X_counts, target)
freq.show(outpath="freqdist.png", clear_figure=True)

X_tfidf = TfidfVectorizer().fit_transform(docs)
tsne = TSNEVisualizer(random_state=13, perplexity=10)
tsne.fit(X_tfidf, target)
tsne.show(outpath="tsne.png", clear_figure=True)

Safety checklist

  • Do not call a loader in offline mode unless its dataset directory already exists in the selected cache; missing data triggers Yellowbrick's downloader.
  • Use the cache inspector before telling an offline user that a loader will work.
  • Use return_dataset=True only on tabular loaders; load_hobbies() already returns a Corpus object.
  • Confirm whether pandas is installed before promising DataFrame/Series returns; numpy arrays are the normal fallback.
  • Confirm text input state: raw strings for vectorizers and WordCorrelationPlot, token lists for DispersionPlot, numeric vectors for TSNE/UMAP, and nested (token, tag) tuples for parser-free POS visualization.
  • Confirm optional dependencies before recommending UMAPVisualizer or raw-text parser mode for PosTagVisualizer.
  • Save figures with a non-interactive backend and class visualizer API when the output must be a file.
Skills enregistrées