f len(detected_index) &lt;= 1:
        return (0, 0)
    y_detected = y[detected_index]
    true_pos = y_detected[y_detected &gt; 0].sum()
    if true_pos == 0:
        return (0, 0)
    pos = y[y &gt; 0].sum()
    return y_detected.mean(), float(true_pos) / pos


def score_linear(X, y, rules: List[str],
                 penalty=&#39;l1&#39;,
                 prediction_task=&#39;regression&#39;,
                 max_rules=30,
                 alpha=None,
                 cv=True,
                 random_st