{
  "id": "python/sklearn-notfitted-error",
  "signature": "sklearn.exceptions.NotFittedError: This StandardScaler instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.",
  "signature_zh": "sklearn.exceptions.NotFittedError: 此 StandardScaler 实例尚未拟合。请先使用适当参数调用 'fit'。",
  "regex": "sklearn\\.exceptions\\.NotFittedError:\\ This\\ StandardScaler\\ instance\\ is\\ not\\ fitted\\ yet\\.\\ Call\\ 'fit'\\ with\\ appropriate\\ arguments\\ before\\ using\\ this\\ estimator\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling transform/predict on an estimator before fit, or using a fresh estimator inside a pipeline instead of the fitted one.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 fit 之前调用 transform/predict，或在管道中使用了未拟合的新估计器。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Same error, no fitted state",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "StandardScaler supports partial_fit but requires correct usage; often yields wrong stats",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "scaler = StandardScaler().fit(X_train); X_test_s = scaler.transform(X_test)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Wrap in Pipeline([('scaler', StandardScaler()), ('clf', LogisticRegression())]) so fit handles all steps",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}