GithubHelp home page GithubHelp logo

Comments (9)

jeffhandl avatar jeffhandl commented on June 2, 2024

You need to specify the name of the time column if it is not time. You can do TimeSeriesData(df, time_col_name='index'). The time attribute of TimeSeriesData needs to consist of Datetime objects - how are you looking to convert the index values to Datetimes?

from kats.

orenpapers avatar orenpapers commented on June 2, 2024

I am doing just that:

df :


0,0.09177
1,0.09567
2,0.08444
3,0.08971


And then I run:
TimeSeriesData(df, time_col_name='index') But then the index is automatically transformed to datetime:

                            index         0
0   1970-01-01 00:00:00.000000000  0.091773
1   1970-01-01 00:00:00.000000001  0.095667
2   1970-01-01 00:00:00.000000002  0.084443
3   1970-01-01 00:00:00.000000003  0.089711

from kats.

jeffhandl avatar jeffhandl commented on June 2, 2024

Yes, the times need to be Datetimes.

from kats.

orenpapers avatar orenpapers commented on June 2, 2024

@jeffhandl OK , but let's say I want to treat them just as order and not specifically datetime - is it possible?

from kats.

jeffhandl avatar jeffhandl commented on June 2, 2024

No, you need datetime values in the time column - that is required.

from kats.

orenpapers avatar orenpapers commented on June 2, 2024

@jeffhandi will be it presented in the future or there is a workaround? since ordered data is actually can be treated as a time series, even if the index is not specifically datetime

from kats.

jeffhandl avatar jeffhandl commented on June 2, 2024

@orko19 If you have ts_df = TimeSeriesData(df, time_col_name='index'), you can recover the indices by doing ts_df.time.index. Does that help?

from kats.

orenpapers avatar orenpapers commented on June 2, 2024

@jeffhandl When I run on my dataframe:

df.apply(lambda x : CUSUMDetector(TimeSeriesData(pd.DataFrame(x['value']).
                                                                   reset_index(), time_col_name="index")).
                            detector(), axis=1)

I get:

[(TimeSeriesChangePoint(start_time: 1970-01-01 00:00:00.000000095, end_time: 1970-01-01 00:00:00.000000095, confidence: 1.0), <kats.detectors.cusum_detection.CUSUMMetadata object at 0x1db27ef40>)]
[(TimeSeriesChangePoint(start_time: 1970-01-01 00:00:00.000000057, end_time: 1970-01-01 00:00:00.000000057, confidence: 1.0), <kats.detectors.cusum_detection.CUSUMMetadata object at 0x1db27e9a0>)]
[(TimeSeriesChangePoint(start_time: 1970-01-01 00:00:00.000000229, end_time: 1970-01-01 00:00:00.000000229, confidence: 1.0), <kats.detectors.cusum_detection.CUSUMMetadata object at 0x1db27e6d0>)]
[(TimeSeriesChangePoint(start_time: 1970-01-01 00:00:00.000000095, end_time: 1970-01-01 00:00:00.000000095, confidence: 1.0), <kats.detectors.cusum_detection.CUSUMMetadata object at 0x1db27ef10>)]
[(TimeSeriesChangePoint(start_time: 1970-01-01 00:00:00.000000057, end_time: 1970-01-01 00:00:00.000000057, confidence: 1.0), <kats.detectors.cusum_detection.CUSUMMetadata object at 0x1db27e340>)]

So I meant to ask if there is a way that the output of the detector will be the actual index? Or a workaround to go back from TimeSeriesChangePoint to row/index in the original dataframe?

from kats.

jeffhandl avatar jeffhandl commented on June 2, 2024

Yes, let's say ts_df is the name o the time series and cp is the name of a changepoint. Then cp[0][0].start_time is the time of the changepoint, so you can do ts_df.time_to_index().get_loc(cp[0][0].start_time).

from kats.

Related Issues (20)

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.