saritha5's picture
Update app.py
fdbed18
raw
history blame
1.76 kB
import numpy as np
import matplotlib.pylab as plt
import ruptures as rpt
import streamlit as st
from ruptures.metrics import precision_recall
from ruptures.metrics import hausdorff
from ruptures.metrics import randindex
st.title("Change Point Detection")
# Generating Signal
def pw_constant_input(n,dim,n_bkps,sigma):
"""Piecewise constant (pw_constant)"""
# n, dim # number of samples, dimension
# n_bkps, sigma # number of change points, noise standard deviation
signal, bkps = rpt.pw_constant(n, dim, n_bkps, noise_std=sigma)
rpt.display(signal, bkps)
return signal,bkps
def pw_linear_input(n,dim,n_bkps,sigma):
"""Piecewise Linear"""
# creation of data
# n, dim = 500, 3 # number of samples, dimension of the covariates
# n_bkps, sigma = 3, 5 # number of change points, noise standart deviation
signal, bkps = rpt.pw_linear(n, dim, n_bkps, noise_std=sigma)
rpt.display(signal, bkps)
return signal,bkps
def pw_normal_input(n,dim,n_bkps,sigma):
"""Piecewise 2D Gaussian process (pw_normal)#"""
# creation of data
#n = 500 # number of samples
#n_bkps = 3 # number of change points
signal, bkps = rpt.pw_normal(n, n_bkps)
rpt.display(signal, bkps)
return signal,bkps
def pw_wavy_input(n,dim,n_bkps,sigma):
# creation of data
#n, dim = 500, 3 # number of samples, dimension
#n_bkps, sigma = 3, 5 # number of change points, noise standart deviation
signal, bkps = rpt.pw_wavy(n, n_bkps, noise_std=sigma)
rpt.display(signal, bkps)
return signal,bkps
input_list = ['piecewiseConstant','piecewiseLinear','piecewiseNormal','piecewiseSinusoidal']
generate_signal = st.selectbox(label = "Choose an input signal", options = input_list)