def test_fit_importances(iris_dataset):
    """
    Check whether feature importance is calculated properly.
    """
    (x_train, y_train, x_valid, y_valid), _, clip_values = iris_dataset

    def pearson_correlations(x, y):
        correlations = [pearsonr(x[:, col], y)[0] for col in range(x.shape[1])]
        absolutes = np.abs(np.array(correlations))
        result = absolutes / np.power(np.sum(absolutes**2), 0.5)
        return result

    # Setup classifier
    lr_clf = LogisticRegression(penalty=None)
    lr_clf.fit(x_train, y_train)
    clf_slr = ScikitlearnLogisticRegression(model=lr_clf, clip_values=clip_values)

    # User defined vector
    vector = pearson_correlations(np.array(x_train), np.array(y_train))

    # 3 different instances of LowProFool, using 3 different ways of specifying importance

    # Default version - using pearson correlation under the hood
    lpf_slr_default = LowProFool(classifier=clf_slr, n_steps=45, eta=0.02, lambd=1.5, importance="pearson")

    # Predefined vector, passed in LowProFool initialization
    lpf_slr_vec = LowProFool(classifier=clf_slr, n_steps=45, eta=0.02, lambd=1.5, importance=vector)

    # User defined function
    lpf_slr_fun = LowProFool(classifier=clf_slr, n_steps=45, eta=0.02, lambd=1.5, importance=pearson_correlations)

    lpf_slr_default.fit_importances(x_train, y_train)
    lpf_slr_vec.fit_importances(x_train, y_train)
    lpf_slr_fun.fit_importances(x_train, y_train, normalize=False)

    importance_default = lpf_slr_default.importance_vec
    importance_vec_init = lpf_slr_vec.importance_vec
    importance_function = lpf_slr_fun.importance_vec

    # Predefined vector passed while fitting
    lpf_slr_default.fit_importances(x_train, y_train, importance_array=vector)
    importance_vec_fit = lpf_slr_default.importance_vec

    # Vector normalization
    vector_norm = vector / np.sum(vector)

    is_default_valid = (vector_norm == importance_default).all()
    is_custom_fun_valid = (vector == importance_function).all()
    is_vec_init_valid = (vector_norm == importance_vec_init).all()
    is_vec_fit_valid = (vector_norm == importance_vec_fit).all()

    logger.info("[Iris flower, Scikit-learn Logistic Regression] Importance fitting test:")
    if not is_default_valid:
        logger.info("Fitting importance by default is invalid")
    elif not is_custom_fun_valid:
        logger.info("Fitting importance with custom function is invalid")
    elif not is_vec_init_valid:
        logger.info("Fitting importance with vector provided in initializer is invalid")
    elif not is_vec_fit_valid:
        logger.info("Fitting importance with vector provided in fit_importances() is invalid")
    else:
        logger.info("Fitting importance with all available methods went successfully")

    assert is_default_valid
    assert is_custom_fun_valid
    assert is_vec_init_valid
    assert is_vec_fit_valid

    Check whether feature importance is calculated properly.
    
tests/attacks/evasion/test_lowprofool.py