Giter Site home page Giter Site logo

jeffzhengye / sklearn-evaluation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ploomber/sklearn-evaluation

0.0 2.0 0.0 6.39 MB

scikit-learn model evaluation made easy: plots, tables and markdown reports.

Home Page: http://edublancas.github.io/sklearn-evaluation

License: MIT License

Python 87.31% CSS 10.99% HTML 1.70%

sklearn-evaluation's Introduction

#sklearn-evaluation

Build Status PyPI version

scikit-learn model evaluation made easy: plots, tables and markdown reports.

Works with Python 2 and 3.

Documentation here.

Install

pip install sklearn-evaluation

Optional dependencies

If you want to use the reports module you need to install mistune and tabulate for the tables module

pip install mistune
pip install tabulate

#Usage

##plot module

Generate evaluation plots with a single function call.

from sklearn_evaluation import plot

#code for data loading and model training

plot.confusion_matrix(y_true, y_pred, target_names=target_names)

confusion matrix

##table module

Generate good looking tables from your model results.

from sklearn_evaluation import table

#code for data loading and training

table.feature_importances(model)
+-----------+--------------+-----------+
| name      |   importance |       std |
+===========+==============+===========+
| Feature 0 |    0.250398  | 0.0530907 |
+-----------+--------------+-----------+
| Feature 1 |    0.232397  | 0.0523836 |
+-----------+--------------+-----------+
| Feature 2 |    0.148898  | 0.0331814 |
+-----------+--------------+-----------+
| Feature 3 |    0.0553634 | 0.0128296 |
+-----------+--------------+-----------+
| Feature 8 |    0.05401   | 0.0122248 |
+-----------+--------------+-----------+
| Feature 5 |    0.053878  | 0.01289   |
+-----------+--------------+-----------+
| Feature 6 |    0.0525828 | 0.0130225 |
+-----------+--------------+-----------+
| Feature 9 |    0.0510197 | 0.0129436 |
+-----------+--------------+-----------+
| Feature 7 |    0.0509633 | 0.0117197 |
+-----------+--------------+-----------+
| Feature 4 |    0.0504887 | 0.012844  |
+-----------+--------------+-----------+

Also, running this in Jupyter will generate a pandas-like output.

##Using the OOP interface

A simplified API is available by packing the results of your estimator in the ClassifierEvaluator class.

from sklearn_evaluation import ClassifierEvaluator

# code for data loading and model training

ce = ClassifierEvaluator(classifier, y_test, y_pred, y_score,
                         feature_list, target_names)

# this plots the confusion matrix
ce.confusion_matrix

Generating reports

Generate reports using Markdown templates.

 
 template = '''
            # Report
            {estimator_type}
            {date}
            {confusion_matrix}
            {roc}
            {precision_recall}
            '''

ce.generate_report(template, path='report.html')

The code above will generate a report like this one.

Reports are self-contained, all images are included in the html file using base64.

sklearn-evaluation's People

Contributors

edublancas avatar

Watchers

James Cloos avatar Jeffery Ye avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.