# gaitsetpy.classification.utils.eval

For evaluation of a classification model

Maintainer: @aharshit123456

View Source

     1'''
     2For evaluation of a classification model
     3
     4Maintainer: @aharshit123456
     5'''
     6
     7from sklearn.metrics import accuracy_score, confusion_matrix
     8from sklearn.model_selection import train_test_split
     9from .preprocess import preprocess_features
    10
    11def evaluate_model(model, features):
    12    """
    13    Evaluates the given model on the provided features and prints accuracy and confusion matrix.
    14    """
    15    X, y = preprocess_features(features)
    16    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
    17
    18    y_pred = model.predict(X_test)
    19
    20    acc = accuracy_score(y_test, y_pred)
    21    # conf_matrix = confusion_matrix(y_test, y_pred)
    22
    23    print(f"Accuracy: {acc:.4f}")
    24    # print(f"Confusion Matrix:\n{conf_matrix}")

def evaluate_model(model, features): View Source

    12def evaluate_model(model, features):
    13    """
    14    Evaluates the given model on the provided features and prints accuracy and confusion matrix.
    15    """
    16    X, y = preprocess_features(features)
    17    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
    18
    19    y_pred = model.predict(X_test)
    20
    21    acc = accuracy_score(y_test, y_pred)
    22    # conf_matrix = confusion_matrix(y_test, y_pred)
    23
    24    print(f"Accuracy: {acc:.4f}")
    25    # print(f"Confusion Matrix:\n{conf_matrix}")

Evaluates the given model on the provided features and prints accuracy and confusion matrix.