Skip to content

API for using Otava as a library #101

@radove

Description

@radove

I recently utilized Otava by calling the functions directly instead of using an importer. This is useful if you have data received by Python in some custom way and want to programmically utilize Otava on the data. There isn't a lot of documentation on this so it was sort of like looking at unit tests and guessing at it. I figured it out, but I am not sure if I am doing it entirely correctly. It would be useful if this was documented officially as an option, unless for some reason you rather people be limited to using an existing importer?

Here is my potentially bad attempt at an example of this

from otava.analysis import compute_change_points, ChangePoint

def _compute_change_points(p, m=0.0, w=30, series=[], new_data=None):
    return compute_change_points(series, window_len=w, max_pvalue=p, min_magnitude=m, new_data=new_data)

#Bring in your data from another source, and set y_list to the data...
y_list = []

#Tweak the parameters to appropriate max_pvalue and min_magnitude options, as these may differ depending on dataset and sensitivity desired


math_results,old_math_results = _compute_change_points(0.005, m=0.003, w=100, series=y_list, new_data=None)
index_list = []

c: ChangePoint
for c in math_results:
    index_list.append(c.index)

for index, y in enumerate(y_list):
    if index in index_list:
        print("This Y should be marked!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions