vanderschaarlab / autoprognosis

A system for automating the design of predictive modeling pipelines tailored for clinical prognosis.
https://www.autoprognosis.vanderschaar-lab.com/
Apache License 2.0
95 stars 26 forks source link

AttributeError: 'DataFrame' object has no attribute 'append' #79

Closed williamty closed 11 months ago

williamty commented 11 months ago

An error occurred when i was running classification_with_explainers. I think it's about the dataset, because I don't meet the error before with other datasets. Here's the error message:

AttributeError: 'DataFrame' object has no attribute 'append'. Did you mean: '_append'?

I have modified python program in autoprognosis\plugins\explainers\plugin_risk_effect_size.py: The original code: ` output = pd.DataFrame([], columns=X.columns) index = [] for bucket in range(bins): curr_bucket = X[buckets == bucket] other_buckets = X[buckets > bucket]

        if len(curr_bucket) < 2 or len(other_buckets) < 2:
            continue

        diffs = self._cohend(curr_bucket, other_buckets).to_dict()

        heatmaps = pd.DataFrame([[0] * len(X.columns)], columns=X.columns)

        for key in diffs:
            if diffs[key] < effect_size:
                continue

            heatmaps[key] = diffs[key]

        output = output.append(heatmaps)
        index.append(f"Risk lvl {bucket}")

`

New code: ` output = pd.DataFrame(columns=X.columns) index = []

    for bucket in range(bins):
        curr_bucket = X[buckets == bucket]
        other_buckets = X[buckets > bucket]

        if len(curr_bucket) < 2 or len(other_buckets) < 2:
            continue

        diffs = self._cohend(curr_bucket, other_buckets).to_dict()

        heatmap_data = [0] * len(X.columns)

        for key in diffs:
            if diffs[key] < effect_size:
                continue

            heatmap_data[X.columns.get_loc(key)] = diffs[key]

        heatmaps = pd.DataFrame([heatmap_data], columns=X.columns)

        output = output._append(heatmaps, ignore_index=True)
        index.append(f"Risk lvl {bucket}")

`

The error will disappear.