sintel-dev / Orion

A machine learning library for detecting anomalies in signals.
https://sintel.dev/Orion/
MIT License
1.01k stars 158 forks source link

cannot import 'plot' from 'utils' #462

Closed eliashyatt closed 10 months ago

eliashyatt commented 11 months ago

Description

I attempted to run the code in the Orion Tulog here: https://github.com/sintel-dev/Orion/blob/master/tutorials/tulog/Tulog.ipynb I'm currently stuck on the general import.

What I Did

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from sklearn.impute import SimpleImputer
from sklearn.preprocessing import MinMaxScaler

from utils import plot, plot_ts, plot_rws, plot_error, unroll_ts

ImportError: cannot import name 'plot' from 'utils' (C:\Users\elias\anaconda3\envs\orion\lib\site-packages\utils\__init__.py)

I checked and I should have utils installed so I'm not sure what exactly is causing the problem. Thank you for the help!

sarahmish commented 11 months ago

Hi @eliashyatt! Thank you for using Orion!

There is a custom utils in the tulog that should be in the same directory as the notebook you are running. Specifically, it is this file that it is trying to import https://github.com/sintel-dev/Orion/blob/master/tutorials/tulog/utils.py.

eliashyatt commented 11 months ago

Hi @sarahmish. I am fairly new to github. Is there a way for me to install the custom version of utils from the tulog?

sarahmish commented 11 months ago

@eliashyatt of course! All you need to do is copy the file to where the notebook is!

Another way of doing it is to clone the repository, run the following code in your notebook:

git clone https://github.com/signals-dev/Orion.git
mv Orion/tutorials/tulog/* .
eliashyatt commented 11 months ago

@sarahmish thank you for your help. I was able to get part 1 of the tutorial to work though I ran into an issue for part 2. When I tried to run the following code, the error said that the pipeline was unknown.

from orion import Orion

orion = Orion(
    pipeline='tadgan.json'
)

anomalies = orion.fit_detect(df)

ValueError: Unknown pipeline: tadgan.json

I also had to change the version of numpy when running this code and found that version required for Orion is <1.19 while the version required for matplotlib >=1.20.

sarahmish commented 11 months ago

@eliashyatt similarly here you would need to have the tadgan.json in the same directly https://github.com/sintel-dev/Orion/blob/master/tutorials/tulog/tadgan.json.

I would say that this setup is not the best, I would recommend just running Orion(pipeline='tadgan') and adjust the number of epochs as necessary.

Hope this helps!

eliashyatt commented 11 months ago

@sarahmish sorry for the late response. I do not know how to adjust the epochs after running Orion.

sarahmish commented 11 months ago

No worries! Send a dictionary specifying the hyperparameter name with its new value, it should be something like this:

from orion import Orion

hyperparameters = {
    'orion.primitives.tadgan.TadGAN#1': {
        'epochs': 5,
        'verbose': True
    }
}

orion = Orion(
    pipeline='tadgan',
    hyperparameters=hyperparameters
)

anomalies = orion.fit_detect(df)
eliashyatt commented 10 months ago

@sarahmish thank you for your help! I was able to get a result similar to the tulog after running the code from your previous message. I'll let you know if I run into anymore problems.

sarahmish commented 10 months ago

@eliashyatt happy to help! I'm glad it is working now and I'll close the issue but feel free to reopen the issue if you have other questions.