{"id":27376,"library":"scikit-learn-stubs","title":"scikit-learn-stubs","description":"Type stubs for scikit-learn, providing static type information for type checkers like mypy and pyright. Current version 0.0.3, updated 2025; low release cadence. Maintained by Microsoft via the python-type-stubs repository, forked by hoel-bagard.","status":"active","version":"0.0.3","language":"python","source_language":"en","source_url":"https://github.com/hoel-bagard/scikit-learn-stubs","tags":["scikit-learn","type-stubs","mypy","pyright","type-hints"],"install":[{"cmd":"pip install scikit-learn-stubs","lang":"bash","label":"pip install"}],"dependencies":[{"reason":"Runtime dependency; stubs provide types for scikit-learn","package":"scikit-learn","optional":false},{"reason":"Required for some type annotations","package":"typing_extensions","optional":true}],"imports":[{"note":"Correct import; stubs do not change import paths.","wrong":null,"symbol":"sklearn.linear_model.LogisticRegression","correct":"from sklearn.linear_model import LogisticRegression"}],"quickstart":{"code":"from sklearn.linear_model import LogisticRegression\nimport numpy as np\n\n# Example usage with type hints (stubs enable type checking)\nmodel: LogisticRegression = LogisticRegression()\nX = np.array([[0, 0], [1, 1]])\ny = np.array([0, 1])\nmodel.fit(X, y)\nprint(model.predict([[0.5, 0.5]]))","lang":"python","description":"Basic scikit-learn usage with type stubs enabled. The stubs are automatically discovered by mypy/pyright when installed."},"warnings":[{"fix":"Check the stub coverage in the repository before relying on types for rarely used estimators.","message":"Stubs may not cover all scikit-learn modules or parameters, especially experimental ones. Use strict type checking cautiously.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider using the official scikit-learn type stubs from scikit-learn itself (if available in future) or contribute to this fork.","message":"The original Microsoft python-type-stubs repository is archived. This fork may become outdated relative to new scikit-learn releases.","severity":"deprecated","affected_versions":"0.0.x"},{"fix":"Pin exact version in requirements: scikit-learn-stubs==0.0.3","message":"Version 0.0.x is pre-1.0. Breaking changes in stub types may occur between minor versions.","severity":"breaking","affected_versions":"<1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: pip install scikit-learn-stubs","cause":"The stubs package is not installed or not compatible with the installed scikit-learn version.","error":"Cannot find implementation or library stub for module 'sklearn'"},{"fix":"Upgrade scikit-learn and stubs: pip install --upgrade scikit-learn scikit-learn-stubs","cause":"Outdated stub files missing some estimators; or incorrect scikit-learn version.","error":"Module 'sklearn.linear_model' has no attribute 'LogisticRegression'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}