Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the Orion Class #79

Closed
csala opened this issue Apr 30, 2020 · 0 comments · Fixed by #81
Closed

Implement the Orion Class #79

csala opened this issue Apr 30, 2020 · 0 comments · Fixed by #81
Milestone

Comments

@csala
Copy link
Contributor

csala commented Apr 30, 2020

This issue is to track the development of the new Orion class.

The Orion class is responsible for handling the MLBlocks Pipelines that provide the central anomaly detection functionality in Orion.

Overall, the Orion class:

  • Provides simple user-facing abstractions
    • fit/detect
    • save/load
    • evaluate
  • Hides away the interaction with other systems
    • MLBlocks Pipelines
    • Pipeline Selection and Tuning (future?)

This should be the class public interface:

class Orion:

    def __init__(self,
        pipeline: Union[str, dict, MLPipeline] = DEFAULT_PIPELINE,
        hyperparameters: dict = None):
        pass
    
    def fit(self, data: DataFrame):
        """Fit the pipeline to the given data.
        
        Args:
            data (DataFrame):
                Input data, passed as a ``pandas.DataFrame`` containing
                exactly two columns: timestamp and value.
        """
        pass
        
    def detect(self, data: DataFrame,
               visualization: bool = True) -> DataFrame:
        """Detect anomalies in the given data..
        
        If ``visualization=True``, also return the visualization
        outputs from the MLPipeline object.
        
        Args:
            data (DataFrame):
                Input data, passed as a ``pandas.DataFrame`` containing
                exactly two columns: timestamp and value.
            visualization (bool):
                If ``True``, also capture the ``visualization`` named
                output from the ``MLPipeline`` and return it as a second
                output.
        
        Returns:
            DataFrame or tuple:
                If visualization is ``False``, it returns the events
                DataFrame. If visualization is ``True``, it returns a
                tuple containing the events DataFrame followed by the
                visualization outputs dict.
        """
        pass
        
    def fit_detect(self, data):
        """Fit the pipeline to pipeline and detect anomalies.
        
        This method is functionally equivalent to calling `fit(data)`
        and later on `detect(data)` but with the difference that
        here the `MLPipeline` is called only once, using its `fit`
        method, and the output is directly captured without having
        to execute the whole pipeline again during the `predict` phase.
        
        If ``visualization=True``, also return the visualization
        outputs from the MLPipeline object.
        
        Args:
            data (DataFrame):
                Input data, passed as a ``pandas.DataFrame`` containing
                exactly two columns: timestamp and value.
            visualization (bool):
                If ``True``, also capture the ``visualization`` named
                output from the ``MLPipeline`` and return it as a second
                output.
        
        Returns:
            DataFrame or tuple:
                If visualization is ``False``, it returns the events
                DataFrame. If visualization is ``True``, it returns a
                tuple containing the events DataFrame followed by the
                visualization outputs dict.
        """
        pass
    
    def save(self, path):
        """Save this object using pickle.
        
        Args:
            path (str):
                Path to the file where the serialization of
                this object will be stored.
        """
        pass
    
    @classmethod
    def load(cls, path) -> Orion:
        """Load an Orion instance from a pickle file.
        
        Args:
            path (str):
                Path to the file where the instance has been
                previously serialized.
        """
        pass
    
    def evaluate(cls, data: DataFrame, truth: DataFrame,
                 metrics: List[str] = DEFAULT_METRICS) -> Series:
        """Evaluate the performance against a ground truth.
        
        Args:
            data (DataFrame):
                Input data, passed as a ``pandas.DataFrame`` containing
                exactly two columns: timestamp and value.
            truth (DataFrame):
                Ground truth passed as a ``pandas.DataFrame`` containing
                two columns: start and stop.
            metrics (list):
                List of metrics to used passed as a list of strings.
                If not given, it defaults to all the Orion metrics.
        
        Returns:
            Series:
                ``pandas.Series`` containing one element for each
                metric applied, with the metric name as index.
        """
        pass
@csala csala added this to the 0.1.1 milestone Apr 30, 2020
@csala csala changed the title Orion Class Implement the Orion Class Apr 30, 2020
@csala csala closed this as completed in #81 May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant