ml-insights


Nameml-insights JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttp://ml-insights.readthedocs.io/en/latest/
SummaryPackage to calibrate and understand ML Models
upload_time2023-09-28 20:29:57
maintainer
docs_urlNone
authorBrian Lucena / Ramesh Sampath
requires_python
licenseMIT license
keywords ml_insights
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ML Insights
===========

Welcome to ML-Insights!

This package contains two core sets of functions:

1) Calibration
2) Interpreting Models

For probability calibration, the main class is `SplineCalib`.  Given a set of model outputs and the "true" classes, you can `fit` a SplineCalib object.  That object can then be used to `calibrate` future model predictions post-hoc.

.. code-block:: python

    >>> model.fit(X_train, y_train)
    >>> sc = mli.SplineCalib()
    >>> sc.fit(X_valid, y_valid)
    >>> uncalib_preds = model.predict_proba(X_test)
    >>> calib_preds = sc.calibrate(uncalib_preds)


.. code-block:: python

    >>> cv_preds = mli.cv_predictions(model, X_train, y_train)
    >>> model.fit(X_train, y_train)
    >>> sc = mli.SplineCalib()
    >>> sc.fit(cv_preds, y_train)
    >>> uncalib_preds = model.predict_proba(X_test)
    >>> calib_preds = sc.calibrate(uncalib_preds)



For model interpretability, we provide the `ice_plot` and `histogram_pair` functions as well as other tools.


.. code-block:: python

    >>> rd = mli.get_range_dict(X_train)
    >>> mli.ice_plot(model, X_test.sample(3), X_train.columns, rd)

.. code-block:: python

    >>> mli.histogram_pair(df.outcome, df.feature, bins=np.linspace(0,100,11))

Please see the documentation and examples at the links below.


- `Documentation <https://ml-insights.readthedocs.io>`_
- `Notebook Examples and Usage <https://github.com/numeristical/introspective/tree/master/examples>`_


Python
------
Python 3.4+


Disclaimer
==========

We have tested this tool to the best of our ability, but understand that it may have bugs.  It was most recently developed on Python 3.7.3.  Use at your own risk, but feel free to report any bugs to our github. <https://github.com/numeristical/introspective>


Installation
=============

.. code-block:: bash

    $ pip install ml_insights


Usage
======

.. code-block:: python

    >>> import ml_insights as mli
    >>> xray = mli.ModelXRay(model, data)

.. code-block:: python

	>>> rfm = RandomForestClassifier(n_estimators = 500, class_weight='balanced_subsample')
	>>> rfm_cv = mli.SplineCalibratedClassifierCV(rfm)
	>>> rfm_cv.fit(X_train,y_train)
	>>> test_res_calib_cv = rfm_cv.predict_proba(X_test)[:,1]
	>>> log_loss(y_test,test_res_calib_cv)

Source
======

Find the latest version on github: https://github.com/numeristical/introspective

Feel free to fork and contribute!

License
=======

Free software: `MIT license <LICENSE>`_

Developed By
============

- Brian Lucena
- Ramesh Sampath

References
==========

Alex Goldstein, Adam Kapelner, Justin Bleich, and Emil Pitkin. 2014. Peeking Inside the Black Box: Visualizing Statistical Learning With Plots of Individual Conditional Expectation. Journal of Computational and Graphical Statistics (March 2014)

            

