{"id":9094,"library":"mapie","title":"MAPIE (Mapping Prediction Intervals)","description":"MAPIE (Mapping Prediction Intervals) is a scikit-learn-compatible Python library for estimating prediction intervals. It provides tools for both regression and classification tasks, leveraging conformal prediction methods to quantify uncertainty. The current version is 1.3.0, and the library maintains an active release cadence with several major and minor updates per year.","status":"active","version":"1.3.0","language":"en","source_language":"en","source_url":"https://github.com/scikit-learn-contrib/MAPIE","tags":["scikit-learn","conformal prediction","prediction intervals","machine learning","uncertainty quantification"],"install":[{"cmd":"pip install mapie","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for model training and compatibility, requires >=1.0, <1.4.","package":"scikit-learn","optional":false},{"reason":"Numerical routines, requires >=1.5.","package":"scipy","optional":false},{"reason":"Fundamental package for numerical computing, requires >=1.20.","package":"numpy","optional":false}],"imports":[{"note":"The v1.0.0 API rework moved regressors into the `mapie.regression` submodule.","wrong":"from mapie import MapieRegressor","symbol":"MapieRegressor","correct":"from mapie.regression import MapieRegressor"},{"note":"The v1.0.0 API rework moved classifiers into the `mapie.classification` submodule.","wrong":"from mapie import MapieClassifier","symbol":"MapieClassifier","correct":"from mapie.classification import MapieClassifier"},{"symbol":"MapieTimeSeriesRegressor","correct":"from mapie.time_series_regression import MapieTimeSeriesRegressor"},{"symbol":"BinaryClassificationController","correct":"from mapie.risk_control import BinaryClassificationController"}],"quickstart":{"code":"import numpy as np\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.datasets import make_regression\nfrom mapie.regression import MapieRegressor\n\n# 1. Generate synthetic data\nX, y = make_regression(n_samples=500, n_features=1, noise=20, random_state=42)\nX_train, X_test, y_train, y_test = train_test_split(\n    X, y, test_size=0.2, random_state=42\n)\n\n# 2. Fit a MAPIE regressor\nregressor = LinearRegression()\nmapie_regressor = MapieRegressor(regressor, cv=\"split\", random_state=42)\nmapie_regressor.fit(X_train, y_train)\n\n# 3. Predict prediction intervals\ny_pred, y_pis = mapie_regressor.predict(X_test, alpha=0.1)\n\n# 4. Print results (example)\nprint(f\"Predicted value for first test sample: {y_pred[0]:.2f}\")\nprint(f\"Prediction interval for first test sample: [{y_pis[0, 0, 0]:.2f}, {y_pis[0, 1, 0]:.2f}]\")","lang":"python","description":"This quickstart demonstrates how to use `MapieRegressor` to train a model and predict prediction intervals on synthetic regression data. It uses a `LinearRegression` model as the base estimator."},"warnings":[{"fix":"Update import statements (e.g., `from mapie.regression import MapieRegressor` instead of `from mapie import MapieRegressor`) and consult the v1.0.0 release notes and updated documentation.","message":"The v1.0.0 release introduced a major API rework, significantly changing import paths and the public API for classification and regression modules. Code written for versions prior to v1.0.0 will likely break.","severity":"breaking","affected_versions":"<1.0.0 to >=1.0.0"},{"fix":"If using risk control, update your code to pass risk names as strings (e.g., `risk_score_function=\"fdr\"`) instead of `BinaryClassificationRisk` objects.","message":"The risk control API in v1.2.0 changed how built-in risks are specified. Previously, users might have passed `BinaryClassificationRisk` objects, but now string representations are expected for built-in risks.","severity":"breaking","affected_versions":"<1.2.0 to >=1.2.0"},{"fix":"Ensure your Python environment is version 3.9 or higher. Consider using `pyenv` or `conda` to manage Python versions.","message":"MAPIE requires Python >=3.9. Attempting to install or run MAPIE on older Python versions will result in an error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify your `scikit-learn` version with `pip show scikit-learn` and upgrade or downgrade if necessary using `pip install 'scikit-learn>=1.0,<1.4'` (adjusting bounds as per current MAPIE documentation).","message":"MAPIE has specific scikit-learn version requirements (currently >=1.0, <1.4). Using an incompatible scikit-learn version may lead to runtime errors or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Update your import statement to use the correct submodule, e.g., `from mapie.regression import MapieRegressor` or `from mapie.classification import MapieClassifier`.","cause":"Attempting to import `MapieRegressor` or `MapieClassifier` directly from the top-level `mapie` package after the v1.0.0 API rework.","error":"ImportError: cannot import name 'MapieRegressor' from 'mapie'"},{"fix":"Pass the risk name as a string, e.g., `BinaryClassificationController(risk_score_function='fdr', ...)` instead of `BinaryClassificationController(risk_score_function=BinaryClassificationRisk('fdr'), ...)`.","cause":"Passing an instantiated `BinaryClassificationRisk` object to `BinaryClassificationController` after the v1.2.0 update, which now expects a string for built-in risks.","error":"TypeError: 'BinaryClassificationRisk' object is not callable"},{"fix":"Upgrade your Python environment to version 3.9 or higher.","cause":"Running MAPIE on an unsupported Python version.","error":"RuntimeError: Python version 3.8.x is not supported by MAPIE. Please use Python 3.9 or newer."}]}