Skip to content

Commit 9eb73fd

Browse files
committed
remove commented-out code
1 parent 2852ea2 commit 9eb73fd

File tree

2 files changed

+0
-211
lines changed

2 files changed

+0
-211
lines changed

examples/diagonal_gibbs.py

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,3 @@
1-
# from __future__ import division
2-
# import numpy as np
3-
# import numpy.random as npr
4-
# import matplotlib.pyplot as plt
5-
#
6-
# from pybasicbayes.distributions import Regression, DiagonalRegression
7-
# from pybasicbayes.util.text import progprint_xrange
8-
#
9-
# from pylds.models import LDS, DefaultLDS
10-
#
11-
# npr.seed(0)
12-
#
13-
#
14-
# #########################
15-
# # set some parameters #
16-
# #########################
17-
# D_obs, D_latent = 1, 2
18-
# mu_init = np.array([0.,1.])
19-
# sigma_init = 0.01*np.eye(2)
20-
#
21-
# A = 0.99*np.array([[np.cos(np.pi/24), -np.sin(np.pi/24)],
22-
# [np.sin(np.pi/24), np.cos(np.pi/24)]])
23-
# sigma_states = 0.01*np.eye(2)
24-
#
25-
# C = np.array([[10.,0.]])
26-
# sigma_obs = 0.01*np.eye(D_obs)
27-
#
28-
#
29-
# ###################
30-
# # generate data #
31-
# ###################
32-
#
33-
# truemodel = LDS(
34-
# dynamics_distn=Regression(A=A,sigma=sigma_states),
35-
# emission_distn=DiagonalRegression(D_obs, D_latent, A=C, sigmasq=np.diag(sigma_obs)))
36-
#
37-
# data, stateseq = truemodel.generate(2000)
38-
#
39-
#
40-
# ###############
41-
# # fit model #
42-
# ###############
43-
#
44-
# def update(model):
45-
# model.resample_model()
46-
# return model.log_likelihood()
47-
#
48-
# diag_model = LDS(
49-
# dynamics_distn=Regression(
50-
# nu_0=D_latent+3,
51-
# S_0=D_latent*np.eye(D_latent),
52-
# M_0=np.zeros((D_latent, D_latent)),
53-
# K_0=D_latent*np.eye(D_latent)),
54-
# emission_distn=DiagonalRegression(D_obs, D_latent))
55-
#
56-
# diag_model.add_data(data)
57-
#
58-
# full_model = model = DefaultLDS(D_latent=2, D_obs=data.shape[1]).add_data(data)
59-
#
60-
# diag_lls = [update(diag_model) for _ in progprint_xrange(200)]
61-
# full_lls = [update(full_model) for _ in progprint_xrange(200)]
62-
#
63-
# plt.figure(figsize=(3,4))
64-
# plt.plot(diag_lls, label="diagonal")
65-
# plt.plot(full_lls, label="full")
66-
# plt.xlabel('iteration')
67-
# plt.ylabel('log likelihood')
68-
# plt.legend()
69-
#
70-
# ################
71-
# # smoothing #
72-
# ################
73-
# smoothed_obs = diag_model.smooth(data)
74-
#
75-
# ################
76-
# # predicting #
77-
# ################
78-
# Nseed = 1700
79-
# Npredict = 100
80-
# prediction_seed = data[:Nseed]
81-
#
82-
# diag_preds = diag_model.sample_predictions(
83-
# prediction_seed, Npredict, obs_noise=False)
84-
#
85-
# full_preds = full_model.sample_predictions(
86-
# prediction_seed, Npredict, obs_noise=False)
87-
#
88-
# plt.figure()
89-
# plt.plot(data, 'k-')
90-
# plt.plot(smoothed_obs[:Nseed], ':k')
91-
# plt.plot(Nseed + np.arange(Npredict), diag_preds, 'b')
92-
# plt.plot(Nseed + np.arange(Npredict), full_preds, 'r')
93-
# plt.xlabel('time index')
94-
# plt.ylabel('prediction')
95-
# # plt.xlim(1800,2000)
96-
#
97-
# plt.show()
98-
#
99-
1001
from __future__ import division
1012
import numpy as np
1023
import numpy.random as npr

examples/meanfield.py

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,3 @@
1-
# from __future__ import division
2-
# import numpy as np
3-
# import numpy.random as npr
4-
# import matplotlib.pyplot as plt
5-
#
6-
# from pybasicbayes.distributions import Regression
7-
# from pybasicbayes.util.text import progprint_xrange
8-
#
9-
# from pylds.models import LDS
10-
#
11-
# npr.seed(0)
12-
#
13-
#
14-
# #########################
15-
# # set some parameters #
16-
# #########################
17-
# D_obs = 1
18-
# D_latent = 2
19-
# D_input = 0
20-
# T = 2000
21-
#
22-
# mu_init = np.array([0.,1.])
23-
# sigma_init = 0.01*np.eye(2)
24-
#
25-
# A = 0.99*np.array([[np.cos(np.pi/24), -np.sin(np.pi/24)],
26-
# [np.sin(np.pi/24), np.cos(np.pi/24)]])
27-
# B = np.ones((D_latent, D_input))
28-
# sigma_states = 0.01*np.eye(2)
29-
#
30-
# C = np.array([[10.,0.]])
31-
# D = np.zeros((D_obs, D_input))
32-
# sigma_obs = 0.01*np.eye(1)
33-
#
34-
# ###################
35-
# # generate data #
36-
# ###################
37-
#
38-
# truemodel = LDS(
39-
# dynamics_distn=Regression(A=np.hstack((A,B)), sigma=sigma_states),
40-
# emission_distn=Regression(A=np.hstack((C,D)), sigma=sigma_obs))
41-
#
42-
# inputs = np.random.randn(T, D_input)
43-
# # inputs = np.zeros((T, D_input))
44-
# data, stateseq = truemodel.generate(T, inputs=inputs)
45-
#
46-
#
47-
# ###############
48-
# # make model #
49-
# ###############
50-
# model = LDS(
51-
# dynamics_distn=Regression(nu_0=D_latent + 2,
52-
# S_0=D_latent * np.eye(D_latent),
53-
# M_0=np.zeros((D_latent, D_latent + D_input)),
54-
# K_0=(D_latent + D_input) * np.eye(D_latent + D_input),
55-
# # A=np.hstack((A,B)), sigma=sigma_states
56-
# ),
57-
# emission_distn=Regression(nu_0=D_obs + 2,
58-
# S_0=D_obs * np.eye(D_obs),
59-
# M_0=np.zeros((D_obs, D_latent + D_input)),
60-
# K_0=(D_latent + D_input) * np.eye(D_latent + D_input),
61-
# # A=np.hstack((C,D)), sigma=100*sigma_obs
62-
# )
63-
# )
64-
# model.add_data(data, inputs=inputs)
65-
# # model.emission_distn._initialize_mean_field()
66-
# # model.dynamics_distn._initialize_mean_field()
67-
#
68-
# ###############
69-
# # fit model #
70-
# ###############
71-
# def update(model):
72-
# return model.meanfield_coordinate_descent_step()
73-
#
74-
# for _ in progprint_xrange(100):
75-
# model.resample_model()
76-
#
77-
# N_steps = 100
78-
# vlbs = [update(model) for _ in progprint_xrange(N_steps)]
79-
# model.resample_from_mf()
80-
#
81-
# plt.figure(figsize=(3,4))
82-
# plt.plot([0, N_steps], truemodel.log_likelihood()*np.ones(2), '--k')
83-
# plt.plot(vlbs)
84-
# plt.xlabel('iteration')
85-
# plt.ylabel('variational lower bound')
86-
# plt.show()
87-
#
88-
# ################
89-
# # smoothing #
90-
# ################
91-
# smoothed_obs = model.states_list[0].meanfield_smooth()
92-
#
93-
# ################
94-
# # predicting #
95-
# ################
96-
# Nseed = 1700
97-
# Npredict = 100
98-
# prediction_seed = data[:Nseed]
99-
#
100-
# model.emission_distn.resample_from_mf()
101-
# predictions = model.sample_predictions(prediction_seed, Npredict)
102-
#
103-
# plt.figure()
104-
# plt.plot(data, 'k')
105-
# plt.plot(smoothed_obs[:Nseed], ':k')
106-
# plt.plot(Nseed + np.arange(Npredict), predictions, 'b')
107-
# plt.xlabel('time index')
108-
# plt.ylabel('prediction')
109-
#
110-
# plt.show()
111-
1121
from __future__ import division
1132
import numpy as np
1143
import numpy.random as npr
@@ -192,4 +81,3 @@ def update(model):
19281
plt.legend()
19382

19483
plt.show()
195-

0 commit comments

Comments
 (0)