Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
1
Indexable
Never
## dockerfile

FROM python:3.8.10

WORKDIR /app

COPY . /app

RUN pip install -r requirements.txt

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
ENTRYPOINT ["streamlit", "run", "home.py", "--server.port=8501", "--server.address=0.0.0.0"]


## home.py

import streamlit as st
import pandas as pd
from orion import Orion
from utils import plot
from tensorflow.keras.utils import plot_model


data = pd.read_csv('data/543341.csv', usecols=['Date', 'No. of Trades'], parse_dates=['Date'])
data.rename(columns={'No. of Trades': 'value', 'Date': 'timestamp'}, inplace=True)
data.sort_values(by='timestamp', inplace=True)
data.timestamp = (data.timestamp - pd.Timestamp("1970-01-01")) // pd.Timedelta("1s")
data.head()

known_anomalies = pd.DataFrame({
    'start': [1648751400],
    'end': [1661970599]
})
known_anomalies

hyperparameters = {
    "mlprimitives.custom.timeseries_preprocessing.rolling_window_sequences#1": {
        'target_column': 0,
        'window_size': 100
    },
    'keras.Sequential.LSTMSeq2Seq#1': {
        'epochs': 15,
        'verbose': True,
        'window_size': 100,
        'input_shape': [100, 1],
        'target_shape': [100, 1]
    }
}

orion = Orion(
    pipeline='lstm_autoencoder',
    hyperparameters=hyperparameters
)
anomalies = orion.fit_detect(data)
anomalies

plotImg = plot(data, 'Sharpline Broadcast Ltd. (543341)', anomalies=[anomalies, known_anomalies])

st.title("Anomalies Detection")
st.dataframe(anomalies)
st.pyplot(plotImg, True)