Skip to content

[BUG] plot_clusters TypeError #675

Closed
1 task done
rohrdr opened this issue May 11, 2022 · 0 comments · Fixed by #707
Closed
1 task done

[BUG] plot_clusters TypeError #675

rohrdr opened this issue May 11, 2022 · 0 comments · Fixed by #707
Assignees
Labels
bug Something isn't working

Comments

@rohrdr
Copy link

rohrdr commented May 11, 2022

🐛 Bug Report

Function plot_clusters gives error TypeError: 'AxesSubplot' object is not subscriptable when number of clusters is two.

Expected behavior

Should plot without errors

How To Reproduce

def gen_dataset():
    df = pd.DataFrame()
    for i in range(1, 5):
        date_range = pd.date_range("2020-01-01", "2020-05-01")
        for j, sigma in enumerate([0.1, 0.3, 0.5, 0.8]):
            tmp = pd.DataFrame({"timestamp": date_range})
            tmp["segment"] = f"{2*i}{j}"
            tmp["target"] = np.random.normal(2*i, sigma, len(tmp))
            df = df.append(tmp, ignore_index=True)
    ts = TSDataset(df=TSDataset.to_dataset(df), freq="D")
    return ts

ts = gen_dataset()
model = EuclideanClustering()
model.build_distance_matrix(ts=ts)
model.build_clustering_algo(n_clusters=2,linkage="average")
segment2cluster = model.fit_predict()
centroids = model.get_centroids()
plot_clusters(ts,segment2cluster,centroids)

Environment

No response

Additional context

No response

Checklist

  • Bug appears at the latest library version
@rohrdr rohrdr added the bug Something isn't working label May 11, 2022
@iKintosh iKintosh changed the title [BUG] [BUG] plot_clusters TypeError May 11, 2022
@alex-hse-repository alex-hse-repository moved this from Specification to Todo in etna board May 13, 2022
@alex-hse-repository alex-hse-repository moved this to Specification in etna board May 13, 2022
@Ama16 Ama16 mentioned this issue May 24, 2022
9 tasks
@Ama16 Ama16 self-assigned this May 25, 2022
@Ama16 Ama16 moved this from Todo to In Progress in etna board May 25, 2022
@Ama16 Ama16 moved this from In Progress to In Review in etna board May 25, 2022
Repository owner moved this from In Review to Done in etna board May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants