├── tmp ├── infographic.png └── graphical_model.png ├── hiercpd └── hiercpd.py ├── README.md ├── circadian ├── expectation.py ├── util.py ├── circadian_model.py └── maximization.py ├── LICENSE └── notebooks └── demo_detector.ipynb /tmp/infographic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmorenoz/HierCPD/HEAD/tmp/infographic.png -------------------------------------------------------------------------------- /tmp/graphical_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmorenoz/HierCPD/HEAD/tmp/graphical_model.png -------------------------------------------------------------------------------- /hiercpd/hiercpd.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Pablo Moreno-Munoz 2 | # Universidad Carlos III de Madrid 3 | 4 | import numpy as np 5 | import random 6 | import matplotlib.pyplot as plt 7 | 8 | class HierCPD(): 9 | def __init__(self, Z, hyp_lambda=None, name='HierCPD'): 10 | 11 | self.Z = Z 12 | self.T = Z.shape[0] 13 | self.Znan = np.isnan(self.Z) 14 | self.K = np.int(np.nanmax(self.Z)) 15 | self.Zbin = self.onehot() 16 | self.maxes = np.empty((self.T+1,1)) 17 | 18 | # Run length initialization 19 | self.R = np.zeros((self.T+1, self.T+1)) 20 | self.R[0,0] = 1 21 | 22 | # Hyperparameters initialization 23 | if hyp_lambda is not None: 24 | self.hyp_lambda = hyp_lambda 25 | else: 26 | pass 27 | self.alpha0 = np.ones((1,self.K)) 28 | self.alphaT = self.alpha0 29 | 30 | # Maxes initialization 31 | self.maxes[0] = 0 32 | 33 | def detection(self): 34 | # Detector 35 | for t in range(self.T): 36 | if self.Znan[t]: 37 | pred = 1. 38 | else: 39 | pred = self.alphaT[:, self.Zbin[t,:]==1] / np.sum(self.alphaT,1)[:,None] 40 | 41 | H = self.constant_hazard(np.arange(t+1)+1) 42 | self.R[1:t+2, t+1, None] = self.R[0:t+1, t, None] * pred * (1-H) 43 | self.R[0,t+1] = np.sum(self.R[0:t+1, t] * pred * H) 44 | self.R[:,t+1] = self.R[:,t+1] / np.sum(self.R[:, t+1]) 45 | 46 | if sum(self.Zbin[t,:] > 1): 47 | alphaT0 = np.vstack(( self.alpha0, self.alphaT)) 48 | else: 49 | alphaT0 = np.vstack((self.alpha0, self.alphaT + np.tile(self.Zbin[t,:].T, (self.alphaT.shape[0] ,1)) )) 50 | 51 | self.alphaT = alphaT0 52 | self.maxes[t+1] = np.where(self.R[1:,t+1] == np.max(self.R[1:,t+1])) 53 | 54 | self.maxes[1:] = self.maxes[1:] + 1 55 | #self.maxes[self.T] = np.where(self.R[:, self.T] == np.max(self.R[:, self.T])) 56 | 57 | def constant_hazard(self, R): 58 | # Probability of CP per unit of time 59 | H = (1./self.hyp_lambda) * np.ones((R.shape[0],1)) 60 | return H 61 | 62 | 63 | def onehot(self): 64 | # One-Hot Encoding of Categorical Data 65 | Z_onehot = np.zeros((self.T, self.K)) 66 | for k in range(self.K): 67 | Z_onehot[:, k, None] = (self.Z==k+1).astype(np.int) 68 | 69 | return Z_onehot 70 | 71 | def plot_detection(self): 72 | plt.figure(figsize=(6,8)) 73 | ax1 = plt.subplot(211) 74 | plt.imshow(self.Zbin.T, cmap='gray_r', aspect='auto') 75 | ax2 = plt.subplot(212, sharex=ax1) 76 | plt.imshow(-np.log(self.R), cmap='gray', aspect='auto') 77 | plt.plot(self.maxes, color='red', linewidth=2.0) 78 | plt.show() 79 | 80 | 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hierarchical Change-Point Detection 2 | 3 | This repository contains the implementation of our Hierarchical Change-Point Detection (HierCPD) model that is fully written in Python. This model addresses the problem of change-point detection on sequences of **high-dimensional** and **heterogeneous** observations (i.e. different statistical data types) with an unknown temporal structure. 4 | 5 | Please, if you use this code, cite the following [paper](https://arxiv.org/abs/1809.04197): 6 | ``` 7 | @article{MorenoRamirezArtes18, 8 | title={Change-Point Detection on Hierarchical Circadian Models}, 9 | author={Pablo Moreno-Mu\~noz, David Ram\'irez and Antonio Art\'es-Rodr\'iguez}, 10 | journal={arXiv preprint arXiv:1809.04197}, 11 | year={2018} 12 | } 13 | ``` 14 | 15 | The repository is divided in two sections that correspond to the two principal contributions of our work: **(i) Hierarchical Detector** and **(ii) Heterogeneous Circadian Mixture Models**. 16 | 17 | # Hierarchical Detector 18 | This is a novel probabilistic extension of the widely known Bayesian Online Change-Point Detection (BOCPD) algorithm. We extend the BOCPD method to handle any type of latent variable model. In particular, it is able to detect by directly modeling complex observations from their latent representation embedded in a lower dimensional manifold. You may find a notebook demo of the detector performance within a latent class model. 19 | 20 | **Graphical model:** Representation of the hierarchical change-point detector. The detection is performed exclusively on the blue region. Additionally, the green region corresponds to the embedded circadian model (see below). 21 | ![graphical_model](tmp/graphical_model.png) 22 | 23 | # Heterogeneous Circadian Mixture Models 24 | 25 | We are to embed different types of heterogeneous models into the hierarchical BOCPD method in order to handle arbitrary combinations of statistical data types or even underlying temporal structures (periodicities). See Section 3 in [paper]. 26 | 27 | **Circadian Model Infographic:** Graphical representation of the embedded circadian model. Shaded boxes represent heterogeneous high-dimensional observations of one single day. All complex objects are represented by a lower dimensional latent variable that we aim to discover. 28 | 29 | ![infographic](tmp/infographic.png) 30 | 31 | **Paramz-based Python code:** Our model is programmed in an easy understandable form using the [Paramz](https://github.com/sods/paramz) library. This one is especially useful for fitting probabilistic models where we need to maximize a likelihood function w.r.t. a set of given parameters. 32 | 33 | ## Contributors 34 | 35 | [Pablo Moreno-Muñoz](http://www.tsc.uc3m.es/~pmoreno/), [David Ramírez](https://ramirezgd.github.io/) and [Antonio Artés-Rodríguez](http://www.tsc.uc3m.es/~antonio/) 36 | 37 | For further information or contact: 38 | ``` 39 | pmoreno@tsc.uc3m.es 40 | ``` 41 | -------------------------------------------------------------------------------- /circadian/expectation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Pablo Moreno-Munoz 2 | # Universidad Carlos III de Madrid and eB2 (eb2.tech) 3 | 4 | import numpy as np 5 | import paramz 6 | import util 7 | from GPy.util import linalg 8 | 9 | class ExpectationStep(): 10 | 11 | def expectation(self, Y, K, C, t, pi, parameters, hyperparameters): 12 | 13 | self.N = Y.shape[0] 14 | self.T = Y.shape[1] 15 | 16 | # Model parameters 17 | pi = parameters[0].copy() 18 | f = parameters[1].copy() 19 | mu = parameters[2].copy() 20 | 21 | # Model hyperparameters 22 | ls = hyperparameters[0].copy() 23 | a0 = hyperparameters[1].copy() 24 | a = hyperparameters[2].copy() 25 | b = hyperparameters[3].copy() 26 | sigmas = hyperparameters[4].copy() 27 | 28 | # Missing values 29 | Yreal = Y[:, :, 0] 30 | Ybin = Y[:, :, 1] 31 | 32 | nans = np.isnan(Yreal) 33 | notnans = np.invert(nans) 34 | 35 | # Covariance 36 | hyperparam_list = [ls, a0, a, b, sigmas] 37 | S, L, Si = util.build_covariance(t, K, hyperparam_list) #dims: (T,T,K) 38 | matrices = {'S_old': S, 'L_old': L, 'Si_old': Si} 39 | 40 | # Posterior of latent classes 41 | r_ik = np.empty((self.N, K)) 42 | 43 | # Expectations on latent variables 44 | for k in range(K): 45 | #param_list = [f[:,k], S[:,:,k], Si[:,:,k], mu[:,k]] 46 | S_k = S[:, :, k] 47 | Si_k = Si[:, :, k] 48 | mu_k = mu[:,k] 49 | detS_k = np.linalg.det(S_k) 50 | #r_ik[:, k] = pi[0, k] * util.heterogeneous_pdf(Y, param_list) 51 | for i in range(self.N): 52 | r_ik[i,k] = pi[0,k]*(1/np.sqrt(detS_k * np.pi**self.T)) \ 53 | *np.exp(-0.5*np.dot(Yreal[i,np.ix_(notnans[i,:])], Si_k[np.ix_(notnans[i,:],notnans[i,:])]).dot(Yreal[i,np.ix_(notnans[i,:])].T)) \ 54 | *np.prod((mu_k[np.ix_(notnans[i,:])])**Ybin[i,np.ix_(notnans[i,:])] * (1 - mu_k[np.ix_(notnans[i,:])])**Ybin[i,np.ix_(notnans[i,:])]) 55 | 56 | r_ik = r_ik/np.tile(r_ik.sum(1)[:,np.newaxis],(1,K)) 57 | 58 | # Expectations on missing values 59 | c_ik = np.empty((self.N, K)) 60 | Y_expectation = [] 61 | 62 | for k in range(K): 63 | # Real observations 64 | Yreal_fill = Yreal.copy() 65 | S_k = S[:, :, k] 66 | Si_k = Si[:, :, k] 67 | 68 | for i in range(self.N): 69 | S_k_oo = S_k[np.ix_(notnans[i,:], notnans[i,:])] 70 | S_k_mm = S_k[np.ix_(nans[i,:], nans[i,:])] 71 | S_k_mo = S_k[np.ix_(nans[i,:], notnans[i,:])] 72 | S_k_om = S_k_mo.T 73 | Si_k_mm = Si_k[np.ix_(nans[i,:], nans[i,:])] # mm submatrix of Si_k 74 | 75 | L_k_oo = linalg.jitchol(S_k_oo) 76 | iS_k_oo, _ = linalg.dpotri(np.asfortranarray(L_k_oo)) # inverse of oo submatrix 77 | 78 | Cov_m = S_k_mm - (S_k_mo.dot(iS_k_oo).dot(S_k_om)) 79 | c_ik[i,k] = np.trace(Si_k_mm.dot(Cov_m)) 80 | 81 | Yreal_fill[i, nans[i, :]] = S_k_mo.dot(iS_k_oo).dot(Yreal[i, notnans[i, :]]) 82 | 83 | 84 | # Binary observations 85 | Ybin_fill = Ybin.copy() 86 | mu_matrix = np.tile(mu[:,k].T + 0.0,(self.N,1)) 87 | Ybin_fill[nans] = mu_matrix[nans] 88 | 89 | # Missings observation are now filled 90 | Y_fill_k = np.empty((self.N, self.T, 2)) 91 | Y_fill_k[:,:,0] = Yreal_fill 92 | Y_fill_k[:,:,1] = Ybin_fill 93 | 94 | Y_expectation.append(Y_fill_k) 95 | 96 | return r_ik, c_ik, Y_expectation, matrices -------------------------------------------------------------------------------- /circadian/util.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Pablo Moreno-Munoz 2 | # Universidad Carlos III de Madrid and eB2 (eb2.tech) 3 | 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | 7 | from GPy import kern 8 | from GPy.util import linalg 9 | from scipy.stats import multivariate_normal 10 | from scipy.stats import bernoulli 11 | 12 | def build_covariance(t, K, hyperparams): 13 | 14 | ls = hyperparams[0] 15 | a0 = hyperparams[1] 16 | a = hyperparams[2] 17 | b = hyperparams[3] 18 | 19 | C,_ = a.shape # number of Fourier coefficients 20 | 21 | T,_ = t.shape 22 | S = np.empty((T,T,K)) 23 | L = np.empty((T,T,K)) 24 | Si = np.empty((T,T,K)) 25 | 26 | Diag, _ = build_diagonal(t, hyperparams) 27 | for k in range(K): 28 | # falta meter el término periódic 29 | hyperparam_k_list = [ls[0,k], a0[0,k], a[:,k], b[:,k]] 30 | per_term = fourier_series(t, T, C, hyperparam_k_list) 31 | s = per_term**2 32 | per_S = s * s.T 33 | E = periodic_exponential(t, T, hyperparam_k_list) 34 | S[:,:,k] = per_S * E 35 | S[:,:,k] += Diag 36 | L[:,:,k] = linalg.jitchol(S[:,:,k]) 37 | Si[:,:,k], _ = linalg.dpotri(np.asfortranarray(L[:,:,k])) 38 | 39 | # quitar esto: 40 | #S[:,:,k] = np.eye(T, T) 41 | #Si[:,:,k] = np.eye(T, T) 42 | return S, L, Si 43 | 44 | def build_diagonal(t, hyperparams): 45 | sigmas = hyperparams[4] 46 | var_precision = sigmas.shape[0] 47 | T = t.shape[0] 48 | 49 | var_vector = np.ones((T,1)) 50 | per_length = np.int(T/var_precision) 51 | for p in range(var_precision): 52 | var_vector[per_length*p:per_length*(p+1)] = sigmas[p]*var_vector[per_length*p:per_length*(p+1)] 53 | 54 | var_vector = var_vector.flatten() 55 | Diag = np.diag(var_vector**2) 56 | 57 | # Matrix of derivatives: (T,T,var_precision) 58 | d_Diag = np.empty((T,T,var_precision)) 59 | for p in range(var_precision): 60 | d_Diag_aux = np.zeros((T,T)) 61 | d_Diag_aux[per_length * p:per_length * (p + 1), per_length * p:per_length * (p + 1)] = np.diag(var_vector[per_length*p:per_length*(p+1)]) 62 | d_Diag[:,:,p] = d_Diag_aux 63 | return Diag, d_Diag 64 | 65 | def heterogeneous_pdf(Y,params): 66 | N,T,_ = Y.shape 67 | Yreal = Y[:,:,0] 68 | Ybin = Y[:,:,1] 69 | 70 | notnans = np.invert(np.isnan(Yreal)) 71 | f = params[0] 72 | S = params[1] 73 | #Si = params[2] 74 | mu = params[3] 75 | 76 | n_pdf = np.empty((1,N)) 77 | b_pdf = np.empty((1, N)) 78 | # make this faster!! 79 | for i in range(N): 80 | n_pdf[0,i] = multivariate_normal(mean=f[notnans[i,:]].flatten(), cov=S[np.ix_(notnans[i,:], notnans[i,:])]).pdf(Yreal[i,notnans[i,:]]) 81 | b_pdf[0,i] = np.prod(bernoulli(mu[notnans[i,:]]).pmf(Ybin[i,notnans[i,:]])) 82 | 83 | het_pdf = n_pdf * b_pdf 84 | return het_pdf 85 | 86 | def heterogeneous_logpdf(Y,params): 87 | # Note that this logpdf is calculated over the filled observations (see previous expectations) 88 | N,T,_ = Y.shape 89 | Yreal = Y[:,:,0] 90 | Ybin = Y[:,:,1] 91 | 92 | f = params[0] 93 | S = params[1] 94 | #Si = params[2] 95 | mu = params[3] 96 | 97 | n_logpdf = np.empty((1,N)) 98 | b_logpdf = np.empty((1, N)) 99 | # make this faster!! 100 | for i in range(N): 101 | n_logpdf[0,i] = multivariate_normal(mean=f.flatten(), cov=S).logpdf(Yreal[i,:]) 102 | b_logpdf[0,i] = np.prod(bernoulli(mu).logpmf(Ybin[i,:])) 103 | 104 | het_logpdf = n_logpdf * b_logpdf 105 | return het_logpdf 106 | 107 | 108 | def fourier_series(t, T, C, hyperparams): 109 | a0 = hyperparams[1] 110 | a = hyperparams[2] 111 | b = hyperparams[3] 112 | 113 | x = np.tile(t, (1,C)) 114 | 115 | s = 0.5 * a0 116 | cos_args = 2 * np.pi * np.arange(1, C+1) / T 117 | sin_args = 2 * np.pi * np.arange(1, C+1) / T 118 | cos_term = np.cos(np.tile(cos_args[np.newaxis,:], (T, 1)) * x) 119 | sin_term = np.sin(np.tile(sin_args[np.newaxis, :], (T, 1)) * x) 120 | 121 | s += np.sum(a * cos_term, 1) + np.sum(b * sin_term, 1) 122 | return s[:,np.newaxis] 123 | 124 | def periodic_exponential(t, T, hyperparams): 125 | ls = hyperparams[0] 126 | trig_arg = np.pi * (t - t.T) / T 127 | sin2 = (np.sin(trig_arg) / ls) ** 2 128 | E = np.exp(-2 * sin2) 129 | return E 130 | 131 | -------------------------------------------------------------------------------- /circadian/circadian_model.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Pablo Moreno-Munoz 2 | # Universidad Carlos III de Madrid and eB2 (eb2.tech) 3 | 4 | import numpy as np 5 | import paramz 6 | import util 7 | from maximization import MaximizationStep 8 | from expectation import ExpectationStep 9 | import random 10 | import matplotlib.pyplot as plt 11 | 12 | class CircadianModel(paramz.Model): 13 | def __init__(self, Y, K, T, C=None, var_precision=None, name='Circadian'): 14 | super(CircadianModel, self).__init__(name=name) 15 | 16 | self.Y = Y 17 | self.N = Y.shape[0] 18 | self.K = K 19 | 20 | # automatic set-up ##### 21 | if T is None: 22 | self.T = 24 # hourly precision 23 | else: 24 | self.T = T 25 | 26 | assert self.T == Y.shape[1] 27 | 28 | if C is None: 29 | self.C = 3 30 | else: 31 | self.C = C 32 | 33 | if var_precision is None: 34 | self.var_precision = 2 35 | #self.var_precision = 1 36 | else: 37 | self.var_precision = var_precision 38 | ########################### 39 | 40 | self.t = np.arange(0, 1, 1 / self.T)[:, np.newaxis] 41 | 42 | self.maximization_step = MaximizationStep() 43 | self.expectation_step = ExpectationStep() 44 | 45 | # Parameters 46 | self.pi = paramz.Param('pi', np.random.dirichlet(50*np.ones((1, self.K)).flatten(), 1)) 47 | self.mu = paramz.Param('mu', 0.5*np.ones((self.T, self.K))) 48 | self.f = paramz.Param('f', np.random.randn(self.T, self.K)) 49 | 50 | # Kernel hyperparameters 51 | self.l = paramz.Param('lengthscale', 0.01*np.ones((1, self.K))) 52 | self.a0 = paramz.Param('a0_fourier', np.random.randn(1, self.K)) 53 | self.a = paramz.Param('a_fourier', np.random.randn(self.C, self.K)) 54 | self.b = paramz.Param('b_fourier', np.random.randn(self. C, self.K)) 55 | self.sigmas = paramz.Param('sigmas', np.ones((self.var_precision, 1))) 56 | 57 | # Parameters: 58 | self.model_parameters = [self.pi, self.f, self.mu] 59 | 60 | # Hyperparameters: 61 | self.link_parameter(self.l, index=0) 62 | self.link_parameter(self.a0) 63 | self.link_parameter(self.a) 64 | self.link_parameter(self.b) 65 | self.link_parameter(self.sigmas) 66 | 67 | # Expected variables 68 | self.r_ik, self.c_ik, self.Y_exp, self.matrices = self.expectation_step.expectation(Y=self.Y, K=self.K, C=self.C, t=self.t, 69 | pi=self.pi, 70 | parameters=self.model_parameters, 71 | hyperparameters=self.parameters) 72 | 73 | self.expected_values = {'r_ik': self.r_ik, 'c_ik': self.c_ik, 'Y_exp': self.Y_exp, 'matrices': self.matrices} 74 | 75 | def objective_function(self): 76 | return -self._log_likelihood 77 | 78 | def parameters_changed(self): 79 | self._log_likelihood, gradients = self.maximization_step.maximization(Y=self.Y, K=self.K, C=self.C, 80 | t=self.t, parameters=self.model_parameters, 81 | hyperparameters=self.parameters, #los parameters son los linked 82 | expectations=self.expected_values) 83 | 84 | # Loading gradients: 85 | self.l.gradient = -gradients['dL_dl'] 86 | self.a0.gradient= -gradients['dL_da0'] 87 | self.a.gradient = -gradients['dL_da'] 88 | self.b.gradient = -gradients['dL_db'] 89 | self.sigmas.gradient = -gradients['dL_dsigmas'] #por que pone self.b.sigmas = ... --- self.sigmas.gradient 90 | 91 | def em_algorithm(self, iterations, convergence=False): 92 | 93 | for it in range(iterations): 94 | # E-Step 95 | self.r_ik, self.c_ik, self.Y_exp, self.matrices = self.expectation_step.expectation(Y=self.Y, K=self.K, C=self.C, t=self.t, pi=self.pi, 96 | parameters=self.model_parameters, 97 | hyperparameters=self.parameters) 98 | 99 | self.expected_values['r_ik'] = self.r_ik 100 | self.expected_values['c_ik'] = self.c_ik 101 | self.expected_values['Y_exp'] = self.Y_exp 102 | self.expected_values['matrices'] = self.matrices 103 | 104 | # M-Step 105 | for k in range(self.K): 106 | Y_exp_real = self.Y_exp[k][:,:,0] 107 | Y_exp_bin = self.Y_exp[k][:, :, 1] 108 | 109 | self.pi[0, k] = sum(self.r_ik[:, k]) / self.N 110 | self.f[:, k] = sum(Y_exp_real*np.tile(self.r_ik[:,k,np.newaxis],(1, self.T))/sum(self.r_ik[:,k]),0) 111 | self.mu[:,k] = sum(Y_exp_bin*np.tile(self.r_ik[:,k,np.newaxis],(1, self.T))/sum(self.r_ik[:,k]),0) 112 | 113 | self.optimize(messages=True, max_iters=100) -------------------------------------------------------------------------------- /circadian/maximization.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Pablo Moreno-Munoz 2 | # Universidad Carlos III de Madrid and eB2 (eb2.tech) 3 | 4 | import numpy as np 5 | import paramz 6 | import util 7 | from GPy.util import linalg 8 | 9 | class MaximizationStep(): 10 | 11 | def maximization(self, Y, K, C, t, parameters, hyperparameters, expectations): 12 | 13 | self.N = Y.shape[0] 14 | self.T = Y.shape[1] 15 | 16 | # Model parameters 17 | pi = parameters[0].copy() 18 | f = parameters[1].copy() 19 | mu = parameters[2].copy() 20 | 21 | # Model hyperparameters 22 | ls = hyperparameters[0].copy() 23 | a0 = hyperparameters[1].copy() 24 | a = hyperparameters[2].copy() 25 | b = hyperparameters[3].copy() 26 | sigmas = hyperparameters[4].copy() 27 | 28 | var_precision = sigmas.shape[0] 29 | 30 | # Expected values 31 | r_ik = expectations['r_ik'] 32 | #c_ik = expectations['c_ik'] 33 | Y_exp = expectations['Y_exp'] 34 | matrices = expectations['matrices'] 35 | 36 | # old building of matrices 37 | Sold = matrices['S_old'] 38 | Lold = matrices['L_old'] 39 | Siold = matrices['Si_old'] 40 | 41 | # new building of matrices 42 | hyperparam_list = [ls, a0, a, b, sigmas] 43 | S, L, Si = util.build_covariance(t, K, hyperparam_list) #dims: (T,T,K) 44 | 45 | # Identifiying missing (NaN) values 46 | nans = np.isnan(Y[:,:,0]) 47 | notnans = np.invert(nans) 48 | 49 | # Expected Log-Likelihood (Cost Function) 50 | log_likelihood = 0.0 51 | het_logpdf = np.empty((self.N, K)) 52 | 53 | # Log-likelihood derivatives wrt hyperparameters 54 | dL_dl = np.zeros((1, K)) 55 | dL_da0 = np.zeros((1, K)) 56 | dL_da = np.zeros((C, K)) 57 | dL_db = np.zeros((C, K)) 58 | dL_dsigmas = np.zeros((var_precision, 1)) 59 | 60 | c_ik = np.empty((self.N, K)) 61 | 62 | for k in range(K): 63 | S_k = S[:, :, k] # new 64 | Si_k = Si[:, :, k] # new 65 | 66 | Sold_k = Sold[:, :, k] # old 67 | Siold_k = Siold[:, :, k] # old 68 | 69 | Y_exp_k = Y_exp[k] 70 | Y_exp_real = Y_exp_k[:, :, 0] 71 | Y_exp_bin = Y_exp_k[:, :, 1] 72 | detS_k = np.linalg.det(S_k) 73 | 74 | for i in range(self.N): 75 | Sold_k_oo = Sold_k[np.ix_(notnans[i,:], notnans[i,:])] 76 | Sold_k_mm = Sold_k[np.ix_(nans[i,:], nans[i,:])] 77 | Sold_k_mo = Sold_k[np.ix_(nans[i,:], notnans[i,:])] 78 | Sold_k_om = Sold_k_mo.T 79 | Si_k_mm = Si_k[np.ix_(nans[i,:], nans[i,:])] # mm submatrix of Si_k 80 | 81 | Lold_k_oo = linalg.jitchol(Sold_k_oo) 82 | iSold_k_oo, _ = linalg.dpotri(np.asfortranarray(Lold_k_oo)) # inverse of oo submatrix 83 | 84 | Cov_m = Sold_k_mm - (Sold_k_mo.dot(iSold_k_oo).dot(Sold_k_om)) 85 | c_ik[i,k] = np.trace(Si_k_mm.dot(Cov_m)) 86 | 87 | A_m = np.zeros((self.T, self.T)) 88 | A_m[np.ix_(nans[i, :], nans[i, :])] = Cov_m 89 | 90 | y = Y_exp_real[i, :].T 91 | y = y[:, np.newaxis] 92 | yy_T = np.dot(y,y.T) 93 | aa_T = Si_k.dot(yy_T).dot(Si_k.T) 94 | 95 | Q1 = aa_T - Si_k 96 | Q2 = Si_k.dot(A_m).dot(Si_k) 97 | 98 | dK_dl, dK_da0, dK_da, dK_db, dK_dsigmas = self.kernel_gradients(Q1, Q2, t, k, C, hyperparam_list) 99 | 100 | 101 | dL_dl[0,k] += 0.5*r_ik[i,k]*dK_dl 102 | dL_da0[0, k] += 0.5*r_ik[i,k]*dK_da0 103 | dL_da[:,k] += 0.5*r_ik[i,k]*dK_da.flatten() 104 | dL_db[:,k] += 0.5*r_ik[i,k]*dK_db.flatten() 105 | dL_dsigmas += 0.5*r_ik[i,k]*dK_dsigmas 106 | 107 | log_likelihood += - 0.5*r_ik[i,k]*np.log(pi[0,k]) - 0.5*r_ik[i,k]*np.log(detS_k) \ 108 | - 0.5*r_ik[i,k] * np.dot(Y_exp_real[i,:],Si_k).dot(Y_exp_real[i,:].T) \ 109 | - 0.5*r_ik[i,k]*c_ik[i,k] \ 110 | + r_ik[i,k]*np.sum(Y_exp_bin[i,:]*np.log(mu[:, k])) \ 111 | + r_ik[i,k]*np.sum(Y_exp_bin[i,:]*np.log(1 - mu[:, k])) 112 | # + r_ik[i,k]*[] 113 | # falta el pi de la gaussian 114 | 115 | 116 | #param_list = [f[:, k], S[:, :, k], Si[:, :, k], mu[:, k]] 117 | 118 | gradients = {'dL_dl':dL_dl, 'dL_da0':dL_da0, 'dL_da':dL_da, 'dL_db':dL_db, 'dL_dsigmas':dL_dsigmas} 119 | 120 | return log_likelihood, gradients 121 | 122 | def kernel_gradients(self, Q1, Q2, t, k, C, hyperparam_list): 123 | 124 | # Kernel gradients wrt hyperparameters 125 | ls = hyperparam_list[0].copy() 126 | a0 = hyperparam_list[1].copy() 127 | a = hyperparam_list[2].copy() 128 | b = hyperparam_list[3].copy() 129 | sigmas = hyperparam_list[4].copy() 130 | 131 | n_fourier = a.shape[0] 132 | var_precision = sigmas.shape[0] 133 | 134 | trig_arg = np.pi * (t - t.T) / self.T 135 | 136 | hyperparam_k_list = [ls[0, k], a0[0, k], a[:, k], b[:, k]] 137 | s = util.fourier_series(t, self.T, C, hyperparam_k_list) 138 | s2 = s**2 139 | sin2 = (np.sin(trig_arg) / ls[0, k]) ** 2 140 | E = np.exp(-2*sin2) 141 | K = (s2 * s2.T) * E 142 | 143 | L = K * 4 * sin2 / ls[0, k] 144 | A0 = (s * s.T) * E * (s + s.T) 145 | 146 | _ , d_Diag = util.build_diagonal(t, hyperparam_list) 147 | 148 | dK_dl = np.trace(Q1.dot(L)) + np.trace(Q2.dot(L)) 149 | dK_da0 = np.trace(Q1.dot(A0)) + np.trace(Q2.dot(A0)) 150 | 151 | dK_dsigmas = np.empty((var_precision,1)) 152 | for p in range(var_precision): 153 | dK_dsigmas[p] = np.trace(Q1.dot(2 * d_Diag[:, :, p])) + np.trace(Q2.dot(2*d_Diag[:,:,p])) 154 | 155 | dK_da = np.empty((n_fourier,1)) 156 | dK_db = np.empty((n_fourier,1)) 157 | 158 | for n in range(n_fourier): 159 | sin_term = np.sin(2*np.pi*(n+1)*t/self.T) 160 | cos_term = np.cos(2*np.pi*(n+1)*t/self.T) 161 | 162 | cos_s = cos_term * s.T 163 | sin_s = sin_term * s.T 164 | 165 | An = 2 * E * (s * s.T) * (cos_s + cos_s.T) 166 | Bn = 2 * E * (s * s.T) * (sin_s + sin_s.T) 167 | 168 | dK_da[n] = np.trace(Q1.dot(An)) + np.trace(Q2.dot(An)) 169 | dK_db[n] = np.trace(Q1.dot(Bn)) + np.trace(Q2.dot(Bn)) 170 | 171 | return dK_dl, dK_da0, dK_da, dK_db, dK_dsigmas 172 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /notebooks/demo_detector.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Hierarchical Change-Point Detection" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import sys\n", 17 | "import os\n", 18 | "sys.path.append('..')\n", 19 | "\n", 20 | "import numpy as np\n", 21 | "from hiercpd.hiercpd import HierCPD # loading Hierarchical Detector package" 22 | ] 23 | }, 24 | { 25 | "cell_type": "markdown", 26 | "metadata": {}, 27 | "source": [ 28 | "### Categorical sequence" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 2, 34 | "metadata": {}, 35 | "outputs": [], 36 | "source": [ 37 | "Z = np.vstack((1*np.ones((20,1)), 2*np.ones((20,1)) ))\n", 38 | "Z[1,:] = np.nan\n", 39 | "Z[7,:] = np.nan\n", 40 | "Z[15,:] = np.nan\n", 41 | "\n", 42 | "# Sequence of ones and twos (K=2) with missing samples (NaN values). \n", 43 | "# This secuence will come from the previous module in a pipeline\n", 44 | "# setting of the tool. I recommend to try with different toy sequences\n", 45 | "# and increase the number of categories (K=10, K=20, ...)" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "### Model definition" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 4, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "name": "stderr", 62 | "output_type": "stream", 63 | "text": [ 64 | "../hiercpd/hiercpd.py:76: RuntimeWarning: divide by zero encountered in log\n", 65 | " plt.imshow(-np.log(self.R), cmap='gray', aspect='auto')\n" 66 | ] 67 | }, 68 | { 69 | "data": { 70 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAHWCAYAAABzDi4SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XmYHGW5///3pyeTBAhLQiJGFgHlgKgYdMhx4aCiICImqBwEPIoeNG54jCsgKgIu4AK4oggIKouIoJGDILJ7QMhEkpCwhsUviYFEErKSber+/VE1/LqGma7OdE93z8zndV19TVc91d131/TM3fXc9TyliMDMzKxbqdkBmJlZa3FiMDOzHCcGMzPLcWIwM7McJwYzM8txYjAzs5yaEoOkcZJukPRw9nNsH9t1SZqd3WaUrd9N0l2SFkj6jaSRtcRjZma1q/WI4UTgxojYA7gxW+7NsxExKbtNKVt/JnB2RLwUWA4cV2M8ZmZWI9UywE3Sg8CbImKxp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NTFEqGGS0p4Gc2IYLPaPiFcDbwc+KemAZgdUJNLjzpb7RkR6nY6XAJOAxcD3mhtOStIY4HfA9IhYWd7WCvuyl/haaj9GRFdETCKdK20ysFcz4+lNzxglvQI4iTTW/YBxpLM4NEWtk5T2NJgTwyJg57LllpyALyIWZT+XAFfTuqO8n5I0ESD7uaTJ8TxPRDyV/YEmwM9pgX0pqZ30n+4lEXFVtrpl9mVv8bXifgSIiGeAm4HXkU2umTW1zN92WYyHZF11ERHrgV/Q3P3YPUnp46Td6gdSNklptk3V+3EwJ4aZwB5Z1X0kcBQwo8kx5UjaStLW3feBg4F5lR/VNDOAY7P7xwJ/aGIsver+Z5t5F03el1kf7gXA/RFxVllTS+zLvuJrpf0oaYKk7bL7WwAHkdZCbgaOyDZr6uexjxgfKEv+Iu27b9p+jIiTImKniNiV9H/hTRHxPvq7H5tdRa+xAn8o6ZkWjwAnNzueXuLbnfRsqTnA/FaJEbiMtAthI2m/43Gk/ZE3Ag8DfwHGtWCMvwLuBeaS/vOd2OQY9yftJpoLzM5uh7bKvqwQX8vsR2Af0skz55L+Y/1qtn534G5gAfBbYFQLxnhTth/nAb8mO3Op2TfgTfz/ZyX1az965LOZmeUM5q4kMzMbAE4MZmaW48RgZmY5TgxmZpbjxGBmZjlODGZmluPEYGZmOU4MZmaW8/8BwFK6XWP7v24AAAAASUVORK5CYII=\n", 71 | "text/plain": [ 72 | "
" 73 | ] 74 | }, 75 | "metadata": {}, 76 | "output_type": "display_data" 77 | } 78 | ], 79 | "source": [ 80 | "hyp_lambda = 1e3 # this hyper-parameter sets the inverse probability of change. (try other values)\n", 81 | "\n", 82 | "cpd_model = HierCPD(Z, hyp_lambda)\n", 83 | "cpd_model.detection()\n", 84 | "cpd_model.plot_detection()" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": null, 90 | "metadata": {}, 91 | "outputs": [], 92 | "source": [] 93 | } 94 | ], 95 | "metadata": { 96 | "kernelspec": { 97 | "display_name": "Python 3", 98 | "language": "python", 99 | "name": "python3" 100 | }, 101 | "language_info": { 102 | "codemirror_mode": { 103 | "name": "ipython", 104 | "version": 3 105 | }, 106 | "file_extension": ".py", 107 | "mimetype": "text/x-python", 108 | "name": "python", 109 | "nbconvert_exporter": "python", 110 | "pygments_lexer": "ipython3", 111 | "version": "3.6.5" 112 | } 113 | }, 114 | "nbformat": 4, 115 | "nbformat_minor": 2 116 | } 117 | --------------------------------------------------------------------------------