models/train_classifier.py
def evaluate_model(model, X_text, Y_test, category_names):
    """The evaluate_model function scores the performance of trained model
        on test (unseen) text and categories

    Args:
        model (model): model to evaluate
        X_text (numpy arrays): the test (unseen) tokenized text
        Y_test (numpy arrays): the test (unseen) target used for evaluation
        category_names(list): list containing the name of the categories

    Returns: None
            print out the accuracy and confusion metrics

    """
    sp = {"end": "\n\n", "sep": "\n\n"}

    # predict using the model
    pred = model.predict(X_text)

    # Calculate accuracy
    accuracy = (pred == Y_test).mean()
    accuracyscore = model.score(X_text, Y_test)
    
    
    print(f"Model Accuracy: {accuracy*100:.02f}%\n")
    print(f"Model Accuracy: {accuracyscore*100:.02f}%\n")


    for i, label in enumerate(category_names):
        print("Printing for ", label)
        print(classification_report(Y_test[i] , pred[i]), **sp)
The evaluate_model function scores the performance of trained model
        on test (unseen) text and categories

    Args:
        model (model): model to evaluate
        X_text (numpy arrays): the test (unseen) tokenized text
        Y_test (numpy arrays): the test (unseen) target used for evaluation
        category_names(list): list containing the name of the categories

    Returns: None
            print out the accuracy and confusion metrics

    
The evaluate_model function scores the performance of trained model
on test (unseen) text and categories
The evaluate_model function scores the performance of trained model on test ( unseen ) text and categories
def evaluate_model(model, X_text, Y_test, category_names):
    sp = {"end": "\n\n", "sep": "\n\n"}
    pred = model.predict(X_text)
    accuracy = (pred == Y_test).mean()
    accuracyscore = model.score(X_text, Y_test)
    print(f"Model Accuracy: {accuracy*100:.02f}%\n")
    print(f"Model Accuracy: {accuracyscore*100:.02f}%\n")
    for i, label in enumerate(category_names):
        print("Printing for ", label)
        print(classification_report(Y_test[i] , pred[i]), **sp)
def evaluate_model ( model , X_text , Y_test , category_names ) : sp = { "end" : "\n\n" , "sep" : "\n\n" } pred = model . predict ( X_text ) accuracy = ( pred == Y_test ) . mean ( ) accuracyscore = model . score ( X_text , Y_test ) print ( f"Model Accuracy: {accuracy*100:.02f}%\n" ) print ( f"Model Accuracy: {accuracyscore*100:.02f}%\n" ) for i , label in enumerate ( category_names ) : print ( "Printing for " , label ) print ( classification_report ( Y_test [ i ] , pred [ i ] ) , ** sp )
The evaluate_model function scores the performance of trained model
on test (unseen) text and categories
The evaluate_model function scores the performance of trained model on test ( unseen ) text and categories
"""The evaluate_model function scores the performance of trained model
        on test (unseen) text and categories

    Args:
        model (model): model to evaluate
        X_text (numpy arrays): the test (unseen) tokenized text
        Y_test (numpy arrays): the test (unseen) target used for evaluation
        category_names(list): list containing the name of the categories

    Returns: None
            print out the accuracy and confusion metrics

    """ # predict using the model # Calculate accuracy
model
model to evaluate
model to evaluate
X_text
the test (unseen) tokenized text
the test ( unseen ) tokenized text
Y_test
the test (unseen) target used for evaluation
the test ( unseen ) target used for evaluation
category_names
list containing the name of the categories
list containing the name of the categories