File size: 2,105 Bytes
3ef3bdb
 
 
 
 
 
 
 
 
 
 
b9a5329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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)



n,dim,n_bkps,sigma = st.columns(4)
with n:
    n= st.number_input('No of Samples',min_value=100,step=1)
with dim:
    dim = st.number_input('No of dimesions',min_value=1,max_value = 5,step=1)
with n_bkps:
    n_bkps = st.number_input('No of breakpoints',min_value=2,step=1)
with sigma:
    sigma = st.number_input('Variance',min_value=1,max_value=4,step=1)