Spaces:
Runtime error
Runtime error
import pandas as pd | |
from scipy.signal import savgol_filter | |
import joblib | |
import numpy as np | |
import plotly.express as px | |
import gradio as gr | |
titik1=gr.Number(label='Node 1 (Close)') | |
titik2=gr.Number(label='Node 2 (Close)') | |
titik3=gr.Number(label='Node 3 (Close)') | |
titik4=gr.Number(label='Node 4 (Close)') | |
titik5=gr.Number(label='Node 5 (Close)') | |
titik6=gr.Number(label='Node 6 (Close)') | |
titik7=gr.Number(label='Node 7 (Close)') | |
titik8=gr.Number(label='Node 8 (Close)') | |
titik9=gr.Number(label='Node 9 (Close)') | |
titik10=gr.Number(label='Node 10 (Close)') | |
titik11=gr.Number(label='Node 11 (Close)') | |
pair=gr.Dropdown(["With Last Node","Without Last Node"]) | |
desc='For one-time prediction only. EURUSD TF 1D for now.' | |
net=joblib.load('model_savgolfilt') | |
def fn(pair,titik1,titik2,titik3,titik4,titik5,titik6,titik7,titik8,titik9,titik10,titik11): | |
titik=np.array([]) | |
titik=np.append(titik,titik1) | |
titik=np.append(titik,titik2) | |
titik=np.append(titik,titik3) | |
titik=np.append(titik,titik4) | |
titik=np.append(titik,titik5) | |
titik=np.append(titik,titik6) | |
titik=np.append(titik,titik7) | |
titik=np.append(titik,titik8) | |
titik=np.append(titik,titik9) | |
titik=np.append(titik,titik10) | |
titik=np.append(titik,titik11) | |
x=savgol_filter(titik,11,3) | |
if pair=="With Last Node": | |
hasil=net.predict([[x[len(x)-2],x[len(x)-1]]]) | |
keluar=px.line(y=[x[len(x)-2],x[len(x)-1],hasil[0]]) | |
elif pair=="Without Last Node": | |
hasil=net.predict([[x[len(x)-3],x[len(x)-2]]]) | |
keluar=px.line(y=[x[len(x)-3],x[len(x)-2],hasil[0]]) | |
return keluar | |
app=gr.Interface(fn,inputs=[pair,titik1,titik2,titik3,titik4,titik5,titik6,titik7,titik8,titik9,titik10,titik11],outputs=[gr.Plot()],description=desc,title='Savitsky-Golay Prediction') | |
app.launch() |