def generate_score(statistics_summary, columns_to_drop, automl):
    """Returns a score of the evaluating the 'goodness' of a given dataset. Datasets with an higher score will be selected for the app.
    The score takes into account:
    * the overall percentage of missing values, extracted from the pandas df of statistics_summary.csv (30%)
    * the percentage of variables not retained when running mljar (warning columns and columns detected by csv detective) (40%)
    * the logloss (for classification) or rmse (for regression) value for the best model (30%), extracted leaderboard.csv """
    prop_missing = statistics_summary['Percentage of missing cells'] / 100
    prop_not_retained = len(columns_to_drop) / statistics_summary['Number of variables']
    best_metric = automl.get_leaderboard()['metric_value'].min()
    score = 1 / (0.3 * prop_missing + 0.4 * prop_not_retained + 0.3 * best_metric)
    return score