Raw data

            {
    "_id": null,
    "home_page": "http://ml-insights.readthedocs.io/en/latest/",
    "name": "ml-insights",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ml_insights",
    "author": "Brian Lucena / Ramesh Sampath",
    "author_email": "brianlucena@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/14/84/abac47c6e1dac9740edd22e9ecb175a1d39c8bdff8a491888584ebd09723/ml_insights-1.0.3.tar.gz",
    "platform": null,
    "description": "ML Insights\n===========\n\nWelcome to ML-Insights!\n\nThis package contains two core sets of functions:\n\n1) Calibration\n2) Interpreting Models\n\nFor probability calibration, the main class is `SplineCalib`.  Given a set of model outputs and the \"true\" classes, you can `fit` a SplineCalib object.  That object can then be used to `calibrate` future model predictions post-hoc.\n\n.. code-block:: python\n\n    >>> model.fit(X_train, y_train)\n    >>> sc = mli.SplineCalib()\n    >>> sc.fit(X_valid, y_valid)\n    >>> uncalib_preds = model.predict_proba(X_test)\n    >>> calib_preds = sc.calibrate(uncalib_preds)\n\n\n.. code-block:: python\n\n    >>> cv_preds = mli.cv_predictions(model, X_train, y_train)\n    >>> model.fit(X_train, y_train)\n    >>> sc = mli.SplineCalib()\n    >>> sc.fit(cv_preds, y_train)\n    >>> uncalib_preds = model.predict_proba(X_test)\n    >>> calib_preds = sc.calibrate(uncalib_preds)\n\n\n\nFor model interpretability, we provide the `ice_plot` and `histogram_pair` functions as well as other tools.\n\n\n.. code-block:: python\n\n    >>> rd = mli.get_range_dict(X_train)\n    >>> mli.ice_plot(model, X_test.sample(3), X_train.columns, rd)\n\n.. code-block:: python\n\n    >>> mli.histogram_pair(df.outcome, df.feature, bins=np.linspace(0,100,11))\n\nPlease see the documentation and examples at the links below.\n\n\n- `Documentation <https://ml-insights.readthedocs.io>`_\n- `Notebook Examples and Usage <https://github.com/numeristical/introspective/tree/master/examples>`_\n\n\nPython\n------\nPython 3.4+\n\n\nDisclaimer\n==========\n\nWe have tested this tool to the best of our ability, but understand that it may have bugs.  It was most recently developed on Python 3.7.3.  Use at your own risk, but feel free to report any bugs to our github. <https://github.com/numeristical/introspective>\n\n\nInstallation\n=============\n\n.. code-block:: bash\n\n    $ pip install ml_insights\n\n\nUsage\n======\n\n.. code-block:: python\n\n    >>> import ml_insights as mli\n    >>> xray = mli.ModelXRay(model, data)\n\n.. code-block:: python\n\n\t>>> rfm = RandomForestClassifier(n_estimators = 500, class_weight='balanced_subsample')\n\t>>> rfm_cv = mli.SplineCalibratedClassifierCV(rfm)\n\t>>> rfm_cv.fit(X_train,y_train)\n\t>>> test_res_calib_cv = rfm_cv.predict_proba(X_test)[:,1]\n\t>>> log_loss(y_test,test_res_calib_cv)\n\nSource\n======\n\nFind the latest version on github: https://github.com/numeristical/introspective\n\nFeel free to fork and contribute!\n\nLicense\n=======\n\nFree software: `MIT license <LICENSE>`_\n\nDeveloped By\n============\n\n- Brian Lucena\n- Ramesh Sampath\n\nReferences\n==========\n\nAlex Goldstein, Adam Kapelner, Justin Bleich, and Emil Pitkin. 2014. Peeking Inside the Black Box: Visualizing Statistical Learning With Plots of Individual Conditional Expectation. Journal of Computational and Graphical Statistics (March 2014)\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "Package to calibrate and understand ML Models",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "http://ml-insights.readthedocs.io/en/latest/"
    },
    "split_keywords": [
        "ml_insights"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47e9800a2a5cd718ef9df9b893c1da29762594719eb0cbec1807cd9da6d2c166",
                "md5": "aa5186d52117687a7288db637d3684cb",
                "sha256": "fcac83d9f157e75d7c906ea098566cca7881343795fc2d37b62b62e8ea85af9f"
            },
            "downloads": -1,
            "filename": "ml_insights-1.0.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa5186d52117687a7288db637d3684cb",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 37834,
            "upload_time": "2023-09-28T20:29:55",
            "upload_time_iso_8601": "2023-09-28T20:29:55.813906Z",
            "url": "https://files.pythonhosted.org/packages/47/e9/800a2a5cd718ef9df9b893c1da29762594719eb0cbec1807cd9da6d2c166/ml_insights-1.0.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1484abac47c6e1dac9740edd22e9ecb175a1d39c8bdff8a491888584ebd09723",
                "md5": "5d3e373899ddfb56e2e9d4764169f082",
                "sha256": "5e903a35ea121e2f1b1460b19ca93ef093508df97ceea96a5a00e624784acaad"
            },
            "downloads": -1,
            "filename": "ml_insights-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "5d3e373899ddfb56e2e9d4764169f082",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 25486,
            "upload_time": "2023-09-28T20:29:57",
            "upload_time_iso_8601": "2023-09-28T20:29:57.820455Z",
            "url": "https://files.pythonhosted.org/packages/14/84/abac47c6e1dac9740edd22e9ecb175a1d39c8bdff8a491888584ebd09723/ml_insights-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-28 20:29:57",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "ml-insights"
}
        
Elapsed time: 0.11976s