debug:scikit-learn

Diagnose scikit-learn debugging issues in training and testing workflows.

9|1|Updated Jan 12, 2026
One-click install
npx skills add https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin --skill debug-scikit-learn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: debug:scikit-learn
Source: https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin/tree/main/plugins/debug-and-refactor/skills/debug-scikit-learn
Command: npx skills add https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin --skill debug-scikit-learn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps diagnose and fix common scikit-learn debugging issues in ML workflows, including NotFittedError, shape mismatches between training and test data, NaN or infinity values, and pipeline/configuration problems that hinder model performance.

Core Features & Use Cases

  • NotFittedError identification and guidance: Detects when a model is used before fitting and provides practical steps to train before evaluation.
  • Shape alignment and preprocessing validation: Verifies train/test feature compatibility and ensures consistent preprocessing with Pipelines and ColumnTransformer.
  • NaN/Inf data quality checks and imputation advice: Detects missing or infinite values and suggests appropriate imputation strategies.
  • Pipeline integrity and cross-validation debugging: Validates each pipeline step, flags misconfigurations, and helps diagnose leakage or over/underfitting across CV schemes.

Quick Start

Provide your X_train, y_train, X_test, y_test, and the scikit-learn pipeline to receive diagnostics and recommended fixes.

Frequently Asked Questions about debug:scikit-learn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my scikit-learn pipeline throw a NotFittedError during prediction?

A NotFittedError occurs when calling predict or transform before fitting the scikit-learn pipeline. You must call fit or fit_transform on the estimator first to ensure weights are trained before evaluation.

How do I fix feature shape mismatches between training and test data in scikit-learn?

Fix feature shape mismatches by verifying train and test datasets have identical column counts and preprocessing transformations. Use Pipeline and ColumnTransformer consistently to enforce shape alignment across splits.

What is the best way to handle NaN and infinity values before fitting a scikit-learn model?

Handle NaN and Inf values by detecting missing data points and applying imputation strategies. Use scikit-learn SimpleImputer within a Pipeline to replace invalid values before model fitting.

Does scikit-learn cross-validation cause data leakage when using ColumnTransformer?

Cross-validation data leakage occurs if preprocessing steps like scaling or imputation are applied globally before splitting. Fit the ColumnTransformer exclusively within each CV fold using a Pipeline to prevent leakage.

How do I resolve convergence warnings in scikit-learn classification models?

Resolve convergence warnings by scaling input features, increasing max_iter parameters, or simplifying the model. Diagnose optimization limits to ensure the algorithm reaches acceptable tolerance during training.