Giter VIP home page Giter VIP logo

classificationreport's Introduction

ClassificationReport

분류 모델에 대한 평가 지표를 출력하는 코드

사용 예제

Example1

from classification_report import ClassificationReport
from pprint import pprint

y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]
target_names = ["class 0", "class 1", "class 2"]

matrix = ClassificationReport(class_name=target_names)
matrix.compute(y_true, y_pred)

print(matrix.print_report())
pprint(matrix.report_dict())
         precision    recall  f1_score  n_sample
 class 0     0.500     1.000     0.667         1
 class 1     0.000     0.000     0.000         1
 class 2     1.000     0.667     0.800         3
------------------------------------------------
accuracy     0.000     0.000     0.600         5

{'accuracy': 0.6,
 'class 0': {'f1_score': 0.6666666657777777,
             'n_sample': 1,
             'precision': 0.49999999975,
             'recall': 0.9999999989999999},
 'class 1': {'f1_score': 0.0, 'n_sample': 1, 'precision': 0.0, 'recall': 0.0},
 'class 2': {'f1_score': 0.7999999992,
             'n_sample': 3,
             'precision': 0.9999999995,
             'recall': 0.6666666664444444},
 'total_sample': 5}

Example2

from classification_report import ClassificationReport

y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]
target_names = ["class 0", "class 1", "class 2"]

matrix = ClassificationReport(class_name=target_names)
matrix.compute(y_true, y_pred)

print(matrix.print_report())

y_true2 = [2, 2, 1, 0, 0]
y_pred2 = [2, 1, 1, 0, 0]
matrix.compute(y_true2, y_pred2)

print(matrix.print_report())
         precision    recall  f1_score  n_sample
 class 0     0.500     1.000     0.667         1
 class 1     0.000     0.000     0.000         1
 class 2     1.000     0.667     0.800         3
------------------------------------------------
accuracy     0.000     0.000     0.600         5

         precision    recall  f1_score  n_sample
 class 0     0.750     1.000     0.857         3
 class 1     0.333     0.500     0.400         2
 class 2     1.000     0.600     0.750         5
------------------------------------------------
accuracy     0.000     0.000     0.700        10

Example3

from classification_report import ClassificationReport

y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]
target_names = ["class 0", "class 1", "class 2"]

matrix = ClassificationReport(class_name=target_names)
matrix.compute(y_true, y_pred)

print(matrix.print_report())

matrix.reset()

y_true2 = [2, 2, 1, 0, 0]
y_pred2 = [2, 1, 1, 0, 0]
matrix.compute(y_true2, y_pred2)

print(matrix.print_report())
         precision    recall  f1_score  n_sample
 class 0     0.500     1.000     0.667         1
 class 1     0.000     0.000     0.000         1
 class 2     1.000     0.667     0.800         3
------------------------------------------------
accuracy     0.000     0.000     0.600         5

         precision    recall  f1_score  n_sample
 class 0     1.000     1.000     1.000         2
 class 1     0.500     1.000     0.667         1
 class 2     1.000     0.500     0.667         2
------------------------------------------------
accuracy     0.000     0.000     0.800         5

classificationreport's People

Contributors

seoyoungdeok avatar

Watchers

 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.