Git Product home page Git Product logo

Comments (14)

ermshaua avatar ermshaua commented on September 25, 2024 1

Hi,

I just added the code to generate the visualizations of the time series as well as predicted segmentations. Check out the updated README.

Cheers, Arik

from time-series-segmentation-benchmark.

hananeYS avatar hananeYS commented on September 25, 2024

How please to generate all the images for all the dataset, i try this but something was wrong.

for _, (ts, ts_name, cps, found_cps) in tssb.iterrows():
import matplotlib.pyplot as plt
from tssb.utils import visualize_time_series
fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)
plt.show()

from time-series-segmentation-benchmark.

ermshaua avatar ermshaua commented on September 25, 2024

The row

for _, (ts, ts_name, cps, found_cps) in tssb.iterrows():

is false. TSSB consists of tuples (ts_name, window_size, cps, ts). Try:

for _, (ts_name, window_size, cps, ts) in tssb.iterrows():
    fig, ax = visualize_time_series(ts, ts_name, cps)
    plt.savefig(f"images/{ts_name}.png", bbox_inches="tight")
    plt.clf()

Cheers, Arik

from time-series-segmentation-benchmark.

hananeYS avatar hananeYS commented on September 25, 2024

for _, (ts_name, window_size, cps, ts) in tssb.iterrows():
fig, ax = visualize_time_series(ts, ts_name, cps)
plt.savefig(f"images/{ts_name}.png", bbox_inches="tight")
plt.clf()

Thank u, but this is before segmentation prediction, i want after the prediction (found changes points)

from time-series-segmentation-benchmark.

ermshaua avatar ermshaua commented on September 25, 2024

In that case, simply add your predicted change points to the method

fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)

from time-series-segmentation-benchmark.

hananeYS avatar hananeYS commented on September 25, 2024

In that case, simply add your predicted change points to the method fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)

i did it, but the result was wrong... Like this..
-----for _, (ts_name, window_size, cps, ts) in tssb.iterrows():
fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)
plt.savefig(f"tssb/results/{ts_name}.png", bbox_inches="tight")
plt.clf()-----

and this is an example of the result...

Adiac

from time-series-segmentation-benchmark.

ermshaua avatar ermshaua commented on September 25, 2024

Well, is your prediction

found_cps = your_algorithm_predict(ts)

in the for loop? And also, can you print your prediction (found_cps)? It seems like it is way too large.

from time-series-segmentation-benchmark.

ermshaua avatar ermshaua commented on September 25, 2024

The following code

import numpy as np
import matplotlib.pyplot as plt

from tssb.utils import load_time_series_segmentation_datasets, visualize_time_series
tssb = load_time_series_segmentation_datasets(names=["Adiac"])

for _, (ts_name, window_size, cps, ts) in tssb.iterrows():
    found_cps = np.array([1000])
    fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)
    plt.show()
    plt.clf()

leads to the following image:

Adiac

from time-series-segmentation-benchmark.

hananeYS avatar hananeYS commented on September 25, 2024

I'm sorry, but i tried that, and it's correct juste for Adiac.
For example, for beetlefly, i got that
Capture

from time-series-segmentation-benchmark.

ermshaua avatar ermshaua commented on September 25, 2024

But this is exactly what you would expect to get for BeetleFly, if your predicted Change Point is at position 1000.

from time-series-segmentation-benchmark.

hananeYS avatar hananeYS commented on September 25, 2024

But this is exactly what you would expect to get for BeetleFly, if your predicted Change Point is at position 10
oh yes, i'm stupide.. but how to print for all our predictions, for example like this (but for all images) ...

Capture

from time-series-segmentation-benchmark.

ermshaua avatar ermshaua commented on September 25, 2024

Well, you simply predict the CPs in the for loop and save the predicted segmentations.

import numpy as np
import matplotlib.pyplot as plt

from tssb.utils import load_time_series_segmentation_datasets, visualize_time_series
tssb = load_time_series_segmentation_datasets(names=["Adiac"])

for _, (ts_name, window_size, cps, ts) in tssb.iterrows():
    found_cps = your_segmentation_algorithm_predict(ts, len(cps))
    fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)
    plt.savefig(f"images/{ts_name}.png", bbox_inches="tight")
    plt.clf()

from time-series-segmentation-benchmark.

hananeYS avatar hananeYS commented on September 25, 2024

Well, you simply predict the CPs in the for loop and save the predicted segmentations.

import numpy as np
import matplotlib.pyplot as plt

from tssb.utils import load_time_series_segmentation_datasets, visualize_time_series
tssb = load_time_series_segmentation_datasets(names=["Adiac"])

for _, (ts_name, window_size, cps, ts) in tssb.iterrows():
    found_cps = your_segmentation_algorithm_predict(ts, len(cps))
    fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)
    plt.savefig(f"images/{ts_name}.png", bbox_inches="tight")
    plt.clf()

Yes, now it's okay, thank you very much. This is the final code for your implementation

for _, (ts_name, window_size, cps, ts) in tssb.iterrows():
found_cps = ClaSPSegmentation(window_size, n_cps=len(cps)).fit_predict(ts)
fig, ax = visualize_time_series(ts, ts_name, cps, found_cps)
plt.savefig(f"tssb/results/{ts_name}.png", bbox_inches="tight")
plt.clf()

from time-series-segmentation-benchmark.

ermshaua avatar ermshaua commented on September 25, 2024

Yes! You are welcome!

from time-series-segmentation-benchmark.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.