def results(x_true, x_pred, y_true, y_pred, classes, params, path=None, name=None):
    if ((path is None) and (name is None)):
        path = f"models/{params['model_type']}/{params['exp_name']}/"
        name = f"{params['model_type']}-{params['exp_name']}"
    Path(path).mkdir(parents=True, exist_ok=True)
    log_file = open(f'{path}log.json', 'w')
    json.dump(params, log_file, indent=4)
    x_pred_ = x_pred.argmax(dim=1)
    report = classification_report(x_true, x_pred_, target_names=classes, output_dict=True)
    df_classification_report = pd.DataFrame(report).transpose()
    accuracy_report = df_classification_report.tail(3)
    accuracy_report.to_csv((path + 'train_accuracy_report.csv'))
    df_classification_report.drop(df_classification_report.tail(3).index, inplace=True)
    df_classification_report = df_classification_report.sort_values(by=['f1-score'], ascending=False)
    df_classification_report.to_csv((path + 'train_classification_report.csv'))
    x_true_ohe = np.zeros((len(x_pred), len(classes)))
    for (idx, lbl) in enumerate(x_true):
        x_true_ohe[idx][lbl] = 1
    x_pred = x_pred.detach().numpy()
    plot_multiclass_roc(x_true_ohe, x_pred, classes=classes, path=path, name=('train-' + name))
    cm = confusion_matrix(x_true, x_pred_)
    plot_confusion_matrix(cm, classes, path=path, name=('train-' + name))
    y_pred_ = y_pred.argmax(dim=1)
    report = classification_report(y_true, y_pred_, target_names=classes, output_dict=True)
    df_classification_report = pd.DataFrame(report).transpose()
    accuracy_report = df_classification_report.tail(3)
    accuracy_report.to_csv((path + 'test-accuracy_report.csv'))
    df_classification_report.drop(df_classification_report.tail(3).index, inplace=True)
    df_classification_report = df_classification_report.sort_values(by=['f1-score'], ascending=False)
    df_classification_report.to_csv((path + 'test-classification_report.csv'))
    y_true_ohe = np.zeros((len(y_pred), len(classes)))
    for (idx, lbl) in enumerate(y_true):
        y_true_ohe[idx][lbl] = 1
    y_pred = y_pred.detach().numpy()
    plot_multiclass_roc(y_true_ohe, y_pred, classes=classes, path=path, name=('test-' + name))
    cm = confusion_matrix(y_true, y_pred_)
    plot_confusion_matrix(cm, classes, path=path, name=('test-' + name))
def results(x_true, x_pred, y_true, y_pred, classes, params, path=None, name=None):
    if ((path is None) and (name is None)):
        path = f"models/{params['model_type']}/{params['exp_name']}/"
        name = f"{params['model_type']}-{params['exp_name']}"
    Path(path).mkdir(parents=True, exist_ok=True)
    log_file = open(f'{path}log.json', 'w')
    json.dump(params, log_file, indent=4)
    x_pred_ = x_pred.argmax(dim=1)
    report = classification_report(x_true, x_pred_, target_names=classes, output_dict=True)
    df_classification_report = pd.DataFrame(report).transpose()
    accuracy_report = df_classification_report.tail(3)
    accuracy_report.to_csv((path + 'train_accuracy_report.csv'))
    df_classification_report.drop(df_classification_report.tail(3).index, inplace=True)
    df_classification_report = df_classification_report.sort_values(by=['f1-score'], ascending=False)
    df_classification_report.to_csv((path + 'train_classification_report.csv'))
    x_true_ohe = np.zeros((len(x_pred), len(classes)))
    for (idx, lbl) in enumerate(x_true):
        x_true_ohe[idx][lbl] = 1
    x_pred = x_pred.detach().numpy()
    plot_multiclass_roc(x_true_ohe, x_pred, classes=classes, path=path, name=('train-' + name))
    cm = confusion_matrix(x_true, x_pred_)
    plot_confusion_matrix(cm, classes, path=path, name=('train-' + name))
    y_pred_ = y_pred.argmax(dim=1)
    report = classification_report(y_true, y_pred_, target_names=classes, output_dict=True)
    df_classification_report = pd.DataFrame(report).transpose()
    accuracy_report = df_classification_report.tail(3)
    accuracy_report.to_csv((path + 'test-accuracy_report.csv'))
    df_classification_report.drop(df_classification_report.tail(3).index, inplace=True)
    df_classification_report = df_classification_report.sort_values(by=['f1-score'], ascending=False)
    df_classification_report.to_csv((path + 'test-classification_report.csv'))
    y_true_ohe = np.zeros((len(y_pred), len(classes)))
    for (idx, lbl) in enumerate(y_true):
        y_true_ohe[idx][lbl] = 1
    y_pred = y_pred.detach().numpy()
    plot_multiclass_roc(y_true_ohe, y_pred, classes=classes, path=path, name=('test-' + name))
    cm = confusion_matrix(y_true, y_pred_)
    plot_confusion_matrix(cm, classes, path=path, name=('test-' + name))