<commit_before># tests.test_classifier.test_classification_report
# Tests for the classification report visualizer
#
# Author:  <NAME> <<EMAIL>>
# Author:  <NAME> <<EMAIL>>
# Created: Sun Mar 18 16:57:27 2018 -0400
#
# ID: test_classification_report.py [] <EMAIL> $

"""
Tests for the classification report visualizer
"""

##########################################################################
## Imports
##########################################################################

import sys
import pytest
import yellowbrick as yb
import matplotlib.pyplot as plt

from yellowbrick.classifier.classification_report import *

from tests.base import VisualTestCase
from tests.dataset import DatasetMixin

from sklearn.svm import LinearSVC
from sklearn.naive_bayes import GaussianNB
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split as tts
from sklearn.linear_model import LassoCV, LogisticRegression

try:
    import pandas as pd
except ImportError:
    pd = None


##########################################################################
##  Test for Classification Report
##########################################################################

@pytest.mark.usefixtures("binary", "multiclass")
class ClassificationReportTests(VisualTestCase, DatasetMixin):
    """
    ClassificationReport visualizer tests
    """

    def test_binary_class_report(self):
        """
        Correctly generates a report for binary classification with LinearSVC
        """
        _, ax = plt.subplots()

        viz = ClassificationReport(LinearSVC(), ax=ax)
        viz.fit(self.binary.X.train, self.binary.y.train)
        viz.score(self.binary.X.test, self.binary.y.test)

        self.assert_images_similar(viz, tol=35)

        assert viz.scores_ == {
            'precision': {0: 0.7446808510638298, 1: 0.8490566037735849},
            'recall': {0: 0.813953488372093, 1: 0.7894736842105263},
            'f1': {0: 0.7777777777777778, 1: 0.8181818181818182}<commit_msg>random state and approx on cr<commit_after># tests.test_classifier.test_classification_report
# Tests for the classification report visualizer
#
# Author:  <NAME> <<EMAIL>>
# Author:  <NAME> <<EMAIL>>
# Created: Sun Mar 18 16:57:27 2018 -0400
#
# ID: test_classification_report.py [] <EMAIL> $

"""
Tests for the classification report visualizer
"""

##########################################################################
## Imports
##########################################################################

import sys
import pytest
import yellowbrick as yb
import matplotlib.pyplot as plt

from yellowbrick.classifier.classification_report import *

from pytest import approx
from tests.base import VisualTestCase
from tests.dataset import DatasetMixin

from sklearn.svm import LinearSVC
from sklearn.naive_bayes import GaussianNB
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split as tts
from sklearn.linear_model import LassoCV, LogisticRegression

try:
    import pandas as pd
except ImportError:
    pd = None


##########################################################################
##  Test for Classification Report
##########################################################################

@pytest.mark.usefixtures("binary", "multiclass")
class ClassificationReportTests(VisualTestCase, DatasetMixin):
    """
    ClassificationReport visualizer tests
    """

    def test_binary_class_report(self):
        """
        Correctly generates a report for binary classification with LinearSVC
        """
        _, ax = plt.subplots()

        viz = ClassificationReport(LinearSVC(random_state=42), ax=ax)
        viz.fit(self.binary.X.train, self.binary.y.train)
        viz.score(self.binary.X.test, self.binary.y.test)

        self.assert_images_similar(viz, tol=35)

        assert viz.scores_ == {
            'precision': {0: approx(0.7446808), 1: approx(0.8490566)},
            'recall': {0: approx(0.8139534), 1: approx(0.7894736)},
            'f1': {0: approx(0.7777777), 1: approx(0.8181818)}
{'fraction_non_alphanumeric': 0.2236276849642005, 'fraction_numerical': 0.047971360381861575, 'mean_word_length': 4.788674033149171, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3744085', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1162, 'n_words': 290}