id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
222,500 | RJT1990/pyflux | pyflux/families/skewt.py | Skewt.pdf | def pdf(self, mu):
"""
PDF for Skew t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfor... | python | def pdf(self, mu):
"""
PDF for Skew t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfor... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"self",
".",
"pdf_internal",
"(",
"mu",
",",
"df",
"=",
"self",
".",
"df0",
... | PDF for Skew t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Skew",
"t",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L349-L364 |
222,501 | RJT1990/pyflux | pyflux/families/skewt.py | Skewt.cdf | def cdf(x, df, loc=0.0, scale=1.0, gamma = 1.0):
"""
CDF function for Skew t distribution
"""
result = np.zeros(x.shape[0])
result[x<0] = 2.0/(np.power(gamma,2) + 1.0)*ss.t.cdf(gamma*(x[x-loc < 0]-loc[x-loc < 0])/scale, df=df)
result[x>=0] = 1.0/(np.power(gamma,2) + 1.0) ... | python | def cdf(x, df, loc=0.0, scale=1.0, gamma = 1.0):
"""
CDF function for Skew t distribution
"""
result = np.zeros(x.shape[0])
result[x<0] = 2.0/(np.power(gamma,2) + 1.0)*ss.t.cdf(gamma*(x[x-loc < 0]-loc[x-loc < 0])/scale, df=df)
result[x>=0] = 1.0/(np.power(gamma,2) + 1.0) ... | [
"def",
"cdf",
"(",
"x",
",",
"df",
",",
"loc",
"=",
"0.0",
",",
"scale",
"=",
"1.0",
",",
"gamma",
"=",
"1.0",
")",
":",
"result",
"=",
"np",
".",
"zeros",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
")",
"result",
"[",
"x",
"<",
"0",
"]",
"="... | CDF function for Skew t distribution | [
"CDF",
"function",
"for",
"Skew",
"t",
"distribution"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L434-L441 |
222,502 | RJT1990/pyflux | pyflux/families/skewt.py | Skewt.ppf | def ppf(q, df, loc=0.0, scale=1.0, gamma = 1.0):
"""
PPF function for Skew t distribution
"""
result = np.zeros(q.shape[0])
probzero = Skewt.cdf(x=np.zeros(1),loc=np.zeros(1),df=df,gamma=gamma)
result[q<probzero] = 1.0/gamma*ss.t.ppf(((np.power(gamma,2) + 1.0) * q[q<probz... | python | def ppf(q, df, loc=0.0, scale=1.0, gamma = 1.0):
"""
PPF function for Skew t distribution
"""
result = np.zeros(q.shape[0])
probzero = Skewt.cdf(x=np.zeros(1),loc=np.zeros(1),df=df,gamma=gamma)
result[q<probzero] = 1.0/gamma*ss.t.ppf(((np.power(gamma,2) + 1.0) * q[q<probz... | [
"def",
"ppf",
"(",
"q",
",",
"df",
",",
"loc",
"=",
"0.0",
",",
"scale",
"=",
"1.0",
",",
"gamma",
"=",
"1.0",
")",
":",
"result",
"=",
"np",
".",
"zeros",
"(",
"q",
".",
"shape",
"[",
"0",
"]",
")",
"probzero",
"=",
"Skewt",
".",
"cdf",
"(... | PPF function for Skew t distribution | [
"PPF",
"function",
"for",
"Skew",
"t",
"distribution"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L444-L452 |
222,503 | RJT1990/pyflux | pyflux/families/family.py | Family.transform_define | def transform_define(transform):
"""
This function links the user's choice of transformation with the associated numpy function
"""
if transform == 'tanh':
return np.tanh
elif transform == 'exp':
return np.exp
elif transform == 'logit':
... | python | def transform_define(transform):
"""
This function links the user's choice of transformation with the associated numpy function
"""
if transform == 'tanh':
return np.tanh
elif transform == 'exp':
return np.exp
elif transform == 'logit':
... | [
"def",
"transform_define",
"(",
"transform",
")",
":",
"if",
"transform",
"==",
"'tanh'",
":",
"return",
"np",
".",
"tanh",
"elif",
"transform",
"==",
"'exp'",
":",
"return",
"np",
".",
"exp",
"elif",
"transform",
"==",
"'logit'",
":",
"return",
"Family",
... | This function links the user's choice of transformation with the associated numpy function | [
"This",
"function",
"links",
"the",
"user",
"s",
"choice",
"of",
"transformation",
"with",
"the",
"associated",
"numpy",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/family.py#L26-L39 |
222,504 | RJT1990/pyflux | pyflux/families/family.py | Family.itransform_define | def itransform_define(transform):
"""
This function links the user's choice of transformation with its inverse
"""
if transform == 'tanh':
return np.arctanh
elif transform == 'exp':
return np.log
elif transform == 'logit':
return Family... | python | def itransform_define(transform):
"""
This function links the user's choice of transformation with its inverse
"""
if transform == 'tanh':
return np.arctanh
elif transform == 'exp':
return np.log
elif transform == 'logit':
return Family... | [
"def",
"itransform_define",
"(",
"transform",
")",
":",
"if",
"transform",
"==",
"'tanh'",
":",
"return",
"np",
".",
"arctanh",
"elif",
"transform",
"==",
"'exp'",
":",
"return",
"np",
".",
"log",
"elif",
"transform",
"==",
"'logit'",
":",
"return",
"Famil... | This function links the user's choice of transformation with its inverse | [
"This",
"function",
"links",
"the",
"user",
"s",
"choice",
"of",
"transformation",
"with",
"its",
"inverse"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/family.py#L42-L55 |
222,505 | RJT1990/pyflux | pyflux/gpnarx/gpnarx.py | GPNARX._L | def _L(self, parm):
""" Creates cholesky decomposition of covariance matrix
Parameters
----------
parm : np.array
Contains transformed latent variables
Returns
----------
The cholesky decomposition (L) of K
"""
return np.linalg.chol... | python | def _L(self, parm):
""" Creates cholesky decomposition of covariance matrix
Parameters
----------
parm : np.array
Contains transformed latent variables
Returns
----------
The cholesky decomposition (L) of K
"""
return np.linalg.chol... | [
"def",
"_L",
"(",
"self",
",",
"parm",
")",
":",
"return",
"np",
".",
"linalg",
".",
"cholesky",
"(",
"self",
".",
"kernel",
".",
"K",
"(",
"parm",
")",
"+",
"np",
".",
"identity",
"(",
"self",
".",
"X",
"(",
")",
".",
"shape",
"[",
"1",
"]",... | Creates cholesky decomposition of covariance matrix
Parameters
----------
parm : np.array
Contains transformed latent variables
Returns
----------
The cholesky decomposition (L) of K | [
"Creates",
"cholesky",
"decomposition",
"of",
"covariance",
"matrix"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gpnarx/gpnarx.py#L176-L189 |
222,506 | RJT1990/pyflux | pyflux/gpnarx/gpnarx.py | GPNARX.plot_fit | def plot_fit(self, intervals=True, **kwargs):
""" Plots the fit of the Gaussian process model to the data
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
intervals : Boolean
Whether to plot uncert... | python | def plot_fit(self, intervals=True, **kwargs):
""" Plots the fit of the Gaussian process model to the data
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
intervals : Boolean
Whether to plot uncert... | [
"def",
"plot_fit",
"(",
"self",
",",
"intervals",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"seaborn",
"as",
"sns",
"figsize",
"=",
"kwargs",
".",
"get",
"(",
"'figsize'",
",",
"(",
... | Plots the fit of the Gaussian process model to the data
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
intervals : Boolean
Whether to plot uncertainty intervals or not
Returns
--... | [
"Plots",
"the",
"fit",
"of",
"the",
"Gaussian",
"process",
"model",
"to",
"the",
"data"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gpnarx/gpnarx.py#L260-L315 |
222,507 | RJT1990/pyflux | pyflux/gas/gas.py | GAS._get_scale_and_shape | def _get_scale_and_shape(self,parm):
""" Obtains appropriate model scale and shape latent variables
Parameters
----------
parm : np.array
Transformed latent variable vector
Returns
----------
None (changes model attributes)
"""
if se... | python | def _get_scale_and_shape(self,parm):
""" Obtains appropriate model scale and shape latent variables
Parameters
----------
parm : np.array
Transformed latent variable vector
Returns
----------
None (changes model attributes)
"""
if se... | [
"def",
"_get_scale_and_shape",
"(",
"self",
",",
"parm",
")",
":",
"if",
"self",
".",
"scale",
"is",
"True",
":",
"if",
"self",
".",
"shape",
"is",
"True",
":",
"model_shape",
"=",
"parm",
"[",
"-",
"1",
"]",
"model_scale",
"=",
"parm",
"[",
"-",
"... | Obtains appropriate model scale and shape latent variables
Parameters
----------
parm : np.array
Transformed latent variable vector
Returns
----------
None (changes model attributes) | [
"Obtains",
"appropriate",
"model",
"scale",
"and",
"shape",
"latent",
"variables"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gas/gas.py#L127-L156 |
222,508 | RJT1990/pyflux | pyflux/gas/gas.py | GAS.plot_sample | def plot_sample(self, nsims=10, plot_data=True, **kwargs):
"""
Plots draws from the posterior predictive density against the data
Parameters
----------
nsims : int (default : 1000)
How many draws from the posterior predictive distribution
plot_data boolean
... | python | def plot_sample(self, nsims=10, plot_data=True, **kwargs):
"""
Plots draws from the posterior predictive density against the data
Parameters
----------
nsims : int (default : 1000)
How many draws from the posterior predictive distribution
plot_data boolean
... | [
"def",
"plot_sample",
"(",
"self",
",",
"nsims",
"=",
"10",
",",
"plot_data",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"latent_variables",
".",
"estimation_method",
"not",
"in",
"[",
"'BBVI'",
",",
"'M-H'",
"]",
":",
"raise",
... | Plots draws from the posterior predictive density against the data
Parameters
----------
nsims : int (default : 1000)
How many draws from the posterior predictive distribution
plot_data boolean
Whether to plot the data or not | [
"Plots",
"draws",
"from",
"the",
"posterior",
"predictive",
"density",
"against",
"the",
"data"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gas/gas.py#L939-L967 |
222,509 | RJT1990/pyflux | pyflux/arma/arma.py | ARIMA._ar_matrix | def _ar_matrix(self):
""" Creates the Autoregressive matrix for the model
Returns
----------
X : np.ndarray
Autoregressive Matrix
"""
X = np.ones(self.data_length-self.max_lag)
if self.ar != 0:
for i in range(0, self.ar):
... | python | def _ar_matrix(self):
""" Creates the Autoregressive matrix for the model
Returns
----------
X : np.ndarray
Autoregressive Matrix
"""
X = np.ones(self.data_length-self.max_lag)
if self.ar != 0:
for i in range(0, self.ar):
... | [
"def",
"_ar_matrix",
"(",
"self",
")",
":",
"X",
"=",
"np",
".",
"ones",
"(",
"self",
".",
"data_length",
"-",
"self",
".",
"max_lag",
")",
"if",
"self",
".",
"ar",
"!=",
"0",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"ar",
... | Creates the Autoregressive matrix for the model
Returns
----------
X : np.ndarray
Autoregressive Matrix | [
"Creates",
"the",
"Autoregressive",
"matrix",
"for",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arma.py#L109-L124 |
222,510 | RJT1990/pyflux | pyflux/families/inverse_wishart.py | InverseWishart.logpdf | def logpdf(self, X):
"""
Log PDF for Inverse Wishart prior
Parameters
----------
X : float
Covariance matrix for which the prior is being formed over
Returns
----------
- log(p(X))
"""
return invwishart.logpdf(X, df=self.v, sc... | python | def logpdf(self, X):
"""
Log PDF for Inverse Wishart prior
Parameters
----------
X : float
Covariance matrix for which the prior is being formed over
Returns
----------
- log(p(X))
"""
return invwishart.logpdf(X, df=self.v, sc... | [
"def",
"logpdf",
"(",
"self",
",",
"X",
")",
":",
"return",
"invwishart",
".",
"logpdf",
"(",
"X",
",",
"df",
"=",
"self",
".",
"v",
",",
"scale",
"=",
"self",
".",
"Psi",
")"
] | Log PDF for Inverse Wishart prior
Parameters
----------
X : float
Covariance matrix for which the prior is being formed over
Returns
----------
- log(p(X)) | [
"Log",
"PDF",
"for",
"Inverse",
"Wishart",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/inverse_wishart.py#L38-L51 |
222,511 | RJT1990/pyflux | pyflux/families/inverse_wishart.py | InverseWishart.pdf | def pdf(self, X):
"""
PDF for Inverse Wishart prior
Parameters
----------
x : float
Covariance matrix for which the prior is being formed over
Returns
----------
- p(x)
"""
return invwishart.pdf(X, df=self.v, sca... | python | def pdf(self, X):
"""
PDF for Inverse Wishart prior
Parameters
----------
x : float
Covariance matrix for which the prior is being formed over
Returns
----------
- p(x)
"""
return invwishart.pdf(X, df=self.v, sca... | [
"def",
"pdf",
"(",
"self",
",",
"X",
")",
":",
"return",
"invwishart",
".",
"pdf",
"(",
"X",
",",
"df",
"=",
"self",
".",
"v",
",",
"scale",
"=",
"self",
".",
"Psi",
")"
] | PDF for Inverse Wishart prior
Parameters
----------
x : float
Covariance matrix for which the prior is being formed over
Returns
----------
- p(x) | [
"PDF",
"for",
"Inverse",
"Wishart",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/inverse_wishart.py#L53-L66 |
222,512 | RJT1990/pyflux | pyflux/ssm/nllt.py | NLLT.neg_loglik | def neg_loglik(self, beta):
""" Creates negative loglikelihood of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood
"""
Z = np.... | python | def neg_loglik(self, beta):
""" Creates negative loglikelihood of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood
"""
Z = np.... | [
"def",
"neg_loglik",
"(",
"self",
",",
"beta",
")",
":",
"Z",
"=",
"np",
".",
"zeros",
"(",
"2",
")",
"Z",
"[",
"0",
"]",
"=",
"1",
"states",
"=",
"np",
".",
"zeros",
"(",
"[",
"self",
".",
"state_no",
",",
"self",
".",
"data",
".",
"shape",
... | Creates negative loglikelihood of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood | [
"Creates",
"negative",
"loglikelihood",
"of",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L117-L136 |
222,513 | RJT1990/pyflux | pyflux/ssm/nllt.py | NLLT.state_likelihood_markov_blanket | def state_likelihood_markov_blanket(self, beta, alpha, col_no):
""" Returns Markov blanket of the states given the variance latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
... | python | def state_likelihood_markov_blanket(self, beta, alpha, col_no):
""" Returns Markov blanket of the states given the variance latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
... | [
"def",
"state_likelihood_markov_blanket",
"(",
"self",
",",
"beta",
",",
"alpha",
",",
"col_no",
")",
":",
"_",
",",
"_",
",",
"_",
",",
"Q",
"=",
"self",
".",
"_ss_matrices",
"(",
"beta",
")",
"blanket",
"=",
"np",
".",
"append",
"(",
"0",
",",
"s... | Returns Markov blanket of the states given the variance latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
State matrix
Returns
----------
State likelihood | [
"Returns",
"Markov",
"blanket",
"of",
"the",
"states",
"given",
"the",
"variance",
"latent",
"variables"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L181-L199 |
222,514 | RJT1990/pyflux | pyflux/ssm/nllt.py | NLLT.markov_blanket | def markov_blanket(self, beta, alpha):
""" Creates total Markov blanket for states
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
A vector of states
Returns
----------
... | python | def markov_blanket(self, beta, alpha):
""" Creates total Markov blanket for states
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
A vector of states
Returns
----------
... | [
"def",
"markov_blanket",
"(",
"self",
",",
"beta",
",",
"alpha",
")",
":",
"likelihood_blanket",
"=",
"self",
".",
"likelihood_markov_blanket",
"(",
"beta",
")",
"state_blanket",
"=",
"self",
".",
"state_likelihood_markov_blanket",
"(",
"beta",
",",
"alpha",
","... | Creates total Markov blanket for states
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
A vector of states
Returns
----------
Markov blanket for states | [
"Creates",
"total",
"Markov",
"blanket",
"for",
"states"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L221-L241 |
222,515 | RJT1990/pyflux | pyflux/ssm/nllt.py | NLLT._general_approximating_model | def _general_approximating_model(self, beta, T, Z, R, Q, h_approx):
""" Creates simplest kind of approximating Gaussian model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
T, Z, R, Q : np.array
State sp... | python | def _general_approximating_model(self, beta, T, Z, R, Q, h_approx):
""" Creates simplest kind of approximating Gaussian model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
T, Z, R, Q : np.array
State sp... | [
"def",
"_general_approximating_model",
"(",
"self",
",",
"beta",
",",
"T",
",",
"Z",
",",
"R",
",",
"Q",
",",
"h_approx",
")",
":",
"H",
"=",
"np",
".",
"ones",
"(",
"self",
".",
"data_length",
")",
"*",
"h_approx",
"mu",
"=",
"np",
".",
"zeros",
... | Creates simplest kind of approximating Gaussian model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
T, Z, R, Q : np.array
State space matrices used in KFS algorithm
h_approx : float
Value t... | [
"Creates",
"simplest",
"kind",
"of",
"approximating",
"Gaussian",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L403-L430 |
222,516 | RJT1990/pyflux | pyflux/ssm/nllt.py | NLLT.fit | def fit(self, optimizer='RMSProp', iterations=1000, print_progress=True, start_diffuse=False, **kwargs):
""" Fits the model
Parameters
----------
optimizer : string
Stochastic optimizer: either RMSProp or ADAM.
iterations: int
How many iterations to run
... | python | def fit(self, optimizer='RMSProp', iterations=1000, print_progress=True, start_diffuse=False, **kwargs):
""" Fits the model
Parameters
----------
optimizer : string
Stochastic optimizer: either RMSProp or ADAM.
iterations: int
How many iterations to run
... | [
"def",
"fit",
"(",
"self",
",",
"optimizer",
"=",
"'RMSProp'",
",",
"iterations",
"=",
"1000",
",",
"print_progress",
"=",
"True",
",",
"start_diffuse",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_bbvi_fit",
"(",
"optimizer"... | Fits the model
Parameters
----------
optimizer : string
Stochastic optimizer: either RMSProp or ADAM.
iterations: int
How many iterations to run
print_progress : bool
Whether tp print the ELBO progress or not
start_diffuse :... | [
"Fits",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllt.py#L432-L455 |
222,517 | RJT1990/pyflux | pyflux/var/var.py | create_design_matrix_2 | def create_design_matrix_2(Z, data, Y_len, lag_no):
"""
For Python 2.7 - cythonized version only works for 3.5
"""
row_count = 1
for lag in range(1, lag_no+1):
for reg in range(Y_len):
Z[row_count, :] = data[reg][(lag_no-lag):-lag]
row_count += 1
return Z | python | def create_design_matrix_2(Z, data, Y_len, lag_no):
"""
For Python 2.7 - cythonized version only works for 3.5
"""
row_count = 1
for lag in range(1, lag_no+1):
for reg in range(Y_len):
Z[row_count, :] = data[reg][(lag_no-lag):-lag]
row_count += 1
return Z | [
"def",
"create_design_matrix_2",
"(",
"Z",
",",
"data",
",",
"Y_len",
",",
"lag_no",
")",
":",
"row_count",
"=",
"1",
"for",
"lag",
"in",
"range",
"(",
"1",
",",
"lag_no",
"+",
"1",
")",
":",
"for",
"reg",
"in",
"range",
"(",
"Y_len",
")",
":",
"... | For Python 2.7 - cythonized version only works for 3.5 | [
"For",
"Python",
"2",
".",
"7",
"-",
"cythonized",
"version",
"only",
"works",
"for",
"3",
".",
"5"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L18-L29 |
222,518 | RJT1990/pyflux | pyflux/var/var.py | VAR._create_B | def _create_B(self,Y):
""" Creates OLS coefficient matrix
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The coefficient matrix B
"""
Z = self._create_Z(Y)
return np.dot(np.dot(Y,np.t... | python | def _create_B(self,Y):
""" Creates OLS coefficient matrix
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The coefficient matrix B
"""
Z = self._create_Z(Y)
return np.dot(np.dot(Y,np.t... | [
"def",
"_create_B",
"(",
"self",
",",
"Y",
")",
":",
"Z",
"=",
"self",
".",
"_create_Z",
"(",
"Y",
")",
"return",
"np",
".",
"dot",
"(",
"np",
".",
"dot",
"(",
"Y",
",",
"np",
".",
"transpose",
"(",
"Z",
")",
")",
",",
"np",
".",
"linalg",
... | Creates OLS coefficient matrix
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The coefficient matrix B | [
"Creates",
"OLS",
"coefficient",
"matrix"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L97-L111 |
222,519 | RJT1990/pyflux | pyflux/var/var.py | VAR._create_Z | def _create_Z(self,Y):
""" Creates design matrix holding the lagged variables
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The design matrix Z
"""
Z = np.ones(((self.ylen*self.lags +1),Y[0].shape[0]... | python | def _create_Z(self,Y):
""" Creates design matrix holding the lagged variables
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The design matrix Z
"""
Z = np.ones(((self.ylen*self.lags +1),Y[0].shape[0]... | [
"def",
"_create_Z",
"(",
"self",
",",
"Y",
")",
":",
"Z",
"=",
"np",
".",
"ones",
"(",
"(",
"(",
"self",
".",
"ylen",
"*",
"self",
".",
"lags",
"+",
"1",
")",
",",
"Y",
"[",
"0",
"]",
".",
"shape",
"[",
"0",
"]",
")",
")",
"return",
"self... | Creates design matrix holding the lagged variables
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The design matrix Z | [
"Creates",
"design",
"matrix",
"holding",
"the",
"lagged",
"variables"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L163-L177 |
222,520 | RJT1990/pyflux | pyflux/var/var.py | VAR._forecast_mean | def _forecast_mean(self,h,t_params,Y,shock_type=None,shock_index=0,shock_value=None,shock_dir='positive',irf_intervals=False):
""" Function allows for mean prediction; also allows shock specification for simulations or impulse response effects
Parameters
----------
h : int
H... | python | def _forecast_mean(self,h,t_params,Y,shock_type=None,shock_index=0,shock_value=None,shock_dir='positive',irf_intervals=False):
""" Function allows for mean prediction; also allows shock specification for simulations or impulse response effects
Parameters
----------
h : int
H... | [
"def",
"_forecast_mean",
"(",
"self",
",",
"h",
",",
"t_params",
",",
"Y",
",",
"shock_type",
"=",
"None",
",",
"shock_index",
"=",
"0",
",",
"shock_value",
"=",
"None",
",",
"shock_dir",
"=",
"'positive'",
",",
"irf_intervals",
"=",
"False",
")",
":",
... | Function allows for mean prediction; also allows shock specification for simulations or impulse response effects
Parameters
----------
h : int
How many steps ahead to forecast
t_params : np.array
Transformed latent variables vector
Y : np.array
... | [
"Function",
"allows",
"for",
"mean",
"prediction",
";",
"also",
"allows",
"shock",
"specification",
"for",
"simulations",
"or",
"impulse",
"response",
"effects"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L179-L237 |
222,521 | RJT1990/pyflux | pyflux/var/var.py | VAR._shock_create | def _shock_create(self, h, shock_type, shock_index, shock_value, shock_dir, irf_intervals):
""" Function creates shocks based on desired specification
Parameters
----------
h : int
How many steps ahead to forecast
shock_type : None or str
Type of shock; ... | python | def _shock_create(self, h, shock_type, shock_index, shock_value, shock_dir, irf_intervals):
""" Function creates shocks based on desired specification
Parameters
----------
h : int
How many steps ahead to forecast
shock_type : None or str
Type of shock; ... | [
"def",
"_shock_create",
"(",
"self",
",",
"h",
",",
"shock_type",
",",
"shock_index",
",",
"shock_value",
",",
"shock_dir",
",",
"irf_intervals",
")",
":",
"if",
"shock_type",
"is",
"None",
":",
"random",
"=",
"[",
"np",
".",
"zeros",
"(",
"self",
".",
... | Function creates shocks based on desired specification
Parameters
----------
h : int
How many steps ahead to forecast
shock_type : None or str
Type of shock; options include None, 'Cov' (simulate from covariance matrix), 'IRF' (impulse response shock)
s... | [
"Function",
"creates",
"shocks",
"based",
"on",
"desired",
"specification"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L269-L336 |
222,522 | RJT1990/pyflux | pyflux/var/var.py | VAR.estimator_cov | def estimator_cov(self,method):
""" Creates covariance matrix for the estimators
Parameters
----------
method : str
Estimation method
Returns
----------
A Covariance Matrix
"""
Y = np.array([reg[self.lags:] for reg i... | python | def estimator_cov(self,method):
""" Creates covariance matrix for the estimators
Parameters
----------
method : str
Estimation method
Returns
----------
A Covariance Matrix
"""
Y = np.array([reg[self.lags:] for reg i... | [
"def",
"estimator_cov",
"(",
"self",
",",
"method",
")",
":",
"Y",
"=",
"np",
".",
"array",
"(",
"[",
"reg",
"[",
"self",
".",
"lags",
":",
"]",
"for",
"reg",
"in",
"self",
".",
"data",
"]",
")",
"Z",
"=",
"self",
".",
"_create_Z",
"(",
"Y",
... | Creates covariance matrix for the estimators
Parameters
----------
method : str
Estimation method
Returns
----------
A Covariance Matrix | [
"Creates",
"covariance",
"matrix",
"for",
"the",
"estimators"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L388-L407 |
222,523 | RJT1990/pyflux | pyflux/var/var.py | VAR.ols_covariance | def ols_covariance(self):
""" Creates OLS estimate of the covariance matrix
Returns
----------
The OLS estimate of the covariance matrix
"""
Y = np.array([reg[self.lags:reg.shape[0]] for reg in self.data])
return (1.0/(Y[0].shape[0]))*np.dot(sel... | python | def ols_covariance(self):
""" Creates OLS estimate of the covariance matrix
Returns
----------
The OLS estimate of the covariance matrix
"""
Y = np.array([reg[self.lags:reg.shape[0]] for reg in self.data])
return (1.0/(Y[0].shape[0]))*np.dot(sel... | [
"def",
"ols_covariance",
"(",
"self",
")",
":",
"Y",
"=",
"np",
".",
"array",
"(",
"[",
"reg",
"[",
"self",
".",
"lags",
":",
"reg",
".",
"shape",
"[",
"0",
"]",
"]",
"for",
"reg",
"in",
"self",
".",
"data",
"]",
")",
"return",
"(",
"1.0",
"/... | Creates OLS estimate of the covariance matrix
Returns
----------
The OLS estimate of the covariance matrix | [
"Creates",
"OLS",
"estimate",
"of",
"the",
"covariance",
"matrix"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L435-L444 |
222,524 | RJT1990/pyflux | pyflux/var/var.py | VAR.residuals | def residuals(self,Y):
""" Creates the model residuals
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The model residuals
"""
return (Y-np.dot(self._create_B(Y),self._create_Z(Y))) | python | def residuals(self,Y):
""" Creates the model residuals
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The model residuals
"""
return (Y-np.dot(self._create_B(Y),self._create_Z(Y))) | [
"def",
"residuals",
"(",
"self",
",",
"Y",
")",
":",
"return",
"(",
"Y",
"-",
"np",
".",
"dot",
"(",
"self",
".",
"_create_B",
"(",
"Y",
")",
",",
"self",
".",
"_create_Z",
"(",
"Y",
")",
")",
")"
] | Creates the model residuals
Parameters
----------
Y : np.array
The dependent variables Y
Returns
----------
The model residuals | [
"Creates",
"the",
"model",
"residuals"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L648-L661 |
222,525 | RJT1990/pyflux | pyflux/var/var.py | VAR.construct_wishart | def construct_wishart(self,v,X):
"""
Constructs a Wishart prior for the covariance matrix
"""
self.adjust_prior(list(range(int((len(self.latent_variables.z_list)-self.ylen-(self.ylen**2-self.ylen)/2)),
int(len(self.latent_variables.z_list)))), fam.InverseWishart(v,X)) | python | def construct_wishart(self,v,X):
"""
Constructs a Wishart prior for the covariance matrix
"""
self.adjust_prior(list(range(int((len(self.latent_variables.z_list)-self.ylen-(self.ylen**2-self.ylen)/2)),
int(len(self.latent_variables.z_list)))), fam.InverseWishart(v,X)) | [
"def",
"construct_wishart",
"(",
"self",
",",
"v",
",",
"X",
")",
":",
"self",
".",
"adjust_prior",
"(",
"list",
"(",
"range",
"(",
"int",
"(",
"(",
"len",
"(",
"self",
".",
"latent_variables",
".",
"z_list",
")",
"-",
"self",
".",
"ylen",
"-",
"("... | Constructs a Wishart prior for the covariance matrix | [
"Constructs",
"a",
"Wishart",
"prior",
"for",
"the",
"covariance",
"matrix"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/var/var.py#L663-L668 |
222,526 | RJT1990/pyflux | pyflux/ssm/llm.py | LLEV.simulation_smoother | def simulation_smoother(self,beta):
""" Koopman's simulation smoother - simulates from states given
model latent variables and observations
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
---... | python | def simulation_smoother(self,beta):
""" Koopman's simulation smoother - simulates from states given
model latent variables and observations
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
---... | [
"def",
"simulation_smoother",
"(",
"self",
",",
"beta",
")",
":",
"T",
",",
"Z",
",",
"R",
",",
"Q",
",",
"H",
"=",
"self",
".",
"_ss_matrices",
"(",
"beta",
")",
"# Generate e_t+ and n_t+",
"rnd_h",
"=",
"np",
".",
"random",
".",
"normal",
"(",
"0",... | Koopman's simulation smoother - simulates from states given
model latent variables and observations
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- A simulated state evolution | [
"Koopman",
"s",
"simulation",
"smoother",
"-",
"simulates",
"from",
"states",
"given",
"model",
"latent",
"variables",
"and",
"observations"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/llm.py#L496-L536 |
222,527 | RJT1990/pyflux | pyflux/ssm/llm.py | LLEV.smoothed_state | def smoothed_state(self,data,beta):
""" Creates the negative log marginal likelihood of the model
Parameters
----------
data : np.array
Data to be smoothed
beta : np.array
Contains untransformed starting values for latent variables
Returns
... | python | def smoothed_state(self,data,beta):
""" Creates the negative log marginal likelihood of the model
Parameters
----------
data : np.array
Data to be smoothed
beta : np.array
Contains untransformed starting values for latent variables
Returns
... | [
"def",
"smoothed_state",
"(",
"self",
",",
"data",
",",
"beta",
")",
":",
"T",
",",
"Z",
",",
"R",
",",
"Q",
",",
"H",
"=",
"self",
".",
"_ss_matrices",
"(",
"beta",
")",
"alpha",
",",
"V",
"=",
"univariate_KFS",
"(",
"data",
",",
"Z",
",",
"H"... | Creates the negative log marginal likelihood of the model
Parameters
----------
data : np.array
Data to be smoothed
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Smoothed states | [
"Creates",
"the",
"negative",
"log",
"marginal",
"likelihood",
"of",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/llm.py#L538-L557 |
222,528 | RJT1990/pyflux | pyflux/tsm.py | TSM._laplace_fit | def _laplace_fit(self,obj_type):
""" Performs a Laplace approximation to the posterior
Parameters
----------
obj_type : method
Whether a likelihood or a posterior
Returns
----------
None (plots posterior)
"""
# Get Mode and Inverse H... | python | def _laplace_fit(self,obj_type):
""" Performs a Laplace approximation to the posterior
Parameters
----------
obj_type : method
Whether a likelihood or a posterior
Returns
----------
None (plots posterior)
"""
# Get Mode and Inverse H... | [
"def",
"_laplace_fit",
"(",
"self",
",",
"obj_type",
")",
":",
"# Get Mode and Inverse Hessian information",
"y",
"=",
"self",
".",
"fit",
"(",
"method",
"=",
"'PML'",
",",
"printer",
"=",
"False",
")",
"if",
"y",
".",
"ihessian",
"is",
"None",
":",
"raise... | Performs a Laplace approximation to the posterior
Parameters
----------
obj_type : method
Whether a likelihood or a posterior
Returns
----------
None (plots posterior) | [
"Performs",
"a",
"Laplace",
"approximation",
"to",
"the",
"posterior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L187-L221 |
222,529 | RJT1990/pyflux | pyflux/tsm.py | TSM._optimize_fit | def _optimize_fit(self, obj_type=None, **kwargs):
"""
This function fits models using Maximum Likelihood or Penalized Maximum Likelihood
"""
preopt_search = kwargs.get('preopt_search', True) # If user supplied
if obj_type == self.neg_loglik:
method = 'MLE'
e... | python | def _optimize_fit(self, obj_type=None, **kwargs):
"""
This function fits models using Maximum Likelihood or Penalized Maximum Likelihood
"""
preopt_search = kwargs.get('preopt_search', True) # If user supplied
if obj_type == self.neg_loglik:
method = 'MLE'
e... | [
"def",
"_optimize_fit",
"(",
"self",
",",
"obj_type",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"preopt_search",
"=",
"kwargs",
".",
"get",
"(",
"'preopt_search'",
",",
"True",
")",
"# If user supplied",
"if",
"obj_type",
"==",
"self",
".",
"neg_logl... | This function fits models using Maximum Likelihood or Penalized Maximum Likelihood | [
"This",
"function",
"fits",
"models",
"using",
"Maximum",
"Likelihood",
"or",
"Penalized",
"Maximum",
"Likelihood"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L347-L406 |
222,530 | RJT1990/pyflux | pyflux/tsm.py | TSM.multivariate_neg_logposterior | def multivariate_neg_logposterior(self,beta):
""" Returns negative log posterior, for a model with a covariance matrix
Parameters
----------
beta : np.array
Contains untransformed starting values for latent_variables
Returns
----------
Negative log ... | python | def multivariate_neg_logposterior(self,beta):
""" Returns negative log posterior, for a model with a covariance matrix
Parameters
----------
beta : np.array
Contains untransformed starting values for latent_variables
Returns
----------
Negative log ... | [
"def",
"multivariate_neg_logposterior",
"(",
"self",
",",
"beta",
")",
":",
"post",
"=",
"self",
".",
"neg_loglik",
"(",
"beta",
")",
"for",
"k",
"in",
"range",
"(",
"0",
",",
"self",
".",
"z_no",
")",
":",
"if",
"self",
".",
"latent_variables",
".",
... | Returns negative log posterior, for a model with a covariance matrix
Parameters
----------
beta : np.array
Contains untransformed starting values for latent_variables
Returns
----------
Negative log posterior | [
"Returns",
"negative",
"log",
"posterior",
"for",
"a",
"model",
"with",
"a",
"covariance",
"matrix"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L496-L516 |
222,531 | RJT1990/pyflux | pyflux/tsm.py | TSM.shift_dates | def shift_dates(self,h):
""" Auxiliary function for creating dates for forecasts
Parameters
----------
h : int
How many steps to forecast
Returns
----------
A transformed date_index object
"""
date_index = copy.deepcopy(self.index)
... | python | def shift_dates(self,h):
""" Auxiliary function for creating dates for forecasts
Parameters
----------
h : int
How many steps to forecast
Returns
----------
A transformed date_index object
"""
date_index = copy.deepcopy(self.index)
... | [
"def",
"shift_dates",
"(",
"self",
",",
"h",
")",
":",
"date_index",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"index",
")",
"date_index",
"=",
"date_index",
"[",
"self",
".",
"max_lag",
":",
"len",
"(",
"date_index",
")",
"]",
"if",
"self",
".... | Auxiliary function for creating dates for forecasts
Parameters
----------
h : int
How many steps to forecast
Returns
----------
A transformed date_index object | [
"Auxiliary",
"function",
"for",
"creating",
"dates",
"for",
"forecasts"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L518-L559 |
222,532 | RJT1990/pyflux | pyflux/tsm.py | TSM.plot_z | def plot_z(self, indices=None,figsize=(15,5),**kwargs):
""" Plots latent variables by calling latent parameters object
Returns
----------
Pretty plot
"""
self.latent_variables.plot_z(indices=indices,figsize=figsize,**kwargs) | python | def plot_z(self, indices=None,figsize=(15,5),**kwargs):
""" Plots latent variables by calling latent parameters object
Returns
----------
Pretty plot
"""
self.latent_variables.plot_z(indices=indices,figsize=figsize,**kwargs) | [
"def",
"plot_z",
"(",
"self",
",",
"indices",
"=",
"None",
",",
"figsize",
"=",
"(",
"15",
",",
"5",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"latent_variables",
".",
"plot_z",
"(",
"indices",
"=",
"indices",
",",
"figsize",
"=",
"figsi... | Plots latent variables by calling latent parameters object
Returns
----------
Pretty plot | [
"Plots",
"latent",
"variables",
"by",
"calling",
"latent",
"parameters",
"object"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L579-L586 |
222,533 | RJT1990/pyflux | pyflux/ssm/ndynlin.py | NDynReg.evo_blanket | def evo_blanket(self, beta, alpha):
""" Creates Markov blanket for the variance latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
A vector of states
Returns
... | python | def evo_blanket(self, beta, alpha):
""" Creates Markov blanket for the variance latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
A vector of states
Returns
... | [
"def",
"evo_blanket",
"(",
"self",
",",
"beta",
",",
"alpha",
")",
":",
"# Markov blanket for each state",
"evo_blanket",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"state_no",
")",
"for",
"i",
"in",
"range",
"(",
"evo_blanket",
".",
"shape",
"[",
"0",
"... | Creates Markov blanket for the variance latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
alpha : np.array
A vector of states
Returns
----------
Markov blanket for variance... | [
"Creates",
"Markov",
"blanket",
"for",
"the",
"variance",
"latent",
"variables"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/ndynlin.py#L233-L258 |
222,534 | RJT1990/pyflux | pyflux/ssm/ndynlin.py | NDynReg.log_p_blanket | def log_p_blanket(self, beta):
""" Creates complete Markov blanket for latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
Markov blanket for latent variables
"... | python | def log_p_blanket(self, beta):
""" Creates complete Markov blanket for latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
Markov blanket for latent variables
"... | [
"def",
"log_p_blanket",
"(",
"self",
",",
"beta",
")",
":",
"states",
"=",
"np",
".",
"zeros",
"(",
"[",
"self",
".",
"state_no",
",",
"self",
".",
"data",
".",
"shape",
"[",
"0",
"]",
"]",
")",
"for",
"state_i",
"in",
"range",
"(",
"self",
".",
... | Creates complete Markov blanket for latent variables
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
Markov blanket for latent variables | [
"Creates",
"complete",
"Markov",
"blanket",
"for",
"latent",
"variables"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/ndynlin.py#L260-L276 |
222,535 | RJT1990/pyflux | pyflux/families/exponential.py | Exponential.logpdf | def logpdf(self, mu):
"""
Log PDF for Exponential prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
m... | python | def logpdf(self, mu):
"""
Log PDF for Exponential prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
m... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"expon",
".",
"logpdf",
"(",
"mu",
",",
"self",
".",
"lmd0",
... | Log PDF for Exponential prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Exponential",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/exponential.py#L177-L192 |
222,536 | RJT1990/pyflux | pyflux/families/exponential.py | Exponential.markov_blanket | def markov_blanket(y, mean, scale, shape, skewness):
""" Markov blanket for the Exponential distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Exponential distribution
... | python | def markov_blanket(y, mean, scale, shape, skewness):
""" Markov blanket for the Exponential distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Exponential distribution
... | [
"def",
"markov_blanket",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"ss",
".",
"expon",
".",
"logpdf",
"(",
"x",
"=",
"y",
",",
"scale",
"=",
"1",
"/",
"mean",
")"
] | Markov blanket for the Exponential distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Exponential distribution
scale : float
scale parameter for the Exponential dis... | [
"Markov",
"blanket",
"for",
"the",
"Exponential",
"distribution"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/exponential.py#L195-L219 |
222,537 | RJT1990/pyflux | pyflux/families/exponential.py | Exponential.pdf | def pdf(self, mu):
"""
PDF for Exponential prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.tra... | python | def pdf(self, mu):
"""
PDF for Exponential prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.tra... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"expon",
".",
"pdf",
"(",
"mu",
",",
"self",
".",
"lmd0",
")"
] | PDF for Exponential prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Exponential",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/exponential.py#L277-L292 |
222,538 | RJT1990/pyflux | pyflux/inference/bbvi.py | BBVI.change_parameters | def change_parameters(self,params):
"""
Utility function for changing the approximate distribution parameters
"""
no_of_params = 0
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
self.q[core_param].vi_chang... | python | def change_parameters(self,params):
"""
Utility function for changing the approximate distribution parameters
"""
no_of_params = 0
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
self.q[core_param].vi_chang... | [
"def",
"change_parameters",
"(",
"self",
",",
"params",
")",
":",
"no_of_params",
"=",
"0",
"for",
"core_param",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"q",
")",
")",
":",
"for",
"approx_param",
"in",
"range",
"(",
"self",
".",
"q",
"[",
"core_... | Utility function for changing the approximate distribution parameters | [
"Utility",
"function",
"for",
"changing",
"the",
"approximate",
"distribution",
"parameters"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L54-L62 |
222,539 | RJT1990/pyflux | pyflux/inference/bbvi.py | BBVI.current_parameters | def current_parameters(self):
"""
Obtains an array with the current parameters
"""
current = []
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
current.append(self.q[core_param].vi_return_param(approx_param... | python | def current_parameters(self):
"""
Obtains an array with the current parameters
"""
current = []
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
current.append(self.q[core_param].vi_return_param(approx_param... | [
"def",
"current_parameters",
"(",
"self",
")",
":",
"current",
"=",
"[",
"]",
"for",
"core_param",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"q",
")",
")",
":",
"for",
"approx_param",
"in",
"range",
"(",
"self",
".",
"q",
"[",
"core_param",
"]",
... | Obtains an array with the current parameters | [
"Obtains",
"an",
"array",
"with",
"the",
"current",
"parameters"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L71-L79 |
222,540 | RJT1990/pyflux | pyflux/inference/bbvi.py | BBVI.cv_gradient | def cv_gradient(self,z):
"""
The control variate augmented Monte Carlo gradient estimate
"""
gradient = np.zeros(np.sum(self.approx_param_no))
z_t = z.T
log_q = self.normal_log_q(z.T)
log_p = self.log_p(z.T)
grad_log_q = self.grad_log_q(z)
gr... | python | def cv_gradient(self,z):
"""
The control variate augmented Monte Carlo gradient estimate
"""
gradient = np.zeros(np.sum(self.approx_param_no))
z_t = z.T
log_q = self.normal_log_q(z.T)
log_p = self.log_p(z.T)
grad_log_q = self.grad_log_q(z)
gr... | [
"def",
"cv_gradient",
"(",
"self",
",",
"z",
")",
":",
"gradient",
"=",
"np",
".",
"zeros",
"(",
"np",
".",
"sum",
"(",
"self",
".",
"approx_param_no",
")",
")",
"z_t",
"=",
"z",
".",
"T",
"log_q",
"=",
"self",
".",
"normal_log_q",
"(",
"z",
".",... | The control variate augmented Monte Carlo gradient estimate | [
"The",
"control",
"variate",
"augmented",
"Monte",
"Carlo",
"gradient",
"estimate"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L81-L96 |
222,541 | RJT1990/pyflux | pyflux/inference/bbvi.py | BBVI.draw_variables | def draw_variables(self):
"""
Draw parameters from the approximating distributions
"""
z = self.q[0].draw_variable_local(self.sims)
for i in range(1,len(self.q)):
z = np.vstack((z,self.q[i].draw_variable_local(self.sims)))
return z | python | def draw_variables(self):
"""
Draw parameters from the approximating distributions
"""
z = self.q[0].draw_variable_local(self.sims)
for i in range(1,len(self.q)):
z = np.vstack((z,self.q[i].draw_variable_local(self.sims)))
return z | [
"def",
"draw_variables",
"(",
"self",
")",
":",
"z",
"=",
"self",
".",
"q",
"[",
"0",
"]",
".",
"draw_variable_local",
"(",
"self",
".",
"sims",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"self",
".",
"q",
")",
")",
":",
"z",
... | Draw parameters from the approximating distributions | [
"Draw",
"parameters",
"from",
"the",
"approximating",
"distributions"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L129-L136 |
222,542 | RJT1990/pyflux | pyflux/inference/bbvi.py | BBVI.grad_log_q | def grad_log_q(self,z):
"""
The gradients of the approximating distributions
"""
param_count = 0
grad = np.zeros((np.sum(self.approx_param_no),self.sims))
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
... | python | def grad_log_q(self,z):
"""
The gradients of the approximating distributions
"""
param_count = 0
grad = np.zeros((np.sum(self.approx_param_no),self.sims))
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
... | [
"def",
"grad_log_q",
"(",
"self",
",",
"z",
")",
":",
"param_count",
"=",
"0",
"grad",
"=",
"np",
".",
"zeros",
"(",
"(",
"np",
".",
"sum",
"(",
"self",
".",
"approx_param_no",
")",
",",
"self",
".",
"sims",
")",
")",
"for",
"core_param",
"in",
"... | The gradients of the approximating distributions | [
"The",
"gradients",
"of",
"the",
"approximating",
"distributions"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L155-L165 |
222,543 | RJT1990/pyflux | pyflux/inference/bbvi.py | BBVIM.print_progress | def print_progress(self, i, current_params):
"""
Prints the current ELBO at every decile of total iterations
"""
for split in range(1,11):
if i == (round(self.iterations/10*split)-1):
post = -self.full_neg_posterior(current_params)
approx = sel... | python | def print_progress(self, i, current_params):
"""
Prints the current ELBO at every decile of total iterations
"""
for split in range(1,11):
if i == (round(self.iterations/10*split)-1):
post = -self.full_neg_posterior(current_params)
approx = sel... | [
"def",
"print_progress",
"(",
"self",
",",
"i",
",",
"current_params",
")",
":",
"for",
"split",
"in",
"range",
"(",
"1",
",",
"11",
")",
":",
"if",
"i",
"==",
"(",
"round",
"(",
"self",
".",
"iterations",
"/",
"10",
"*",
"split",
")",
"-",
"1",
... | Prints the current ELBO at every decile of total iterations | [
"Prints",
"the",
"current",
"ELBO",
"at",
"every",
"decile",
"of",
"total",
"iterations"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L441-L451 |
222,544 | RJT1990/pyflux | pyflux/inference/bbvi.py | BBVIM.run | def run(self):
"""
The core BBVI routine - draws Monte Carlo gradients and uses a stochastic optimizer.
"""
# Initialization assumptions
z = self.draw_normal_initial()
gradient = self.cv_gradient_initial(z)
gradient[np.isnan(gradient)] = 0
variance = np.p... | python | def run(self):
"""
The core BBVI routine - draws Monte Carlo gradients and uses a stochastic optimizer.
"""
# Initialization assumptions
z = self.draw_normal_initial()
gradient = self.cv_gradient_initial(z)
gradient[np.isnan(gradient)] = 0
variance = np.p... | [
"def",
"run",
"(",
"self",
")",
":",
"# Initialization assumptions",
"z",
"=",
"self",
".",
"draw_normal_initial",
"(",
")",
"gradient",
"=",
"self",
".",
"cv_gradient_initial",
"(",
"z",
")",
"gradient",
"[",
"np",
".",
"isnan",
"(",
"gradient",
")",
"]",... | The core BBVI routine - draws Monte Carlo gradients and uses a stochastic optimizer. | [
"The",
"core",
"BBVI",
"routine",
"-",
"draws",
"Monte",
"Carlo",
"gradients",
"and",
"uses",
"a",
"stochastic",
"optimizer",
"."
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L453-L502 |
222,545 | RJT1990/pyflux | pyflux/garch/segarchm.py | logpdf | def logpdf(x, shape, loc=0.0, scale=1.0, skewness=1.0):
"""
Log PDF for the Skew-t distribution
Parameters
----------
x : np.array
random variables
shape : float
The degrees of freedom for the skew-t distribution
loc : np.array
The location parameter for the skew-t... | python | def logpdf(x, shape, loc=0.0, scale=1.0, skewness=1.0):
"""
Log PDF for the Skew-t distribution
Parameters
----------
x : np.array
random variables
shape : float
The degrees of freedom for the skew-t distribution
loc : np.array
The location parameter for the skew-t... | [
"def",
"logpdf",
"(",
"x",
",",
"shape",
",",
"loc",
"=",
"0.0",
",",
"scale",
"=",
"1.0",
",",
"skewness",
"=",
"1.0",
")",
":",
"m1",
"=",
"(",
"np",
".",
"sqrt",
"(",
"shape",
")",
"*",
"sp",
".",
"gamma",
"(",
"(",
"shape",
"-",
"1.0",
... | Log PDF for the Skew-t distribution
Parameters
----------
x : np.array
random variables
shape : float
The degrees of freedom for the skew-t distribution
loc : np.array
The location parameter for the skew-t distribution
scale : float
The scale of the distributi... | [
"Log",
"PDF",
"for",
"the",
"Skew",
"-",
"t",
"distribution"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/garch/segarchm.py#L17-L44 |
222,546 | RJT1990/pyflux | pyflux/families/poisson.py | Poisson.approximating_model_reg | def approximating_model_reg(self, beta, T, Z, R, Q, h_approx, data, X, state_no):
""" Creates approximating Gaussian model for Poisson measurement density
- dynamic regression model
Parameters
----------
beta : np.array
Contains untransformed starting values for late... | python | def approximating_model_reg(self, beta, T, Z, R, Q, h_approx, data, X, state_no):
""" Creates approximating Gaussian model for Poisson measurement density
- dynamic regression model
Parameters
----------
beta : np.array
Contains untransformed starting values for late... | [
"def",
"approximating_model_reg",
"(",
"self",
",",
"beta",
",",
"T",
",",
"Z",
",",
"R",
",",
"Q",
",",
"h_approx",
",",
"data",
",",
"X",
",",
"state_no",
")",
":",
"H",
"=",
"np",
".",
"ones",
"(",
"data",
".",
"shape",
"[",
"0",
"]",
")",
... | Creates approximating Gaussian model for Poisson measurement density
- dynamic regression model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
T, Z, R, Q : np.array
State space matrices used in KFS algor... | [
"Creates",
"approximating",
"Gaussian",
"model",
"for",
"Poisson",
"measurement",
"density",
"-",
"dynamic",
"regression",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L86-L131 |
222,547 | RJT1990/pyflux | pyflux/families/poisson.py | Poisson.logpdf | def logpdf(self, mu):
"""
Log PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | python | def logpdf(self, mu):
"""
Log PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"poisson",
".",
"logpmf",
"(",
"mu",
",",
"self",
".",
"lmd0",
... | Log PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Poisson",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L198-L213 |
222,548 | RJT1990/pyflux | pyflux/families/poisson.py | Poisson.setup | def setup():
""" Returns the attributes of this family
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a skewness parameter (gamma)
... | python | def setup():
""" Returns the attributes of this family
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a skewness parameter (gamma)
... | [
"def",
"setup",
"(",
")",
":",
"name",
"=",
"\"Poisson\"",
"link",
"=",
"np",
".",
"exp",
"scale",
"=",
"False",
"shape",
"=",
"False",
"skewness",
"=",
"False",
"mean_transform",
"=",
"np",
".",
"log",
"cythonized",
"=",
"True",
"return",
"name",
",",... | Returns the attributes of this family
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a skewness parameter (gamma)
- mean_transform is a fu... | [
"Returns",
"the",
"attributes",
"of",
"this",
"family"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L243-L265 |
222,549 | RJT1990/pyflux | pyflux/families/poisson.py | Poisson.pdf | def pdf(self, mu):
"""
PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfo... | python | def pdf(self, mu):
"""
PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfo... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"poisson",
".",
"pmf",
"(",
"mu",
",",
"self",
".",
"lmd0",
")"
... | PDF for Poisson prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Poisson",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L294-L309 |
222,550 | RJT1990/pyflux | pyflux/families/poisson.py | Poisson.reg_score_function | def reg_score_function(X, y, mean, scale, shape, skewness):
""" GAS Poisson Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the tim... | python | def reg_score_function(X, y, mean, scale, shape, skewness):
""" GAS Poisson Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the tim... | [
"def",
"reg_score_function",
"(",
"X",
",",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"X",
"*",
"(",
"y",
"-",
"mean",
")"
] | GAS Poisson Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the time series
mean : float
location parameter for the Po... | [
"GAS",
"Poisson",
"Regression",
"Update",
"term",
"using",
"gradient",
"only",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L312-L339 |
222,551 | RJT1990/pyflux | pyflux/families/poisson.py | Poisson.second_order_score | def second_order_score(y, mean, scale, shape, skewness):
""" GAS Poisson Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the... | python | def second_order_score(y, mean, scale, shape, skewness):
""" GAS Poisson Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the... | [
"def",
"second_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"y",
"-",
"mean",
")",
"/",
"float",
"(",
"mean",
")"
] | GAS Poisson Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Poisson distribution
scale : float
scale parame... | [
"GAS",
"Poisson",
"Update",
"term",
"potentially",
"using",
"second",
"-",
"order",
"information",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/poisson.py#L342-L366 |
222,552 | RJT1990/pyflux | pyflux/families/inverse_gamma.py | InverseGamma.logpdf | def logpdf(self, x):
"""
Log PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(x))
"""
if self.transform is not None:
x ... | python | def logpdf(self, x):
"""
Log PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(x))
"""
if self.transform is not None:
x ... | [
"def",
"logpdf",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"x",
"=",
"self",
".",
"transform",
"(",
"x",
")",
"return",
"(",
"-",
"self",
".",
"alpha",
"-",
"1",
")",
"*",
"np",
".",
"log",
"("... | Log PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(x)) | [
"Log",
"PDF",
"for",
"Inverse",
"Gamma",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/inverse_gamma.py#L33-L48 |
222,553 | RJT1990/pyflux | pyflux/families/inverse_gamma.py | InverseGamma.pdf | def pdf(self, x):
"""
PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- p(x)
"""
if self.transform is not None:
x = self.trans... | python | def pdf(self, x):
"""
PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- p(x)
"""
if self.transform is not None:
x = self.trans... | [
"def",
"pdf",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"x",
"=",
"self",
".",
"transform",
"(",
"x",
")",
"return",
"(",
"x",
"**",
"(",
"-",
"self",
".",
"alpha",
"-",
"1",
")",
")",
"*",
"... | PDF for Inverse Gamma prior
Parameters
----------
x : float
Latent variable for which the prior is being formed over
Returns
----------
- p(x) | [
"PDF",
"for",
"Inverse",
"Gamma",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/inverse_gamma.py#L50-L65 |
222,554 | RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.logpdf | def logpdf(self, mu):
"""
Log PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = s... | python | def logpdf(self, mu):
"""
Log PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = s... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"cauchy",
".",
"logpdf",
"(",
"mu",
",",
"self",
".",
"loc0",
... | Log PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Cauchy",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L155-L170 |
222,555 | RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.pdf | def pdf(self, mu):
"""
PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
return ss.cauchy.pdf(mu, self.loc0, self.scale0) | python | def pdf(self, mu):
"""
PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
return ss.cauchy.pdf(mu, self.loc0, self.scale0) | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"return",
"ss",
".",
"cauchy",
".",
"pdf",
"(",
"mu",
",",
"self",
".",
"loc0",
",",
"self",
".",
"scale0",
")"
] | PDF for Cauchy prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Cauchy",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L172-L185 |
222,556 | RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.markov_blanket | def markov_blanket(y, mean, scale, shape, skewness):
""" Markov blanket for each likelihood term - used for state space models
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distr... | python | def markov_blanket(y, mean, scale, shape, skewness):
""" Markov blanket for each likelihood term - used for state space models
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distr... | [
"def",
"markov_blanket",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"ss",
".",
"cauchy",
".",
"logpdf",
"(",
"y",
",",
"loc",
"=",
"mean",
",",
"scale",
"=",
"scale",
")"
] | Markov blanket for each likelihood term - used for state space models
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distribution
scale : float
scale parameter for th... | [
"Markov",
"blanket",
"for",
"each",
"likelihood",
"term",
"-",
"used",
"for",
"state",
"space",
"models"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L188-L212 |
222,557 | RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.setup | def setup():
""" Returns the attributes of this family if using in a probabilistic model
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a ... | python | def setup():
""" Returns the attributes of this family if using in a probabilistic model
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a ... | [
"def",
"setup",
"(",
")",
":",
"name",
"=",
"\"Cauchy\"",
"link",
"=",
"np",
".",
"array",
"scale",
"=",
"True",
"shape",
"=",
"False",
"skewness",
"=",
"False",
"mean_transform",
"=",
"np",
".",
"array",
"cythonized",
"=",
"True",
"# used for GAS models",... | Returns the attributes of this family if using in a probabilistic model
Notes
----------
- scale notes whether family has a variance parameter (sigma)
- shape notes whether family has a tail thickness parameter (nu)
- skewness notes whether family has a skewness parameter (gamma... | [
"Returns",
"the",
"attributes",
"of",
"this",
"family",
"if",
"using",
"in",
"a",
"probabilistic",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L215-L237 |
222,558 | RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.neg_loglikelihood | def neg_loglikelihood(y, mean, scale, shape, skewness):
""" Negative loglikelihood function for this distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distribution
... | python | def neg_loglikelihood(y, mean, scale, shape, skewness):
""" Negative loglikelihood function for this distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distribution
... | [
"def",
"neg_loglikelihood",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"-",
"np",
".",
"sum",
"(",
"ss",
".",
"cauchy",
".",
"logpdf",
"(",
"y",
",",
"loc",
"=",
"mean",
",",
"scale",
"=",
"scale",
")"... | Negative loglikelihood function for this distribution
Parameters
----------
y : np.ndarray
univariate time series
mean : np.ndarray
array of location parameters for the Cauchy distribution
scale : float
scale parameter for the Cauchy distrib... | [
"Negative",
"loglikelihood",
"function",
"for",
"this",
"distribution"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L294-L318 |
222,559 | RJT1990/pyflux | pyflux/families/cauchy.py | Cauchy.reg_score_function | def reg_score_function(X, y, mean, scale, shape, skewness):
""" GAS Cauchy Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the time... | python | def reg_score_function(X, y, mean, scale, shape, skewness):
""" GAS Cauchy Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the time... | [
"def",
"reg_score_function",
"(",
"X",
",",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"2.0",
"*",
"(",
"(",
"y",
"-",
"mean",
")",
"*",
"X",
")",
"/",
"(",
"np",
".",
"power",
"(",
"scale",
",",
"2",
"... | GAS Cauchy Regression Update term using gradient only - native Python function
Parameters
----------
X : float
datapoint for the right hand side variable
y : float
datapoint for the time series
mean : float
location parameter for the Cau... | [
"GAS",
"Cauchy",
"Regression",
"Update",
"term",
"using",
"gradient",
"only",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L322-L349 |
222,560 | RJT1990/pyflux | pyflux/arma/nnarx.py | NNARX.general_neg_loglik | def general_neg_loglik(self, beta):
""" Calculates the negative log-likelihood of the model
Parameters
----------
beta : np.ndarray
Contains untransformed starting values for latent variables
Returns
----------
The negative logliklihood of the model
... | python | def general_neg_loglik(self, beta):
""" Calculates the negative log-likelihood of the model
Parameters
----------
beta : np.ndarray
Contains untransformed starting values for latent variables
Returns
----------
The negative logliklihood of the model
... | [
"def",
"general_neg_loglik",
"(",
"self",
",",
"beta",
")",
":",
"mu",
",",
"Y",
"=",
"self",
".",
"_model",
"(",
"beta",
")",
"parm",
"=",
"np",
".",
"array",
"(",
"[",
"self",
".",
"latent_variables",
".",
"z_list",
"[",
"k",
"]",
".",
"prior",
... | Calculates the negative log-likelihood of the model
Parameters
----------
beta : np.ndarray
Contains untransformed starting values for latent variables
Returns
----------
The negative logliklihood of the model | [
"Calculates",
"the",
"negative",
"log",
"-",
"likelihood",
"of",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/nnarx.py#L430-L447 |
222,561 | RJT1990/pyflux | pyflux/arma/nnarx.py | NNARX.plot_fit | def plot_fit(self, **kwargs):
"""
Plots the fit of the model against the data
"""
import matplotlib.pyplot as plt
import seaborn as sns
figsize = kwargs.get('figsize',(10,7))
plt.figure(figsize=figsize)
date_index = self.index[self.ar:self.data.shape[0]... | python | def plot_fit(self, **kwargs):
"""
Plots the fit of the model against the data
"""
import matplotlib.pyplot as plt
import seaborn as sns
figsize = kwargs.get('figsize',(10,7))
plt.figure(figsize=figsize)
date_index = self.index[self.ar:self.data.shape[0]... | [
"def",
"plot_fit",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"seaborn",
"as",
"sns",
"figsize",
"=",
"kwargs",
".",
"get",
"(",
"'figsize'",
",",
"(",
"10",
",",
"7",
")",
")",
"pl... | Plots the fit of the model against the data | [
"Plots",
"the",
"fit",
"of",
"the",
"model",
"against",
"the",
"data"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/nnarx.py#L487-L503 |
222,562 | RJT1990/pyflux | pyflux/arma/nnarx.py | NNARX.predict_is | def predict_is(self, h=5, fit_once=True, fit_method='MLE', intervals=False, **kwargs):
""" Makes dynamic out-of-sample predictions with the estimated model on in-sample data
Parameters
----------
h : int (default : 5)
How many steps would you like to forecast?
fit_o... | python | def predict_is(self, h=5, fit_once=True, fit_method='MLE', intervals=False, **kwargs):
""" Makes dynamic out-of-sample predictions with the estimated model on in-sample data
Parameters
----------
h : int (default : 5)
How many steps would you like to forecast?
fit_o... | [
"def",
"predict_is",
"(",
"self",
",",
"h",
"=",
"5",
",",
"fit_once",
"=",
"True",
",",
"fit_method",
"=",
"'MLE'",
",",
"intervals",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"predictions",
"=",
"[",
"]",
"for",
"t",
"in",
"range",
"(",
... | Makes dynamic out-of-sample predictions with the estimated model on in-sample data
Parameters
----------
h : int (default : 5)
How many steps would you like to forecast?
fit_once : boolean
(default: True) Fits only once before the in-sample prediction; if False,... | [
"Makes",
"dynamic",
"out",
"-",
"of",
"-",
"sample",
"predictions",
"with",
"the",
"estimated",
"model",
"on",
"in",
"-",
"sample",
"data"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/nnarx.py#L557-L603 |
222,563 | RJT1990/pyflux | pyflux/ssm/nllm.py | NLLEV.likelihood_markov_blanket | def likelihood_markov_blanket(self, beta):
""" Creates likelihood markov blanket of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood
""" ... | python | def likelihood_markov_blanket(self, beta):
""" Creates likelihood markov blanket of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood
""" ... | [
"def",
"likelihood_markov_blanket",
"(",
"self",
",",
"beta",
")",
":",
"states",
"=",
"beta",
"[",
"self",
".",
"z_no",
":",
"self",
".",
"z_no",
"+",
"self",
".",
"data_length",
"]",
"# the local level (untransformed)",
"parm",
"=",
"np",
".",
"array",
"... | Creates likelihood markov blanket of the model
Parameters
----------
beta : np.array
Contains untransformed starting values for latent variables
Returns
----------
- Negative loglikelihood | [
"Creates",
"likelihood",
"markov",
"blanket",
"of",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllm.py#L135-L150 |
222,564 | RJT1990/pyflux | pyflux/ssm/nllm.py | NLLEV._animate_bbvi | def _animate_bbvi(self,stored_latent_variables,stored_predictive_likelihood):
""" Produces animated plot of BBVI optimization
Returns
----------
None (changes model attributes)
"""
from matplotlib.animation import FuncAnimation, writers
import matplotlib.pyplot ... | python | def _animate_bbvi(self,stored_latent_variables,stored_predictive_likelihood):
""" Produces animated plot of BBVI optimization
Returns
----------
None (changes model attributes)
"""
from matplotlib.animation import FuncAnimation, writers
import matplotlib.pyplot ... | [
"def",
"_animate_bbvi",
"(",
"self",
",",
"stored_latent_variables",
",",
"stored_predictive_likelihood",
")",
":",
"from",
"matplotlib",
".",
"animation",
"import",
"FuncAnimation",
",",
"writers",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"seab... | Produces animated plot of BBVI optimization
Returns
----------
None (changes model attributes) | [
"Produces",
"animated",
"plot",
"of",
"BBVI",
"optimization"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllm.py#L278-L298 |
222,565 | RJT1990/pyflux | pyflux/ssm/nllm.py | NLLEV.initialize_approx_dist | def initialize_approx_dist(self, phi, start_diffuse, gaussian_latents):
""" Initializes the appoximate distibution for the model
Parameters
----------
phi : np.ndarray
Latent variables
start_diffuse: boolean
Whether to start from diffuse values or not
... | python | def initialize_approx_dist(self, phi, start_diffuse, gaussian_latents):
""" Initializes the appoximate distibution for the model
Parameters
----------
phi : np.ndarray
Latent variables
start_diffuse: boolean
Whether to start from diffuse values or not
... | [
"def",
"initialize_approx_dist",
"(",
"self",
",",
"phi",
",",
"start_diffuse",
",",
"gaussian_latents",
")",
":",
"# Starting values for approximate distribution",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"latent_variables",
".",
"z_list",
")",
")... | Initializes the appoximate distibution for the model
Parameters
----------
phi : np.ndarray
Latent variables
start_diffuse: boolean
Whether to start from diffuse values or not
gaussian_latents: LatentVariables object
Latent variables... | [
"Initializes",
"the",
"appoximate",
"distibution",
"for",
"the",
"model"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllm.py#L442-L482 |
222,566 | RJT1990/pyflux | pyflux/families/t.py | t.logpdf | def logpdf(self, mu):
"""
Log PDF for t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = self.t... | python | def logpdf(self, mu):
"""
Log PDF for t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = self.t... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"t",
".",
"logpdf",
"(",
"mu",
",",
"df",
"=",
"self",
".",
... | Log PDF for t prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"t",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/t.py#L186-L201 |
222,567 | RJT1990/pyflux | pyflux/families/t.py | t.second_order_score | def second_order_score(y, mean, scale, shape, skewness):
""" GAS t Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the t dis... | python | def second_order_score(y, mean, scale, shape, skewness):
""" GAS t Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the t dis... | [
"def",
"second_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"(",
"shape",
"+",
"1",
")",
"/",
"shape",
")",
"*",
"(",
"y",
"-",
"mean",
")",
"/",
"(",
"np",
".",
"power",
"(",
"scale... | GAS t Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the t distribution
scale : float
scale parameter for the ... | [
"GAS",
"t",
"Update",
"term",
"potentially",
"using",
"second",
"-",
"order",
"information",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/t.py#L330-L354 |
222,568 | RJT1990/pyflux | tools/cythonize.py | load_hashes | def load_hashes(filename):
"""Load the hashes dict from the hashfile"""
# { filename : (sha1 of header if available or 'NA',
# sha1 of input,
# sha1 of output) }
hashes = {}
try:
with open(filename, 'r') as cython_hash_file:
for hash_record in cyt... | python | def load_hashes(filename):
"""Load the hashes dict from the hashfile"""
# { filename : (sha1 of header if available or 'NA',
# sha1 of input,
# sha1 of output) }
hashes = {}
try:
with open(filename, 'r') as cython_hash_file:
for hash_record in cyt... | [
"def",
"load_hashes",
"(",
"filename",
")",
":",
"# { filename : (sha1 of header if available or 'NA',",
"# sha1 of input,",
"# sha1 of output) }",
"hashes",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"... | Load the hashes dict from the hashfile | [
"Load",
"the",
"hashes",
"dict",
"from",
"the",
"hashfile"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/tools/cythonize.py#L81-L96 |
222,569 | RJT1990/pyflux | tools/cythonize.py | save_hashes | def save_hashes(hashes, filename):
"""Save the hashes dict to the hashfile"""
with open(filename, 'w') as cython_hash_file:
for key, value in hashes.items():
cython_hash_file.write("%s %s %s %s\n"
% (key, value[0], value[1], value[2])) | python | def save_hashes(hashes, filename):
"""Save the hashes dict to the hashfile"""
with open(filename, 'w') as cython_hash_file:
for key, value in hashes.items():
cython_hash_file.write("%s %s %s %s\n"
% (key, value[0], value[1], value[2])) | [
"def",
"save_hashes",
"(",
"hashes",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"cython_hash_file",
":",
"for",
"key",
",",
"value",
"in",
"hashes",
".",
"items",
"(",
")",
":",
"cython_hash_file",
".",
"write",
... | Save the hashes dict to the hashfile | [
"Save",
"the",
"hashes",
"dict",
"to",
"the",
"hashfile"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/tools/cythonize.py#L99-L104 |
222,570 | RJT1990/pyflux | tools/cythonize.py | clean_path | def clean_path(path):
"""Clean the path"""
path = path.replace(os.sep, '/')
if path.startswith('./'):
path = path[2:]
return path | python | def clean_path(path):
"""Clean the path"""
path = path.replace(os.sep, '/')
if path.startswith('./'):
path = path[2:]
return path | [
"def",
"clean_path",
"(",
"path",
")",
":",
"path",
"=",
"path",
".",
"replace",
"(",
"os",
".",
"sep",
",",
"'/'",
")",
"if",
"path",
".",
"startswith",
"(",
"'./'",
")",
":",
"path",
"=",
"path",
"[",
"2",
":",
"]",
"return",
"path"
] | Clean the path | [
"Clean",
"the",
"path"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/tools/cythonize.py#L114-L119 |
222,571 | RJT1990/pyflux | tools/cythonize.py | get_hash_tuple | def get_hash_tuple(header_path, cython_path, gen_file_path):
"""Get the hashes from the given files"""
header_hash = (sha1_of_file(header_path)
if os.path.exists(header_path) else 'NA')
from_hash = sha1_of_file(cython_path)
to_hash = (sha1_of_file(gen_file_path)
if os.... | python | def get_hash_tuple(header_path, cython_path, gen_file_path):
"""Get the hashes from the given files"""
header_hash = (sha1_of_file(header_path)
if os.path.exists(header_path) else 'NA')
from_hash = sha1_of_file(cython_path)
to_hash = (sha1_of_file(gen_file_path)
if os.... | [
"def",
"get_hash_tuple",
"(",
"header_path",
",",
"cython_path",
",",
"gen_file_path",
")",
":",
"header_hash",
"=",
"(",
"sha1_of_file",
"(",
"header_path",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"header_path",
")",
"else",
"'NA'",
")",
"from_has... | Get the hashes from the given files | [
"Get",
"the",
"hashes",
"from",
"the",
"given",
"files"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/tools/cythonize.py#L122-L131 |
222,572 | RJT1990/pyflux | pyflux/families/truncated_normal.py | TruncatedNormal.logpdf | def logpdf(self, mu):
"""
Log PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
... | python | def logpdf(self, mu):
"""
Log PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"if",
"mu",
"<",
"self",
".",
"lower",
"and",
"self",
".",
"lower",
"is",
"not",
"... | Log PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Truncated",
"Normal",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/truncated_normal.py#L42-L62 |
222,573 | RJT1990/pyflux | pyflux/families/truncated_normal.py | TruncatedNormal.pdf | def pdf(self, mu):
"""
PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = sel... | python | def pdf(self, mu):
"""
PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = sel... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"if",
"mu",
"<",
"self",
".",
"lower",
"and",
"self",
".",
"lower",
"is",
"not",
"Non... | PDF for Truncated Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Truncated",
"Normal",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/truncated_normal.py#L64-L84 |
222,574 | RJT1990/pyflux | pyflux/inference/metropolis_hastings.py | MetropolisHastings.tune_scale | def tune_scale(acceptance, scale):
""" Tunes scale for M-H algorithm
Parameters
----------
acceptance : float
The most recent acceptance rate
scale : float
The current scale parameter
Returns
----------
scale : float
... | python | def tune_scale(acceptance, scale):
""" Tunes scale for M-H algorithm
Parameters
----------
acceptance : float
The most recent acceptance rate
scale : float
The current scale parameter
Returns
----------
scale : float
... | [
"def",
"tune_scale",
"(",
"acceptance",
",",
"scale",
")",
":",
"if",
"acceptance",
">",
"0.8",
":",
"scale",
"*=",
"2.0",
"elif",
"acceptance",
"<=",
"0.8",
"and",
"acceptance",
">",
"0.4",
":",
"scale",
"*=",
"1.3",
"elif",
"acceptance",
"<",
"0.234",
... | Tunes scale for M-H algorithm
Parameters
----------
acceptance : float
The most recent acceptance rate
scale : float
The current scale parameter
Returns
----------
scale : float
An adjusted scale parameter
Notes
... | [
"Tunes",
"scale",
"for",
"M",
"-",
"H",
"algorithm"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/metropolis_hastings.py#L66-L100 |
222,575 | RJT1990/pyflux | pyflux/families/normal.py | Normal.draw_variable_local | def draw_variable_local(self, size):
""" Simulate from the Normal distribution using instance values
Parameters
----------
size : int
How many simulations to perform
Returns
----------
np.ndarray of Normal random variable
"""
return ... | python | def draw_variable_local(self, size):
""" Simulate from the Normal distribution using instance values
Parameters
----------
size : int
How many simulations to perform
Returns
----------
np.ndarray of Normal random variable
"""
return ... | [
"def",
"draw_variable_local",
"(",
"self",
",",
"size",
")",
":",
"return",
"ss",
".",
"norm",
".",
"rvs",
"(",
"loc",
"=",
"self",
".",
"mu0",
",",
"scale",
"=",
"self",
".",
"sigma0",
",",
"size",
"=",
"size",
")"
] | Simulate from the Normal distribution using instance values
Parameters
----------
size : int
How many simulations to perform
Returns
----------
np.ndarray of Normal random variable | [
"Simulate",
"from",
"the",
"Normal",
"distribution",
"using",
"instance",
"values"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L154-L166 |
222,576 | RJT1990/pyflux | pyflux/families/normal.py | Normal.first_order_score | def first_order_score(y, mean, scale, shape, skewness):
""" GAS Normal Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Normal distribution
... | python | def first_order_score(y, mean, scale, shape, skewness):
""" GAS Normal Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Normal distribution
... | [
"def",
"first_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"y",
"-",
"mean",
")",
"/",
"np",
".",
"power",
"(",
"scale",
",",
"2",
")"
] | GAS Normal Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Normal distribution
scale : float
scale parameter for the Normal distri... | [
"GAS",
"Normal",
"Update",
"term",
"using",
"gradient",
"only",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L169-L193 |
222,577 | RJT1990/pyflux | pyflux/families/normal.py | Normal.logpdf | def logpdf(self, mu):
"""
Log PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = s... | python | def logpdf(self, mu):
"""
Log PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = s... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"-",
"np",
".",
"log",
"(",
"float",
"(",
"self",
".",
"sigma0",
")",
")... | Log PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Normal",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L195-L210 |
222,578 | RJT1990/pyflux | pyflux/families/normal.py | Normal.pdf | def pdf(self, mu):
"""
PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfor... | python | def pdf(self, mu):
"""
PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfor... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"(",
"1.0",
"/",
"float",
"(",
"self",
".",
"sigma0",
")",
")",
"*",
"np",
... | PDF for Normal prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Normal",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L291-L306 |
222,579 | RJT1990/pyflux | pyflux/families/normal.py | Normal.vi_change_param | def vi_change_param(self, index, value):
""" Wrapper function for changing latent variables - variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
value : float
What to change the latent variable to
""... | python | def vi_change_param(self, index, value):
""" Wrapper function for changing latent variables - variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
value : float
What to change the latent variable to
""... | [
"def",
"vi_change_param",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"if",
"index",
"==",
"0",
":",
"self",
".",
"mu0",
"=",
"value",
"elif",
"index",
"==",
"1",
":",
"self",
".",
"sigma0",
"=",
"np",
".",
"exp",
"(",
"value",
")"
] | Wrapper function for changing latent variables - variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
value : float
What to change the latent variable to | [
"Wrapper",
"function",
"for",
"changing",
"latent",
"variables",
"-",
"variational",
"inference"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L365-L379 |
222,580 | RJT1990/pyflux | pyflux/families/normal.py | Normal.vi_return_param | def vi_return_param(self, index):
""" Wrapper function for selecting appropriate latent variable for variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
Returns
----------
The appropriate indexed paramete... | python | def vi_return_param(self, index):
""" Wrapper function for selecting appropriate latent variable for variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
Returns
----------
The appropriate indexed paramete... | [
"def",
"vi_return_param",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"==",
"0",
":",
"return",
"self",
".",
"mu0",
"elif",
"index",
"==",
"1",
":",
"return",
"np",
".",
"log",
"(",
"self",
".",
"sigma0",
")"
] | Wrapper function for selecting appropriate latent variable for variational inference
Parameters
----------
index : int
0 or 1 depending on which latent variable
Returns
----------
The appropriate indexed parameter | [
"Wrapper",
"function",
"for",
"selecting",
"appropriate",
"latent",
"variable",
"for",
"variational",
"inference"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L381-L396 |
222,581 | RJT1990/pyflux | pyflux/families/normal.py | Normal.vi_score | def vi_score(self, x, index):
""" Wrapper function for selecting appropriate score
Parameters
----------
x : float
A random variable
index : int
0 or 1 depending on which latent variable
Returns
----------
The gradient of the sca... | python | def vi_score(self, x, index):
""" Wrapper function for selecting appropriate score
Parameters
----------
x : float
A random variable
index : int
0 or 1 depending on which latent variable
Returns
----------
The gradient of the sca... | [
"def",
"vi_score",
"(",
"self",
",",
"x",
",",
"index",
")",
":",
"if",
"index",
"==",
"0",
":",
"return",
"self",
".",
"vi_loc_score",
"(",
"x",
")",
"elif",
"index",
"==",
"1",
":",
"return",
"self",
".",
"vi_scale_score",
"(",
"x",
")"
] | Wrapper function for selecting appropriate score
Parameters
----------
x : float
A random variable
index : int
0 or 1 depending on which latent variable
Returns
----------
The gradient of the scale latent variable at x | [
"Wrapper",
"function",
"for",
"selecting",
"appropriate",
"score"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L426-L444 |
222,582 | RJT1990/pyflux | pyflux/families/laplace.py | Laplace.first_order_score | def first_order_score(y, mean, scale, shape, skewness):
""" GAS Laplace Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Laplace distribution
... | python | def first_order_score(y, mean, scale, shape, skewness):
""" GAS Laplace Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Laplace distribution
... | [
"def",
"first_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"y",
"-",
"mean",
")",
"/",
"float",
"(",
"scale",
"*",
"np",
".",
"abs",
"(",
"y",
"-",
"mean",
")",
")"
] | GAS Laplace Update term using gradient only - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Laplace distribution
scale : float
scale parameter for the Laplace dis... | [
"GAS",
"Laplace",
"Update",
"term",
"using",
"gradient",
"only",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L156-L180 |
222,583 | RJT1990/pyflux | pyflux/families/laplace.py | Laplace.logpdf | def logpdf(self, mu):
"""
Log PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | python | def logpdf(self, mu):
"""
Log PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"laplace",
".",
"logpdf",
"(",
"mu",
",",
"loc",
"=",
"self",
... | Log PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Laplace",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L182-L197 |
222,584 | RJT1990/pyflux | pyflux/families/laplace.py | Laplace.pdf | def pdf(self, mu):
"""
PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfo... | python | def pdf(self, mu):
"""
PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu)
"""
if self.transform is not None:
mu = self.transfo... | [
"def",
"pdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"laplace",
".",
"pdf",
"(",
"mu",
",",
"self",
".",
"loc0",
",",... | PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- p(mu) | [
"PDF",
"for",
"Laplace",
"prior"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L278-L293 |
222,585 | RJT1990/pyflux | pyflux/families/laplace.py | Laplace.second_order_score | def second_order_score(y, mean, scale, shape, skewness):
""" GAS Laplace Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the... | python | def second_order_score(y, mean, scale, shape, skewness):
""" GAS Laplace Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the... | [
"def",
"second_order_score",
"(",
"y",
",",
"mean",
",",
"scale",
",",
"shape",
",",
"skewness",
")",
":",
"return",
"(",
"(",
"y",
"-",
"mean",
")",
"/",
"float",
"(",
"scale",
"*",
"np",
".",
"abs",
"(",
"y",
"-",
"mean",
")",
")",
")",
"/",
... | GAS Laplace Update term potentially using second-order information - native Python function
Parameters
----------
y : float
datapoint for the time series
mean : float
location parameter for the Laplace distribution
scale : float
scale parame... | [
"GAS",
"Laplace",
"Update",
"term",
"potentially",
"using",
"second",
"-",
"order",
"information",
"-",
"native",
"Python",
"function"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L326-L350 |
222,586 | RJT1990/pyflux | pyflux/data_check.py | data_check | def data_check(data,target):
""" Checks data type
Parameters
----------
data : pd.DataFrame or np.array
Field to specify the time series data that will be used.
target : int or str
Target column
Returns
----------
transformed_data : np.array
Raw dat... | python | def data_check(data,target):
""" Checks data type
Parameters
----------
data : pd.DataFrame or np.array
Field to specify the time series data that will be used.
target : int or str
Target column
Returns
----------
transformed_data : np.array
Raw dat... | [
"def",
"data_check",
"(",
"data",
",",
"target",
")",
":",
"# Check pandas or numpy",
"if",
"isinstance",
"(",
"data",
",",
"pd",
".",
"DataFrame",
")",
"or",
"isinstance",
"(",
"data",
",",
"pd",
".",
"core",
".",
"frame",
".",
"DataFrame",
")",
":",
... | Checks data type
Parameters
----------
data : pd.DataFrame or np.array
Field to specify the time series data that will be used.
target : int or str
Target column
Returns
----------
transformed_data : np.array
Raw data array for use in the model
... | [
"Checks",
"data",
"type"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/data_check.py#L4-L57 |
222,587 | RJT1990/pyflux | pyflux/latent_variables.py | LatentVariables.add_z | def add_z(self, name, prior, q, index=True):
""" Adds latent variable
Parameters
----------
name : str
Name of the latent variable
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
q : Distribution object
Which distribu... | python | def add_z(self, name, prior, q, index=True):
""" Adds latent variable
Parameters
----------
name : str
Name of the latent variable
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
q : Distribution object
Which distribu... | [
"def",
"add_z",
"(",
"self",
",",
"name",
",",
"prior",
",",
"q",
",",
"index",
"=",
"True",
")",
":",
"self",
".",
"z_list",
".",
"append",
"(",
"LatentVariable",
"(",
"name",
",",
"len",
"(",
"self",
".",
"z_list",
")",
",",
"prior",
",",
"q",
... | Adds latent variable
Parameters
----------
name : str
Name of the latent variable
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
q : Distribution object
Which distribution to use for variational approximation
index ... | [
"Adds",
"latent",
"variable"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/latent_variables.py#L46-L70 |
222,588 | RJT1990/pyflux | pyflux/latent_variables.py | LatentVariables.create | def create(self, name, dim, prior, q):
""" Creates multiple latent variables
Parameters
----------
name : str
Name of the latent variable
dim : list
Dimension of the latent variable arrays
prior : Prior object
Which prior distributio... | python | def create(self, name, dim, prior, q):
""" Creates multiple latent variables
Parameters
----------
name : str
Name of the latent variable
dim : list
Dimension of the latent variable arrays
prior : Prior object
Which prior distributio... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"dim",
",",
"prior",
",",
"q",
")",
":",
"def",
"rec",
"(",
"dim",
",",
"prev",
"=",
"[",
"]",
")",
":",
"if",
"len",
"(",
"dim",
")",
">",
"0",
":",
"return",
"[",
"rec",
"(",
"dim",
"[",
"... | Creates multiple latent variables
Parameters
----------
name : str
Name of the latent variable
dim : list
Dimension of the latent variable arrays
prior : Prior object
Which prior distribution? E.g. Normal(0,1)
q : Distribution objec... | [
"Creates",
"multiple",
"latent",
"variables"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/latent_variables.py#L72-L113 |
222,589 | RJT1990/pyflux | pyflux/gpnarx/kernels.py | ARD.build_latent_variables | def build_latent_variables(self):
""" Builds latent variables for this kernel
Returns
----------
- A list of lists (each sub-list contains latent variable information)
"""
lvs_to_build = []
lvs_to_build.append(['Noise Sigma^2', fam.Flat(transform='exp'), fam.Norm... | python | def build_latent_variables(self):
""" Builds latent variables for this kernel
Returns
----------
- A list of lists (each sub-list contains latent variable information)
"""
lvs_to_build = []
lvs_to_build.append(['Noise Sigma^2', fam.Flat(transform='exp'), fam.Norm... | [
"def",
"build_latent_variables",
"(",
"self",
")",
":",
"lvs_to_build",
"=",
"[",
"]",
"lvs_to_build",
".",
"append",
"(",
"[",
"'Noise Sigma^2'",
",",
"fam",
".",
"Flat",
"(",
"transform",
"=",
"'exp'",
")",
",",
"fam",
".",
"Normal",
"(",
"0",
",",
"... | Builds latent variables for this kernel
Returns
----------
- A list of lists (each sub-list contains latent variable information) | [
"Builds",
"latent",
"variables",
"for",
"this",
"kernel"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gpnarx/kernels.py#L160-L172 |
222,590 | RJT1990/pyflux | pyflux/arma/nnar.py | NNAR._ar_matrix | def _ar_matrix(self):
""" Creates Autoregressive matrix
Returns
----------
X : np.ndarray
Autoregressive Matrix
"""
Y = np.array(self.data[self.max_lag:self.data.shape[0]])
X = self.data[(self.max_lag-1):-1]
if self.ar != 0:
for ... | python | def _ar_matrix(self):
""" Creates Autoregressive matrix
Returns
----------
X : np.ndarray
Autoregressive Matrix
"""
Y = np.array(self.data[self.max_lag:self.data.shape[0]])
X = self.data[(self.max_lag-1):-1]
if self.ar != 0:
for ... | [
"def",
"_ar_matrix",
"(",
"self",
")",
":",
"Y",
"=",
"np",
".",
"array",
"(",
"self",
".",
"data",
"[",
"self",
".",
"max_lag",
":",
"self",
".",
"data",
".",
"shape",
"[",
"0",
"]",
"]",
")",
"X",
"=",
"self",
".",
"data",
"[",
"(",
"self",... | Creates Autoregressive matrix
Returns
----------
X : np.ndarray
Autoregressive Matrix | [
"Creates",
"Autoregressive",
"matrix"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/nnar.py#L118-L134 |
222,591 | RJT1990/pyflux | pyflux/ensembles/mixture_of_experts.py | Aggregate.predict_is | def predict_is(self, h):
""" Outputs predictions for the Aggregate algorithm on the in-sample data
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of ensemble predictions
"""... | python | def predict_is(self, h):
""" Outputs predictions for the Aggregate algorithm on the in-sample data
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of ensemble predictions
"""... | [
"def",
"predict_is",
"(",
"self",
",",
"h",
")",
":",
"result",
"=",
"pd",
".",
"DataFrame",
"(",
"[",
"self",
".",
"run",
"(",
"h",
"=",
"h",
")",
"[",
"2",
"]",
"]",
")",
".",
"T",
"result",
".",
"index",
"=",
"self",
".",
"index",
"[",
"... | Outputs predictions for the Aggregate algorithm on the in-sample data
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of ensemble predictions | [
"Outputs",
"predictions",
"for",
"the",
"Aggregate",
"algorithm",
"on",
"the",
"in",
"-",
"sample",
"data"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ensembles/mixture_of_experts.py#L335-L349 |
222,592 | RJT1990/pyflux | pyflux/ensembles/mixture_of_experts.py | Aggregate.summary | def summary(self, h):
"""
Summarize the results for each model for h steps of the algorithm
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of losses for each model
... | python | def summary(self, h):
"""
Summarize the results for each model for h steps of the algorithm
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of losses for each model
... | [
"def",
"summary",
"(",
"self",
",",
"h",
")",
":",
"_",
",",
"losses",
",",
"_",
"=",
"self",
".",
"run",
"(",
"h",
"=",
"h",
")",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"losses",
")",
"df",
".",
"index",
"=",
"[",
"'Ensemble'",
"]",
"+",
... | Summarize the results for each model for h steps of the algorithm
Parameters
----------
h : int
How many steps to run the aggregating algorithm on
Returns
----------
- pd.DataFrame of losses for each model | [
"Summarize",
"the",
"results",
"for",
"each",
"model",
"for",
"h",
"steps",
"of",
"the",
"algorithm"
] | 297f2afc2095acd97c12e827dd500e8ea5da0c0f | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ensembles/mixture_of_experts.py#L351-L368 |
222,593 | vtkiorg/vtki | vtki/container.py | MultiBlock.extract_geometry | def extract_geometry(self):
"""Combines the geomertry of all blocks into a single ``PolyData``
object. Place this filter at the end of a pipeline before a polydata
consumer such as a polydata mapper to extract geometry from all blocks
and append them to one polydata object.
"""
... | python | def extract_geometry(self):
"""Combines the geomertry of all blocks into a single ``PolyData``
object. Place this filter at the end of a pipeline before a polydata
consumer such as a polydata mapper to extract geometry from all blocks
and append them to one polydata object.
"""
... | [
"def",
"extract_geometry",
"(",
"self",
")",
":",
"gf",
"=",
"vtk",
".",
"vtkCompositeDataGeometryFilter",
"(",
")",
"gf",
".",
"SetInputData",
"(",
"self",
")",
"gf",
".",
"Update",
"(",
")",
"return",
"wrap",
"(",
"gf",
".",
"GetOutputDataObject",
"(",
... | Combines the geomertry of all blocks into a single ``PolyData``
object. Place this filter at the end of a pipeline before a polydata
consumer such as a polydata mapper to extract geometry from all blocks
and append them to one polydata object. | [
"Combines",
"the",
"geomertry",
"of",
"all",
"blocks",
"into",
"a",
"single",
"PolyData",
"object",
".",
"Place",
"this",
"filter",
"at",
"the",
"end",
"of",
"a",
"pipeline",
"before",
"a",
"polydata",
"consumer",
"such",
"as",
"a",
"polydata",
"mapper",
"... | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L58-L67 |
222,594 | vtkiorg/vtki | vtki/container.py | MultiBlock.combine | def combine(self, merge_points=False):
"""Appends all blocks into a single unstructured grid.
Parameters
----------
merge_points : bool, optional
Merge coincidental points.
"""
alg = vtk.vtkAppendFilter()
for block in self:
alg.AddInputDa... | python | def combine(self, merge_points=False):
"""Appends all blocks into a single unstructured grid.
Parameters
----------
merge_points : bool, optional
Merge coincidental points.
"""
alg = vtk.vtkAppendFilter()
for block in self:
alg.AddInputDa... | [
"def",
"combine",
"(",
"self",
",",
"merge_points",
"=",
"False",
")",
":",
"alg",
"=",
"vtk",
".",
"vtkAppendFilter",
"(",
")",
"for",
"block",
"in",
"self",
":",
"alg",
".",
"AddInputData",
"(",
"block",
")",
"alg",
".",
"SetMergePoints",
"(",
"merge... | Appends all blocks into a single unstructured grid.
Parameters
----------
merge_points : bool, optional
Merge coincidental points. | [
"Appends",
"all",
"blocks",
"into",
"a",
"single",
"unstructured",
"grid",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L69-L83 |
222,595 | vtkiorg/vtki | vtki/container.py | MultiBlock.save | def save(self, filename, binary=True):
"""
Writes a ``MultiBlock`` dataset to disk.
Written file may be an ASCII or binary vtm file.
Parameters
----------
filename : str
Filename of mesh to be written. File type is inferred from
the extension of... | python | def save(self, filename, binary=True):
"""
Writes a ``MultiBlock`` dataset to disk.
Written file may be an ASCII or binary vtm file.
Parameters
----------
filename : str
Filename of mesh to be written. File type is inferred from
the extension of... | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"binary",
"=",
"True",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
")",
"ext",
"=",
"vtki",
".",
"get_ext",
"(",
... | Writes a ``MultiBlock`` dataset to disk.
Written file may be an ASCII or binary vtm file.
Parameters
----------
filename : str
Filename of mesh to be written. File type is inferred from
the extension of the filename unless overridden with
ftype. Ca... | [
"Writes",
"a",
"MultiBlock",
"dataset",
"to",
"disk",
"."
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L111-L146 |
222,596 | vtkiorg/vtki | vtki/container.py | MultiBlock.get_index_by_name | def get_index_by_name(self, name):
"""Find the index number by block name"""
for i in range(self.n_blocks):
if self.get_block_name(i) == name:
return i
raise KeyError('Block name ({}) not found'.format(name)) | python | def get_index_by_name(self, name):
"""Find the index number by block name"""
for i in range(self.n_blocks):
if self.get_block_name(i) == name:
return i
raise KeyError('Block name ({}) not found'.format(name)) | [
"def",
"get_index_by_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n_blocks",
")",
":",
"if",
"self",
".",
"get_block_name",
"(",
"i",
")",
"==",
"name",
":",
"return",
"i",
"raise",
"KeyError",
"(",
"'Block... | Find the index number by block name | [
"Find",
"the",
"index",
"number",
"by",
"block",
"name"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L211-L216 |
222,597 | vtkiorg/vtki | vtki/container.py | MultiBlock.append | def append(self, data):
"""Add a data set to the next block index"""
index = self.n_blocks # note off by one so use as index
self[index] = data
self.refs.append(data) | python | def append(self, data):
"""Add a data set to the next block index"""
index = self.n_blocks # note off by one so use as index
self[index] = data
self.refs.append(data) | [
"def",
"append",
"(",
"self",
",",
"data",
")",
":",
"index",
"=",
"self",
".",
"n_blocks",
"# note off by one so use as index",
"self",
"[",
"index",
"]",
"=",
"data",
"self",
".",
"refs",
".",
"append",
"(",
"data",
")"
] | Add a data set to the next block index | [
"Add",
"a",
"data",
"set",
"to",
"the",
"next",
"block",
"index"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L234-L238 |
222,598 | vtkiorg/vtki | vtki/container.py | MultiBlock.set_block_name | def set_block_name(self, index, name):
"""Set a block's string name at the specified index"""
if name is None:
return
self.GetMetaData(index).Set(vtk.vtkCompositeDataSet.NAME(), name)
self.Modified() | python | def set_block_name(self, index, name):
"""Set a block's string name at the specified index"""
if name is None:
return
self.GetMetaData(index).Set(vtk.vtkCompositeDataSet.NAME(), name)
self.Modified() | [
"def",
"set_block_name",
"(",
"self",
",",
"index",
",",
"name",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"self",
".",
"GetMetaData",
"(",
"index",
")",
".",
"Set",
"(",
"vtk",
".",
"vtkCompositeDataSet",
".",
"NAME",
"(",
")",
",",
"name... | Set a block's string name at the specified index | [
"Set",
"a",
"block",
"s",
"string",
"name",
"at",
"the",
"specified",
"index"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L247-L252 |
222,599 | vtkiorg/vtki | vtki/container.py | MultiBlock.get_block_name | def get_block_name(self, index):
"""Returns the string name of the block at the given index"""
meta = self.GetMetaData(index)
if meta is not None:
return meta.Get(vtk.vtkCompositeDataSet.NAME())
return None | python | def get_block_name(self, index):
"""Returns the string name of the block at the given index"""
meta = self.GetMetaData(index)
if meta is not None:
return meta.Get(vtk.vtkCompositeDataSet.NAME())
return None | [
"def",
"get_block_name",
"(",
"self",
",",
"index",
")",
":",
"meta",
"=",
"self",
".",
"GetMetaData",
"(",
"index",
")",
"if",
"meta",
"is",
"not",
"None",
":",
"return",
"meta",
".",
"Get",
"(",
"vtk",
".",
"vtkCompositeDataSet",
".",
"NAME",
"(",
... | Returns the string name of the block at the given index | [
"Returns",
"the",
"string",
"name",
"of",
"the",
"block",
"at",
"the",
"given",
"index"
] | 5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1 | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L255-L260 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.