{"record":{"id":"926e80fb266167c9","repo":"open-mmlab/mmdetection","slug":"sscikit-learn-is-not-installed-pl-926e80","errorCode":null,"errorMessage":"sscikit-learn is not installed,                 please install it by: pip install scikit-learn","messagePattern":"sscikit-learn is not installed,                 please install it by: pip install scikit-learn","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mmdet/models/task_modules/tracking/kalman_filter.py","lineNumber":45,"sourceCode":"            Filter, which adaptively modulates the noise scale according to\n            the quality of detections. More details in\n            https://arxiv.org/abs/2202.11983. Defaults to False.\n    \"\"\"\n    chi2inv95 = {\n        1: 3.8415,\n        2: 5.9915,\n        3: 7.8147,\n        4: 9.4877,\n        5: 11.070,\n        6: 12.592,\n        7: 14.067,\n        8: 15.507,\n        9: 16.919\n    }\n\n    def __init__(self, center_only: bool = False, use_nsa: bool = False):\n        if not HAS_SCIPY:\n            raise RuntimeError('sscikit-learn is not installed,\\\n                 please install it by: pip install scikit-learn')\n        self.center_only = center_only\n        if self.center_only:\n            self.gating_threshold = self.chi2inv95[2]\n        else:\n            self.gating_threshold = self.chi2inv95[4]\n\n        self.use_nsa = use_nsa\n        ndim, dt = 4, 1.\n\n        # Create Kalman filter model matrices.\n        self._motion_mat = np.eye(2 * ndim, 2 * ndim)\n        for i in range(ndim):\n            self._motion_mat[i, ndim + i] = dt\n        self._update_mat = np.eye(ndim, 2 * ndim)\n\n        # Motion and observation uncertainty are chosen relative to the current\n        # state estimate. These weights control the amount of uncertainty in","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/task_modules/tracking/kalman_filter.py#L27-L63","documentation":"KalmanFilter for SORT/DeepSORT tracking needs scipy.linalg (cho_factor/cho_solve) for Mahalanobis gating. If scipy failed to import at module load, HAS_SCIPY is False and constructing the filter raises RuntimeError. The message text mentions scikit-learn but the actual missing package is scipy.","triggerScenarios":"Building any SORT/DeepSORT/ByteSORT tracker or motion=dict(type='KalmanFilter') in an environment where scipy is not installed.","commonSituations":"Minimal mmdetection install used for image detection, then a tracking config (sort_tracker, strongsort) is run; confusingly the error suggests installing scikit-learn, which does not fix it.","solutions":["pip install scipy (this is the actual missing dependency)","If it still fails, also install lap and motmetrics which the trackers need next","Ignore the misleading 'scikit-learn' wording; verify with python -c 'import scipy'"],"exampleFix":"# before: RuntimeError: sscikit-learn is not installed\n# after\npip install scipy lap motmetrics","handlingStrategy":"validation","validationCode":"import importlib.util\nassert importlib.util.find_spec('scipy') is not None, 'pip install scipy'","typeGuard":null,"tryCatchPattern":"try:\n    kf = KalmanFilter()\nexcept RuntimeError as e:\n    raise SystemExit('Tracking motion module needs scipy (message mentions scikit-learn but install scipy)')","preventionTips":["Note the message is misleading — scipy is the real dependency","Pre-install all tracking extras: pip install scipy lap motmetrics scikit-learn"],"tags":["mmdetection","tracking","missing-dependency","scipy","kalman-filter"],"backgroundTag":"missing-python-package","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}