def get_features_importance(model, feature_names, top=10):
    # graph
    terminal.markdown_h2("Top {} Feature Importances".format(top))
    print()

    feature_importances = model.feature_importances_
    df_feature_importances = pd.DataFrame({"importance": feature_importances}, index=feature_names) \
        .sort_values('importance', ascending=False)

    top_df = df_feature_importances.head(top)
    graphs.bars(top_df["importance"],
                percentage_on_top=False,
                title='Feature Importances',
                ylabel="Importance",
                xlabel="Feature",
                data_processed=True)

    # break line
    print("\n")

    # table
    terminal.markdown_h2("Feature Importances")
    print()

    table = [["Feature", "Importance"]]
    content = []
    for i, x in enumerate(feature_importances):
        content.append([feature_names[i], round(x, 3)])

    content.sort(key=lambda x: x[1], reverse=True)

    table += content

    terminal.markdown_table(table)
Exemple #2
0
def metrics_table(historys):
    terminal.markdown_h2("Metrics Table")
    print()
    header = [
        "Neurons", "Accuracy", "Max Accuracy", "Epoch Max Acc.", "Loss",
        "Min Loss", "Epoch Min Loss"
    ]

    table = [header]

    # metrics table
    for neurons, history in historys:
        # accuracy
        accuracy = history['val_accuracy'][-1]
        max_accuracy = max(history['val_accuracy'])
        idx_max_accuracy = history['val_accuracy'].index(max_accuracy) + 1

        # loss
        loss = history['val_loss'][-1]
        min_loss = min(history['val_loss'])
        idx_min_loss = history['val_loss'].index(min_loss) + 1

        row = [
            neurons,
            round(accuracy, 3),
            round(max_accuracy, 3),
            round(idx_max_accuracy),
            round(loss, 3),
            round(min_loss, 3),
            round(idx_min_loss, 3),
        ]

        table.append(row)

    dskc_terminal.table(table)
def header(section, sub_section, text, increment_sub_section=True):
    print("\n")
    markdown_h2("{}.{} {}".format(section, sub_section, text))
    print("\n")

    if increment_sub_section:
        sub_section += 1

    return sub_section
Exemple #4
0
def loss_graphs(historys):
    terminal.markdown_h2("Loss")
    print()
    _plots(historys, train="loss", test="val_loss", label="Loss")
    print("\n")
Exemple #5
0
def accuracy_graphs(historys):
    terminal.markdown_h2("Accuracy")
    print()
    _plots(historys, train="accuracy", test="val_accuracy", label="Accuracy")
    print("\n")