partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
information
Returns the file exif
pyexifinfo/pyexifinfo.py
def information(filename): """Returns the file exif""" check_if_this_file_exist(filename) filename = os.path.abspath(filename) result = get_json(filename) result = result[0] return result
def information(filename): """Returns the file exif""" check_if_this_file_exist(filename) filename = os.path.abspath(filename) result = get_json(filename) result = result[0] return result
[ "Returns", "the", "file", "exif" ]
guinslym/pyexifinfo
python
https://github.com/guinslym/pyexifinfo/blob/56e5b44e77ee17b018a530ec858f19a9c6c07018/pyexifinfo/pyexifinfo.py#L64-L70
[ "def", "information", "(", "filename", ")", ":", "check_if_this_file_exist", "(", "filename", ")", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "result", "=", "get_json", "(", "filename", ")", "result", "=", "result", "[", "0",...
56e5b44e77ee17b018a530ec858f19a9c6c07018
train
get_json
Return a json value of the exif Get a filename and return a JSON object Arguments: filename {string} -- your filename Returns: [JSON] -- Return a JSON object
pyexifinfo/pyexifinfo.py
def get_json(filename): """ Return a json value of the exif Get a filename and return a JSON object Arguments: filename {string} -- your filename Returns: [JSON] -- Return a JSON object """ check_if_this_file_exist(filename) #Process this function filename = os.path.a...
def get_json(filename): """ Return a json value of the exif Get a filename and return a JSON object Arguments: filename {string} -- your filename Returns: [JSON] -- Return a JSON object """ check_if_this_file_exist(filename) #Process this function filename = os.path.a...
[ "Return", "a", "json", "value", "of", "the", "exif" ]
guinslym/pyexifinfo
python
https://github.com/guinslym/pyexifinfo/blob/56e5b44e77ee17b018a530ec858f19a9c6c07018/pyexifinfo/pyexifinfo.py#L100-L121
[ "def", "get_json", "(", "filename", ")", ":", "check_if_this_file_exist", "(", "filename", ")", "#Process this function", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "s", "=", "command_line", "(", "[", "'exiftool'", ",", "'-G'", ...
56e5b44e77ee17b018a530ec858f19a9c6c07018
train
get_csv
Return a csv representation of the exif get a filename and returns a unicode string with a CSV format Arguments: filename {string} -- your filename Returns: [unicode] -- unicode string
pyexifinfo/pyexifinfo.py
def get_csv(filename): """ Return a csv representation of the exif get a filename and returns a unicode string with a CSV format Arguments: filename {string} -- your filename Returns: [unicode] -- unicode string """ check_if_this_file_exist(filename) #Process this functio...
def get_csv(filename): """ Return a csv representation of the exif get a filename and returns a unicode string with a CSV format Arguments: filename {string} -- your filename Returns: [unicode] -- unicode string """ check_if_this_file_exist(filename) #Process this functio...
[ "Return", "a", "csv", "representation", "of", "the", "exif" ]
guinslym/pyexifinfo
python
https://github.com/guinslym/pyexifinfo/blob/56e5b44e77ee17b018a530ec858f19a9c6c07018/pyexifinfo/pyexifinfo.py#L123-L144
[ "def", "get_csv", "(", "filename", ")", ":", "check_if_this_file_exist", "(", "filename", ")", "#Process this function", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "s", "=", "command_line", "(", "[", "'exiftool'", ",", "'-G'", ...
56e5b44e77ee17b018a530ec858f19a9c6c07018
train
print_a_header
Header This function will output a message in a header Keyword Arguments: message {str} -- [the message string] (default: {"-"})
setup.py
def print_a_header(message="-"): """Header This function will output a message in a header Keyword Arguments: message {str} -- [the message string] (default: {"-"}) """ print("-".center(60,'-')) print(message.center(60,'-')) print("-".center(60,'-')) print()
def print_a_header(message="-"): """Header This function will output a message in a header Keyword Arguments: message {str} -- [the message string] (default: {"-"}) """ print("-".center(60,'-')) print(message.center(60,'-')) print("-".center(60,'-')) print()
[ "Header" ]
guinslym/pyexifinfo
python
https://github.com/guinslym/pyexifinfo/blob/56e5b44e77ee17b018a530ec858f19a9c6c07018/setup.py#L22-L33
[ "def", "print_a_header", "(", "message", "=", "\"-\"", ")", ":", "print", "(", "\"-\"", ".", "center", "(", "60", ",", "'-'", ")", ")", "print", "(", "message", ".", "center", "(", "60", ",", "'-'", ")", ")", "print", "(", "\"-\"", ".", "center", ...
56e5b44e77ee17b018a530ec858f19a9c6c07018
train
check_if_exiftool_is_already_installed
Requirements This function will check if Exiftool is installed on your system Return: True if Exiftool is Installed False if not
setup.py
def check_if_exiftool_is_already_installed(): """Requirements This function will check if Exiftool is installed on your system Return: True if Exiftool is Installed False if not """ result = 1; command = ["exiftool", "-ver"] with open(os.devnull, "w") as fnull: res...
def check_if_exiftool_is_already_installed(): """Requirements This function will check if Exiftool is installed on your system Return: True if Exiftool is Installed False if not """ result = 1; command = ["exiftool", "-ver"] with open(os.devnull, "w") as fnull: res...
[ "Requirements" ]
guinslym/pyexifinfo
python
https://github.com/guinslym/pyexifinfo/blob/56e5b44e77ee17b018a530ec858f19a9c6c07018/setup.py#L35-L59
[ "def", "check_if_exiftool_is_already_installed", "(", ")", ":", "result", "=", "1", "command", "=", "[", "\"exiftool\"", ",", "\"-ver\"", "]", "with", "open", "(", "os", ".", "devnull", ",", "\"w\"", ")", "as", "fnull", ":", "result", "=", "subprocess", "....
56e5b44e77ee17b018a530ec858f19a9c6c07018
train
EmailMessage.render
Render email with provided context Arguments --------- context : dict |context| If not specified then the :attr:`~mail_templated.EmailMessage.context` property is used. Keyword Arguments ----------------- clean : bool If `...
mail_templated/message.py
def render(self, context=None, clean=False): """ Render email with provided context Arguments --------- context : dict |context| If not specified then the :attr:`~mail_templated.EmailMessage.context` property is used. Keyword Argument...
def render(self, context=None, clean=False): """ Render email with provided context Arguments --------- context : dict |context| If not specified then the :attr:`~mail_templated.EmailMessage.context` property is used. Keyword Argument...
[ "Render", "email", "with", "provided", "context" ]
artemrizhov/django-mail-templated
python
https://github.com/artemrizhov/django-mail-templated/blob/1b428e7b6e02a5cf775bc83d6f5fd8c5f56d7932/mail_templated/message.py#L153-L205
[ "def", "render", "(", "self", ",", "context", "=", "None", ",", "clean", "=", "False", ")", ":", "# Load template if it is not loaded yet.", "if", "not", "self", ".", "template", ":", "self", ".", "load_template", "(", "self", ".", "template_name", ")", "# T...
1b428e7b6e02a5cf775bc83d6f5fd8c5f56d7932
train
EmailMessage.send
Send email message, render if it is not rendered yet. Note ---- Any extra arguments are passed to :class:`EmailMultiAlternatives.send() <django.core.mail.EmailMessage>`. Keyword Arguments ----------------- clean : bool If ``True``, remove any templat...
mail_templated/message.py
def send(self, *args, **kwargs): """ Send email message, render if it is not rendered yet. Note ---- Any extra arguments are passed to :class:`EmailMultiAlternatives.send() <django.core.mail.EmailMessage>`. Keyword Arguments ----------------- cle...
def send(self, *args, **kwargs): """ Send email message, render if it is not rendered yet. Note ---- Any extra arguments are passed to :class:`EmailMultiAlternatives.send() <django.core.mail.EmailMessage>`. Keyword Arguments ----------------- cle...
[ "Send", "email", "message", "render", "if", "it", "is", "not", "rendered", "yet", "." ]
artemrizhov/django-mail-templated
python
https://github.com/artemrizhov/django-mail-templated/blob/1b428e7b6e02a5cf775bc83d6f5fd8c5f56d7932/mail_templated/message.py#L207-L227
[ "def", "send", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "clean", "=", "kwargs", ".", "pop", "(", "'clean'", ",", "False", ")", "if", "not", "self", ".", "_is_rendered", ":", "self", ".", "render", "(", ")", "if", "clean",...
1b428e7b6e02a5cf775bc83d6f5fd8c5f56d7932
train
send_mail
Easy wrapper for sending a single email message to a recipient list using django template system. It works almost the same way as the standard :func:`send_mail()<django.core.mail.send_mail>` function. .. |main_difference| replace:: The main difference is that two first arguments ``subject`` an...
mail_templated/utils.py
def send_mail(template_name, context, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None, **kwargs): """ Easy wrapper for sending a single email message to a recipient list using django template system. It works almost the sa...
def send_mail(template_name, context, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None, **kwargs): """ Easy wrapper for sending a single email message to a recipient list using django template system. It works almost the sa...
[ "Easy", "wrapper", "for", "sending", "a", "single", "email", "message", "to", "a", "recipient", "list", "using", "django", "template", "system", "." ]
artemrizhov/django-mail-templated
python
https://github.com/artemrizhov/django-mail-templated/blob/1b428e7b6e02a5cf775bc83d6f5fd8c5f56d7932/mail_templated/utils.py#L13-L93
[ "def", "send_mail", "(", "template_name", ",", "context", ",", "from_email", ",", "recipient_list", ",", "fail_silently", "=", "False", ",", "auth_user", "=", "None", ",", "auth_password", "=", "None", ",", "connection", "=", "None", ",", "*", "*", "kwargs",...
1b428e7b6e02a5cf775bc83d6f5fd8c5f56d7932
train
silhouette_score
Compute the mean Silhouette Coefficient of all samples. The Silhouette Coefficient is calculated using the mean intra-cluster distance (``a``) and the mean nearest-cluster distance (``b``) for each sample. The Silhouette Coefficient for a sample is ``(b - a) / max(a, b)``. To clarify, ``b`` is the di...
bin/unsupervised.py
def silhouette_score(X, labels, metric='euclidean', sample_size=None, random_state=None, **kwds): """Compute the mean Silhouette Coefficient of all samples. The Silhouette Coefficient is calculated using the mean intra-cluster distance (``a``) and the mean nearest-cluster distance (``b...
def silhouette_score(X, labels, metric='euclidean', sample_size=None, random_state=None, **kwds): """Compute the mean Silhouette Coefficient of all samples. The Silhouette Coefficient is calculated using the mean intra-cluster distance (``a``) and the mean nearest-cluster distance (``b...
[ "Compute", "the", "mean", "Silhouette", "Coefficient", "of", "all", "samples", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/bin/unsupervised.py#L27-L106
[ "def", "silhouette_score", "(", "X", ",", "labels", ",", "metric", "=", "'euclidean'", ",", "sample_size", "=", "None", ",", "random_state", "=", "None", ",", "*", "*", "kwds", ")", ":", "if", "sample_size", "is", "not", "None", ":", "X", ",", "labels"...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
silhouette_samples
Compute the Silhouette Coefficient for each sample. The Silhouette Coefficient is a measure of how well samples are clustered with samples that are similar to themselves. Clustering models with a high Silhouette Coefficient are said to be dense, where samples in the same cluster are similar to each oth...
bin/unsupervised.py
def silhouette_samples(X, labels, metric='euclidean', **kwds): """Compute the Silhouette Coefficient for each sample. The Silhouette Coefficient is a measure of how well samples are clustered with samples that are similar to themselves. Clustering models with a high Silhouette Coefficient are said to b...
def silhouette_samples(X, labels, metric='euclidean', **kwds): """Compute the Silhouette Coefficient for each sample. The Silhouette Coefficient is a measure of how well samples are clustered with samples that are similar to themselves. Clustering models with a high Silhouette Coefficient are said to b...
[ "Compute", "the", "Silhouette", "Coefficient", "for", "each", "sample", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/bin/unsupervised.py#L109-L213
[ "def", "silhouette_samples", "(", "X", ",", "labels", ",", "metric", "=", "'euclidean'", ",", "*", "*", "kwds", ")", ":", "X", ",", "labels", "=", "check_X_y", "(", "X", ",", "labels", ",", "accept_sparse", "=", "[", "'csc'", ",", "'csr'", "]", ")", ...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
calinski_harabaz_score
Compute the Calinski and Harabaz score. The score is defined as ratio between the within-cluster dispersion and the between-cluster dispersion. Read more in the :ref:`User Guide <calinski_harabaz_index>`. Parameters ---------- X : array-like, shape (``n_samples``, ``n_features``) List...
bin/unsupervised.py
def calinski_harabaz_score(X, labels): """Compute the Calinski and Harabaz score. The score is defined as ratio between the within-cluster dispersion and the between-cluster dispersion. Read more in the :ref:`User Guide <calinski_harabaz_index>`. Parameters ---------- X : array-like, shap...
def calinski_harabaz_score(X, labels): """Compute the Calinski and Harabaz score. The score is defined as ratio between the within-cluster dispersion and the between-cluster dispersion. Read more in the :ref:`User Guide <calinski_harabaz_index>`. Parameters ---------- X : array-like, shap...
[ "Compute", "the", "Calinski", "and", "Harabaz", "score", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/bin/unsupervised.py#L216-L263
[ "def", "calinski_harabaz_score", "(", "X", ",", "labels", ")", ":", "X", ",", "labels", "=", "check_X_y", "(", "X", ",", "labels", ")", "le", "=", "LabelEncoder", "(", ")", "labels", "=", "le", ".", "fit_transform", "(", "labels", ")", "n_samples", ","...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
handle_zeros_in_scale
Makes sure that whenever scale is zero, we handle it correctly. This happens in most scalers when we have constant features. Adapted from sklearn.preprocessing.data
scanorama/utils.py
def handle_zeros_in_scale(scale, copy=True): ''' Makes sure that whenever scale is zero, we handle it correctly. This happens in most scalers when we have constant features. Adapted from sklearn.preprocessing.data''' # if we are fitting on 1D arrays, scale might be a scalar if np.isscalar(scale): ...
def handle_zeros_in_scale(scale, copy=True): ''' Makes sure that whenever scale is zero, we handle it correctly. This happens in most scalers when we have constant features. Adapted from sklearn.preprocessing.data''' # if we are fitting on 1D arrays, scale might be a scalar if np.isscalar(scale): ...
[ "Makes", "sure", "that", "whenever", "scale", "is", "zero", "we", "handle", "it", "correctly", ".", "This", "happens", "in", "most", "scalers", "when", "we", "have", "constant", "features", ".", "Adapted", "from", "sklearn", ".", "preprocessing", ".", "data"...
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/utils.py#L124-L139
[ "def", "handle_zeros_in_scale", "(", "scale", ",", "copy", "=", "True", ")", ":", "# if we are fitting on 1D arrays, scale might be a scalar", "if", "np", ".", "isscalar", "(", "scale", ")", ":", "if", "scale", "==", ".0", ":", "scale", "=", "1.", "return", "s...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
_joint_probabilities
Compute joint probabilities p_ij from distances. Parameters ---------- distances : array, shape (n_samples * (n_samples-1) / 2,) Distances of samples are stored as condensed matrices, i.e. we omit the diagonal and duplicate entries and store everything in a one-dimensional array. ...
scanorama/t_sne_approx.py
def _joint_probabilities(distances, desired_perplexity, verbose): """Compute joint probabilities p_ij from distances. Parameters ---------- distances : array, shape (n_samples * (n_samples-1) / 2,) Distances of samples are stored as condensed matrices, i.e. we omit the diagonal and dupl...
def _joint_probabilities(distances, desired_perplexity, verbose): """Compute joint probabilities p_ij from distances. Parameters ---------- distances : array, shape (n_samples * (n_samples-1) / 2,) Distances of samples are stored as condensed matrices, i.e. we omit the diagonal and dupl...
[ "Compute", "joint", "probabilities", "p_ij", "from", "distances", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L39-L68
[ "def", "_joint_probabilities", "(", "distances", ",", "desired_perplexity", ",", "verbose", ")", ":", "# Compute conditional probabilities such that they approximately match", "# the desired perplexity", "distances", "=", "distances", ".", "astype", "(", "np", ".", "float32",...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
_joint_probabilities_nn
Compute joint probabilities p_ij from distances using just nearest neighbors. This method is approximately equal to _joint_probabilities. The latter is O(N), but limiting the joint probability to nearest neighbors improves this substantially to O(uN). Parameters ---------- distances : arra...
scanorama/t_sne_approx.py
def _joint_probabilities_nn(distances, neighbors, desired_perplexity, verbose): """Compute joint probabilities p_ij from distances using just nearest neighbors. This method is approximately equal to _joint_probabilities. The latter is O(N), but limiting the joint probability to nearest neighbors improv...
def _joint_probabilities_nn(distances, neighbors, desired_perplexity, verbose): """Compute joint probabilities p_ij from distances using just nearest neighbors. This method is approximately equal to _joint_probabilities. The latter is O(N), but limiting the joint probability to nearest neighbors improv...
[ "Compute", "joint", "probabilities", "p_ij", "from", "distances", "using", "just", "nearest", "neighbors", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L71-L124
[ "def", "_joint_probabilities_nn", "(", "distances", ",", "neighbors", ",", "desired_perplexity", ",", "verbose", ")", ":", "t0", "=", "time", "(", ")", "# Compute conditional probabilities such that they approximately match", "# the desired perplexity", "n_samples", ",", "k...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
_kl_divergence
t-SNE objective function: gradient of the KL divergence of p_ijs and q_ijs and the absolute error. Parameters ---------- params : array, shape (n_params,) Unraveled embedding. P : array, shape (n_samples * (n_samples-1) / 2,) Condensed joint probability matrix. degrees_of_free...
scanorama/t_sne_approx.py
def _kl_divergence(params, P, degrees_of_freedom, n_samples, n_components, skip_num_points=0): """t-SNE objective function: gradient of the KL divergence of p_ijs and q_ijs and the absolute error. Parameters ---------- params : array, shape (n_params,) Unraveled embedding...
def _kl_divergence(params, P, degrees_of_freedom, n_samples, n_components, skip_num_points=0): """t-SNE objective function: gradient of the KL divergence of p_ijs and q_ijs and the absolute error. Parameters ---------- params : array, shape (n_params,) Unraveled embedding...
[ "t", "-", "SNE", "objective", "function", ":", "gradient", "of", "the", "KL", "divergence", "of", "p_ijs", "and", "q_ijs", "and", "the", "absolute", "error", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L127-L189
[ "def", "_kl_divergence", "(", "params", ",", "P", ",", "degrees_of_freedom", ",", "n_samples", ",", "n_components", ",", "skip_num_points", "=", "0", ")", ":", "X_embedded", "=", "params", ".", "reshape", "(", "n_samples", ",", "n_components", ")", "# Q is a h...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
_kl_divergence_bh
t-SNE objective function: KL divergence of p_ijs and q_ijs. Uses Barnes-Hut tree methods to calculate the gradient that runs in O(NlogN) instead of O(N^2) Parameters ---------- params : array, shape (n_params,) Unraveled embedding. P : csr sparse matrix, shape (n_samples, n_sample) ...
scanorama/t_sne_approx.py
def _kl_divergence_bh(params, P, degrees_of_freedom, n_samples, n_components, angle=0.5, skip_num_points=0, verbose=False): """t-SNE objective function: KL divergence of p_ijs and q_ijs. Uses Barnes-Hut tree methods to calculate the gradient that runs in O(NlogN) instead of O(N^2) ...
def _kl_divergence_bh(params, P, degrees_of_freedom, n_samples, n_components, angle=0.5, skip_num_points=0, verbose=False): """t-SNE objective function: KL divergence of p_ijs and q_ijs. Uses Barnes-Hut tree methods to calculate the gradient that runs in O(NlogN) instead of O(N^2) ...
[ "t", "-", "SNE", "objective", "function", ":", "KL", "divergence", "of", "p_ijs", "and", "q_ijs", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L192-L258
[ "def", "_kl_divergence_bh", "(", "params", ",", "P", ",", "degrees_of_freedom", ",", "n_samples", ",", "n_components", ",", "angle", "=", "0.5", ",", "skip_num_points", "=", "0", ",", "verbose", "=", "False", ")", ":", "params", "=", "params", ".", "astype...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
_gradient_descent
Batch gradient descent with momentum and individual gains. Parameters ---------- objective : function or callable Should return a tuple of cost and gradient for a given parameter vector. When expensive to compute, the cost can optionally be None and can be computed every n_iter_chec...
scanorama/t_sne_approx.py
def _gradient_descent(objective, p0, it, n_iter, n_iter_check=1, n_iter_without_progress=300, momentum=0.8, learning_rate=200.0, min_gain=0.01, min_grad_norm=1e-7, verbose=0, args=None, kwargs=None): """Batch gradient descent with momentum and indivi...
def _gradient_descent(objective, p0, it, n_iter, n_iter_check=1, n_iter_without_progress=300, momentum=0.8, learning_rate=200.0, min_gain=0.01, min_grad_norm=1e-7, verbose=0, args=None, kwargs=None): """Batch gradient descent with momentum and indivi...
[ "Batch", "gradient", "descent", "with", "momentum", "and", "individual", "gains", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L261-L383
[ "def", "_gradient_descent", "(", "objective", ",", "p0", ",", "it", ",", "n_iter", ",", "n_iter_check", "=", "1", ",", "n_iter_without_progress", "=", "300", ",", "momentum", "=", "0.8", ",", "learning_rate", "=", "200.0", ",", "min_gain", "=", "0.01", ","...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
trustworthiness
Expresses to what extent the local structure is retained. The trustworthiness is within [0, 1]. It is defined as .. math:: T(k) = 1 - \frac{2}{nk (2n - 3k - 1)} \sum^n_{i=1} \sum_{j \in U^{(k)}_i} (r(i, j) - k) where :math:`r(i, j)` is the rank of the embedded datapoint j accordi...
scanorama/t_sne_approx.py
def trustworthiness(X, X_embedded, n_neighbors=5, precomputed=False): """Expresses to what extent the local structure is retained. The trustworthiness is within [0, 1]. It is defined as .. math:: T(k) = 1 - \frac{2}{nk (2n - 3k - 1)} \sum^n_{i=1} \sum_{j \in U^{(k)}_i} (r(i, j) - k) ...
def trustworthiness(X, X_embedded, n_neighbors=5, precomputed=False): """Expresses to what extent the local structure is retained. The trustworthiness is within [0, 1]. It is defined as .. math:: T(k) = 1 - \frac{2}{nk (2n - 3k - 1)} \sum^n_{i=1} \sum_{j \in U^{(k)}_i} (r(i, j) - k) ...
[ "Expresses", "to", "what", "extent", "the", "local", "structure", "is", "retained", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L386-L445
[ "def", "trustworthiness", "(", "X", ",", "X_embedded", ",", "n_neighbors", "=", "5", ",", "precomputed", "=", "False", ")", ":", "if", "precomputed", ":", "dist_X", "=", "X", "else", ":", "dist_X", "=", "pairwise_distances", "(", "X", ",", "squared", "="...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
TSNEApprox._fit
Fit the model using X as training data. Note that sparse arrays can only be handled by method='exact'. It is recommended that you convert your sparse array to dense (e.g. `X.toarray()`) if it fits in memory, or otherwise using a dimensionality reduction technique (e.g. TruncatedSVD). ...
scanorama/t_sne_approx.py
def _fit(self, X, skip_num_points=0): """Fit the model using X as training data. Note that sparse arrays can only be handled by method='exact'. It is recommended that you convert your sparse array to dense (e.g. `X.toarray()`) if it fits in memory, or otherwise using a dimension...
def _fit(self, X, skip_num_points=0): """Fit the model using X as training data. Note that sparse arrays can only be handled by method='exact'. It is recommended that you convert your sparse array to dense (e.g. `X.toarray()`) if it fits in memory, or otherwise using a dimension...
[ "Fit", "the", "model", "using", "X", "as", "training", "data", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L621-L784
[ "def", "_fit", "(", "self", ",", "X", ",", "skip_num_points", "=", "0", ")", ":", "if", "self", ".", "method", "not", "in", "[", "'barnes_hut'", ",", "'exact'", "]", ":", "raise", "ValueError", "(", "\"'method' must be 'barnes_hut' or 'exact'\"", ")", "if", ...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
TSNEApprox._tsne
Runs t-SNE.
scanorama/t_sne_approx.py
def _tsne(self, P, degrees_of_freedom, n_samples, random_state, X_embedded, neighbors=None, skip_num_points=0): """Runs t-SNE.""" # t-SNE minimizes the Kullback-Leiber divergence of the Gaussians P # and the Student's t-distributions Q. The optimization algorithm that # we ...
def _tsne(self, P, degrees_of_freedom, n_samples, random_state, X_embedded, neighbors=None, skip_num_points=0): """Runs t-SNE.""" # t-SNE minimizes the Kullback-Leiber divergence of the Gaussians P # and the Student's t-distributions Q. The optimization algorithm that # we ...
[ "Runs", "t", "-", "SNE", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L792-L853
[ "def", "_tsne", "(", "self", ",", "P", ",", "degrees_of_freedom", ",", "n_samples", ",", "random_state", ",", "X_embedded", ",", "neighbors", "=", "None", ",", "skip_num_points", "=", "0", ")", ":", "# t-SNE minimizes the Kullback-Leiber divergence of the Gaussians P"...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
TSNEApprox.fit_transform
Fit X into an embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) or (n_samples, n_samples) If the metric is 'precomputed' X must be a square distance matrix. Otherwise it contains a sample per row. ...
scanorama/t_sne_approx.py
def fit_transform(self, X, y=None): """Fit X into an embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) or (n_samples, n_samples) If the metric is 'precomputed' X must be a square distance mat...
def fit_transform(self, X, y=None): """Fit X into an embedded space and return that transformed output. Parameters ---------- X : array, shape (n_samples, n_features) or (n_samples, n_samples) If the metric is 'precomputed' X must be a square distance mat...
[ "Fit", "X", "into", "an", "embedded", "space", "and", "return", "that", "transformed", "output", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/t_sne_approx.py#L855-L872
[ "def", "fit_transform", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "embedding", "=", "self", ".", "_fit", "(", "X", ")", "self", ".", "embedding_", "=", "embedding", "return", "self", ".", "embedding_" ]
57aafac87d07a8d682f57450165dd07f066ebb3c
train
correct
Integrate and batch correct a list of data sets. Parameters ---------- datasets_full : `list` of `scipy.sparse.csr_matrix` or of `numpy.ndarray` Data sets to integrate and correct. genes_list: `list` of `list` of `string` List of genes for each data set. return_dimred: `bool`, optio...
scanorama/scanorama.py
def correct(datasets_full, genes_list, return_dimred=False, batch_size=BATCH_SIZE, verbose=VERBOSE, ds_names=None, dimred=DIMRED, approx=APPROX, sigma=SIGMA, alpha=ALPHA, knn=KNN, return_dense=False, hvg=None, union=False, geosketch=False, geosketch_max=20000): """Int...
def correct(datasets_full, genes_list, return_dimred=False, batch_size=BATCH_SIZE, verbose=VERBOSE, ds_names=None, dimred=DIMRED, approx=APPROX, sigma=SIGMA, alpha=ALPHA, knn=KNN, return_dense=False, hvg=None, union=False, geosketch=False, geosketch_max=20000): """Int...
[ "Integrate", "and", "batch", "correct", "a", "list", "of", "data", "sets", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/scanorama.py#L37-L111
[ "def", "correct", "(", "datasets_full", ",", "genes_list", ",", "return_dimred", "=", "False", ",", "batch_size", "=", "BATCH_SIZE", ",", "verbose", "=", "VERBOSE", ",", "ds_names", "=", "None", ",", "dimred", "=", "DIMRED", ",", "approx", "=", "APPROX", "...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
integrate
Integrate a list of data sets. Parameters ---------- datasets_full : `list` of `scipy.sparse.csr_matrix` or of `numpy.ndarray` Data sets to integrate and correct. genes_list: `list` of `list` of `string` List of genes for each data set. batch_size: `int`, optional (default: `5000`) ...
scanorama/scanorama.py
def integrate(datasets_full, genes_list, batch_size=BATCH_SIZE, verbose=VERBOSE, ds_names=None, dimred=DIMRED, approx=APPROX, sigma=SIGMA, alpha=ALPHA, knn=KNN, geosketch=False, geosketch_max=20000, n_iter=1, union=False, hvg=None): """Integrate a list of data sets. Pa...
def integrate(datasets_full, genes_list, batch_size=BATCH_SIZE, verbose=VERBOSE, ds_names=None, dimred=DIMRED, approx=APPROX, sigma=SIGMA, alpha=ALPHA, knn=KNN, geosketch=False, geosketch_max=20000, n_iter=1, union=False, hvg=None): """Integrate a list of data sets. Pa...
[ "Integrate", "a", "list", "of", "data", "sets", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/scanorama.py#L114-L169
[ "def", "integrate", "(", "datasets_full", ",", "genes_list", ",", "batch_size", "=", "BATCH_SIZE", ",", "verbose", "=", "VERBOSE", ",", "ds_names", "=", "None", ",", "dimred", "=", "DIMRED", ",", "approx", "=", "APPROX", ",", "sigma", "=", "SIGMA", ",", ...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
correct_scanpy
Batch correct a list of `scanpy.api.AnnData`. Parameters ---------- adatas : `list` of `scanpy.api.AnnData` Data sets to integrate and/or correct. kwargs : `dict` See documentation for the `correct()` method for a full list of parameters to use for batch correction. Returns...
scanorama/scanorama.py
def correct_scanpy(adatas, **kwargs): """Batch correct a list of `scanpy.api.AnnData`. Parameters ---------- adatas : `list` of `scanpy.api.AnnData` Data sets to integrate and/or correct. kwargs : `dict` See documentation for the `correct()` method for a full list of paramet...
def correct_scanpy(adatas, **kwargs): """Batch correct a list of `scanpy.api.AnnData`. Parameters ---------- adatas : `list` of `scanpy.api.AnnData` Data sets to integrate and/or correct. kwargs : `dict` See documentation for the `correct()` method for a full list of paramet...
[ "Batch", "correct", "a", "list", "of", "scanpy", ".", "api", ".", "AnnData", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/scanorama.py#L172-L216
[ "def", "correct_scanpy", "(", "adatas", ",", "*", "*", "kwargs", ")", ":", "if", "'return_dimred'", "in", "kwargs", "and", "kwargs", "[", "'return_dimred'", "]", ":", "datasets_dimred", ",", "datasets", ",", "genes", "=", "correct", "(", "[", "adata", ".",...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
integrate_scanpy
Integrate a list of `scanpy.api.AnnData`. Parameters ---------- adatas : `list` of `scanpy.api.AnnData` Data sets to integrate. kwargs : `dict` See documentation for the `integrate()` method for a full list of parameters to use for batch correction. Returns ------- ...
scanorama/scanorama.py
def integrate_scanpy(adatas, **kwargs): """Integrate a list of `scanpy.api.AnnData`. Parameters ---------- adatas : `list` of `scanpy.api.AnnData` Data sets to integrate. kwargs : `dict` See documentation for the `integrate()` method for a full list of parameters to use for ...
def integrate_scanpy(adatas, **kwargs): """Integrate a list of `scanpy.api.AnnData`. Parameters ---------- adatas : `list` of `scanpy.api.AnnData` Data sets to integrate. kwargs : `dict` See documentation for the `integrate()` method for a full list of parameters to use for ...
[ "Integrate", "a", "list", "of", "scanpy", ".", "api", ".", "AnnData", "." ]
brianhie/scanorama
python
https://github.com/brianhie/scanorama/blob/57aafac87d07a8d682f57450165dd07f066ebb3c/scanorama/scanorama.py#L219-L242
[ "def", "integrate_scanpy", "(", "adatas", ",", "*", "*", "kwargs", ")", ":", "datasets_dimred", ",", "genes", "=", "integrate", "(", "[", "adata", ".", "X", "for", "adata", "in", "adatas", "]", ",", "[", "adata", ".", "var_names", ".", "values", "for",...
57aafac87d07a8d682f57450165dd07f066ebb3c
train
augknt
Augment a knot vector. Parameters: knots: Python list or rank-1 array, the original knot vector (without endpoint repeats) order: int, >= 0, order of spline Returns: list_of_knots: rank-1 array that has (`order` + 1) copies of ``knots[0]``, then ``knots[1:-1]``, and finally (`order...
bspline/splinelab.py
def augknt(knots, order): """Augment a knot vector. Parameters: knots: Python list or rank-1 array, the original knot vector (without endpoint repeats) order: int, >= 0, order of spline Returns: list_of_knots: rank-1 array that has (`order` + 1) copies of ``knots[0]``, then ``k...
def augknt(knots, order): """Augment a knot vector. Parameters: knots: Python list or rank-1 array, the original knot vector (without endpoint repeats) order: int, >= 0, order of spline Returns: list_of_knots: rank-1 array that has (`order` + 1) copies of ``knots[0]``, then ``k...
[ "Augment", "a", "knot", "vector", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/splinelab.py#L23-L47
[ "def", "augknt", "(", "knots", ",", "order", ")", ":", "if", "isinstance", "(", "knots", ",", "np", ".", "ndarray", ")", "and", "knots", ".", "ndim", ">", "1", ":", "raise", "ValueError", "(", "\"knots must be a list or a rank-1 array\"", ")", "knots", "="...
366085a665da6fe907258eafcc8032c58a0601e0
train
aveknt
Compute the running average of `k` successive elements of `t`. Return the averaged array. Parameters: t: Python list or rank-1 array k: int, >= 2, how many successive elements to average Returns: rank-1 array, averaged data. If k > len(t), returns a zero-length array. Caveat: This is ...
bspline/splinelab.py
def aveknt(t, k): """Compute the running average of `k` successive elements of `t`. Return the averaged array. Parameters: t: Python list or rank-1 array k: int, >= 2, how many successive elements to average Returns: rank-1 array, averaged data. If k > len(t), returns a zero-length arr...
def aveknt(t, k): """Compute the running average of `k` successive elements of `t`. Return the averaged array. Parameters: t: Python list or rank-1 array k: int, >= 2, how many successive elements to average Returns: rank-1 array, averaged data. If k > len(t), returns a zero-length arr...
[ "Compute", "the", "running", "average", "of", "k", "successive", "elements", "of", "t", ".", "Return", "the", "averaged", "array", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/splinelab.py#L50-L78
[ "def", "aveknt", "(", "t", ",", "k", ")", ":", "t", "=", "np", ".", "atleast_1d", "(", "t", ")", "if", "t", ".", "ndim", ">", "1", ":", "raise", "ValueError", "(", "\"t must be a list or a rank-1 array\"", ")", "n", "=", "t", ".", "shape", "[", "0"...
366085a665da6fe907258eafcc8032c58a0601e0
train
aptknt
Create an acceptable knot vector. Minimal emulation of MATLAB's ``aptknt``. The returned knot vector can be used to generate splines of desired `order` that are suitable for interpolation to the collocation sites `tau`. Note that this is only possible when ``len(tau)`` >= `order` + 1. When this condition does not h...
bspline/splinelab.py
def aptknt(tau, order): """Create an acceptable knot vector. Minimal emulation of MATLAB's ``aptknt``. The returned knot vector can be used to generate splines of desired `order` that are suitable for interpolation to the collocation sites `tau`. Note that this is only possible when ``len(tau)`` >= `order` + 1. ...
def aptknt(tau, order): """Create an acceptable knot vector. Minimal emulation of MATLAB's ``aptknt``. The returned knot vector can be used to generate splines of desired `order` that are suitable for interpolation to the collocation sites `tau`. Note that this is only possible when ``len(tau)`` >= `order` + 1. ...
[ "Create", "an", "acceptable", "knot", "vector", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/splinelab.py#L81-L145
[ "def", "aptknt", "(", "tau", ",", "order", ")", ":", "tau", "=", "np", ".", "atleast_1d", "(", "tau", ")", "k", "=", "order", "+", "1", "if", "tau", ".", "ndim", ">", "1", ":", "raise", "ValueError", "(", "\"tau must be a list or a rank-1 array\"", ")"...
366085a665da6fe907258eafcc8032c58a0601e0
train
knt2mlt
Count multiplicities of elements in a sorted list or rank-1 array. Minimal emulation of MATLAB's ``knt2mlt``. Parameters: t: Python list or rank-1 array. Must be sorted! Returns: out rank-1 array such that out[k] = #{ t[i] == t[k] for i < k } Example: If ``t = [1, 1, 2, 3, 3, 3]`...
bspline/splinelab.py
def knt2mlt(t): """Count multiplicities of elements in a sorted list or rank-1 array. Minimal emulation of MATLAB's ``knt2mlt``. Parameters: t: Python list or rank-1 array. Must be sorted! Returns: out rank-1 array such that out[k] = #{ t[i] == t[k] for i < k } Example: If ``...
def knt2mlt(t): """Count multiplicities of elements in a sorted list or rank-1 array. Minimal emulation of MATLAB's ``knt2mlt``. Parameters: t: Python list or rank-1 array. Must be sorted! Returns: out rank-1 array such that out[k] = #{ t[i] == t[k] for i < k } Example: If ``...
[ "Count", "multiplicities", "of", "elements", "in", "a", "sorted", "list", "or", "rank", "-", "1", "array", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/splinelab.py#L148-L182
[ "def", "knt2mlt", "(", "t", ")", ":", "t", "=", "np", ".", "atleast_1d", "(", "t", ")", "if", "t", ".", "ndim", ">", "1", ":", "raise", "ValueError", "(", "\"t must be a list or a rank-1 array\"", ")", "out", "=", "[", "]", "e", "=", "None", "for", ...
366085a665da6fe907258eafcc8032c58a0601e0
train
spcol
Return collocation matrix. Minimal emulation of MATLAB's ``spcol``. Parameters: knots: rank-1 array, knot vector (with appropriately repeated endpoints; see `augknt`, `aptknt`) order: int, >= 0, order of spline tau: rank-1 array, collocation sites Returns: rank-2 array A such ...
bspline/splinelab.py
def spcol(knots, order, tau): """Return collocation matrix. Minimal emulation of MATLAB's ``spcol``. Parameters: knots: rank-1 array, knot vector (with appropriately repeated endpoints; see `augknt`, `aptknt`) order: int, >= 0, order of spline tau: rank-1 array, collocation sit...
def spcol(knots, order, tau): """Return collocation matrix. Minimal emulation of MATLAB's ``spcol``. Parameters: knots: rank-1 array, knot vector (with appropriately repeated endpoints; see `augknt`, `aptknt`) order: int, >= 0, order of spline tau: rank-1 array, collocation sit...
[ "Return", "collocation", "matrix", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/splinelab.py#L185-L220
[ "def", "spcol", "(", "knots", ",", "order", ",", "tau", ")", ":", "m", "=", "knt2mlt", "(", "tau", ")", "B", "=", "bspline", ".", "Bspline", "(", "knots", ",", "order", ")", "dummy", "=", "B", "(", "0.", ")", "nbasis", "=", "len", "(", "dummy",...
366085a665da6fe907258eafcc8032c58a0601e0
train
Bspline.__basis0
Order zero basis (for internal use).
bspline/bspline.py
def __basis0(self, xi): """Order zero basis (for internal use).""" return np.where(np.all([self.knot_vector[:-1] <= xi, xi < self.knot_vector[1:]],axis=0), 1.0, 0.0)
def __basis0(self, xi): """Order zero basis (for internal use).""" return np.where(np.all([self.knot_vector[:-1] <= xi, xi < self.knot_vector[1:]],axis=0), 1.0, 0.0)
[ "Order", "zero", "basis", "(", "for", "internal", "use", ")", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/bspline.py#L83-L86
[ "def", "__basis0", "(", "self", ",", "xi", ")", ":", "return", "np", ".", "where", "(", "np", ".", "all", "(", "[", "self", ".", "knot_vector", "[", ":", "-", "1", "]", "<=", "xi", ",", "xi", "<", "self", ".", "knot_vector", "[", "1", ":", "]...
366085a665da6fe907258eafcc8032c58a0601e0
train
Bspline.__basis
Recursive Cox - de Boor function (for internal use). Compute basis functions and optionally their first derivatives.
bspline/bspline.py
def __basis(self, xi, p, compute_derivatives=False): """Recursive Cox - de Boor function (for internal use). Compute basis functions and optionally their first derivatives. """ if p == 0: return self.__basis0(xi) else: basis_p_minus_1 = self.__basis(xi, ...
def __basis(self, xi, p, compute_derivatives=False): """Recursive Cox - de Boor function (for internal use). Compute basis functions and optionally their first derivatives. """ if p == 0: return self.__basis0(xi) else: basis_p_minus_1 = self.__basis(xi, ...
[ "Recursive", "Cox", "-", "de", "Boor", "function", "(", "for", "internal", "use", ")", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/bspline.py#L88-L123
[ "def", "__basis", "(", "self", ",", "xi", ",", "p", ",", "compute_derivatives", "=", "False", ")", ":", "if", "p", "==", "0", ":", "return", "self", ".", "__basis0", "(", "xi", ")", "else", ":", "basis_p_minus_1", "=", "self", ".", "__basis", "(", ...
366085a665da6fe907258eafcc8032c58a0601e0
train
Bspline.d
Convenience function to compute first derivative of basis functions. 'Memoized' for speed.
bspline/bspline.py
def d(self, xi): """Convenience function to compute first derivative of basis functions. 'Memoized' for speed.""" return self.__basis(xi, self.p, compute_derivatives=True)
def d(self, xi): """Convenience function to compute first derivative of basis functions. 'Memoized' for speed.""" return self.__basis(xi, self.p, compute_derivatives=True)
[ "Convenience", "function", "to", "compute", "first", "derivative", "of", "basis", "functions", ".", "Memoized", "for", "speed", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/bspline.py#L131-L133
[ "def", "d", "(", "self", ",", "xi", ")", ":", "return", "self", ".", "__basis", "(", "xi", ",", "self", ".", "p", ",", "compute_derivatives", "=", "True", ")" ]
366085a665da6fe907258eafcc8032c58a0601e0
train
Bspline.plot
Plot basis functions over full range of knots. Convenience function. Requires matplotlib.
bspline/bspline.py
def plot(self): """Plot basis functions over full range of knots. Convenience function. Requires matplotlib. """ try: import matplotlib.pyplot as plt except ImportError: from sys import stderr print("ERROR: matplotlib.pyplot not found, matplo...
def plot(self): """Plot basis functions over full range of knots. Convenience function. Requires matplotlib. """ try: import matplotlib.pyplot as plt except ImportError: from sys import stderr print("ERROR: matplotlib.pyplot not found, matplo...
[ "Plot", "basis", "functions", "over", "full", "range", "of", "knots", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/bspline.py#L135-L158
[ "def", "plot", "(", "self", ")", ":", "try", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "except", "ImportError", ":", "from", "sys", "import", "stderr", "print", "(", "\"ERROR: matplotlib.pyplot not found, matplotlib must be installed to use this function\...
366085a665da6fe907258eafcc8032c58a0601e0
train
Bspline.__diff_internal
Differentiate a B-spline once, and return the resulting coefficients and Bspline objects. This preserves the Bspline object nature of the data, enabling recursive implementation of higher-order differentiation (see `diff`). The value of the first derivative of `B` at a point `x` can be obtained as:: def diff1(B,...
bspline/bspline.py
def __diff_internal(self): """Differentiate a B-spline once, and return the resulting coefficients and Bspline objects. This preserves the Bspline object nature of the data, enabling recursive implementation of higher-order differentiation (see `diff`). The value of the first derivative of `B` at a point `x` ...
def __diff_internal(self): """Differentiate a B-spline once, and return the resulting coefficients and Bspline objects. This preserves the Bspline object nature of the data, enabling recursive implementation of higher-order differentiation (see `diff`). The value of the first derivative of `B` at a point `x` ...
[ "Differentiate", "a", "B", "-", "spline", "once", "and", "return", "the", "resulting", "coefficients", "and", "Bspline", "objects", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/bspline.py#L186-L222
[ "def", "__diff_internal", "(", "self", ")", ":", "assert", "self", ".", "p", ">", "0", ",", "\"order of Bspline must be > 0\"", "# we already handle the other case in diff()", "# https://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-derv.html", "#", "t", "=",...
366085a665da6fe907258eafcc8032c58a0601e0
train
Bspline.diff
Differentiate a B-spline `order` number of times. Parameters: order: int, >= 0 Returns: **lambda** `x`: ... that evaluates the `order`-th derivative of `B` at the point `x`. The returned function internally uses __call__, which is 'memoized' for speed.
bspline/bspline.py
def diff(self, order=1): """Differentiate a B-spline `order` number of times. Parameters: order: int, >= 0 Returns: **lambda** `x`: ... that evaluates the `order`-th derivative of `B` at the point `x`. The returned function internally uses __call__, which is 'memoized' for ...
def diff(self, order=1): """Differentiate a B-spline `order` number of times. Parameters: order: int, >= 0 Returns: **lambda** `x`: ... that evaluates the `order`-th derivative of `B` at the point `x`. The returned function internally uses __call__, which is 'memoized' for ...
[ "Differentiate", "a", "B", "-", "spline", "order", "number", "of", "times", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/bspline.py#L225-L262
[ "def", "diff", "(", "self", ",", "order", "=", "1", ")", ":", "order", "=", "int", "(", "order", ")", "if", "order", "<", "0", ":", "raise", "ValueError", "(", "\"order must be >= 0, got %d\"", "%", "(", "order", ")", ")", "if", "order", "==", "0", ...
366085a665da6fe907258eafcc8032c58a0601e0
train
Bspline.collmat
Compute collocation matrix. Parameters: tau: Python list or rank-1 array, collocation sites deriv_order: int, >=0, order of derivative for which to compute the collocation matrix. The default is 0, which means the function value itself. Returns: A: if len(tau) > 1, rank-2 a...
bspline/bspline.py
def collmat(self, tau, deriv_order=0): """Compute collocation matrix. Parameters: tau: Python list or rank-1 array, collocation sites deriv_order: int, >=0, order of derivative for which to compute the collocation matrix. The default is 0, which means the function value itself. ...
def collmat(self, tau, deriv_order=0): """Compute collocation matrix. Parameters: tau: Python list or rank-1 array, collocation sites deriv_order: int, >=0, order of derivative for which to compute the collocation matrix. The default is 0, which means the function value itself. ...
[ "Compute", "collocation", "matrix", "." ]
johntfoster/bspline
python
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/bspline.py#L265-L309
[ "def", "collmat", "(", "self", ",", "tau", ",", "deriv_order", "=", "0", ")", ":", "# get number of basis functions and output dtype", "dummy", "=", "self", ".", "__call__", "(", "0.", ")", "nbasis", "=", "dummy", ".", "shape", "[", "0", "]", "tau", "=", ...
366085a665da6fe907258eafcc8032c58a0601e0
train
build_interfaces_by_method
Create new dictionary from INTERFACES hashed by method then the endpoints name. For use when using the disqusapi by the method interface instead of the endpoint interface. For instance: 'blacklists': { 'add': { 'formats': ['json', 'jsonp'], 'method': 'POST', ...
disqusapi/utils.py
def build_interfaces_by_method(interfaces): """ Create new dictionary from INTERFACES hashed by method then the endpoints name. For use when using the disqusapi by the method interface instead of the endpoint interface. For instance: 'blacklists': { 'add': { 'formats': ['jso...
def build_interfaces_by_method(interfaces): """ Create new dictionary from INTERFACES hashed by method then the endpoints name. For use when using the disqusapi by the method interface instead of the endpoint interface. For instance: 'blacklists': { 'add': { 'formats': ['jso...
[ "Create", "new", "dictionary", "from", "INTERFACES", "hashed", "by", "method", "then", "the", "endpoints", "name", ".", "For", "use", "when", "using", "the", "disqusapi", "by", "the", "method", "interface", "instead", "of", "the", "endpoint", "interface", ".",...
disqus/disqus-python
python
https://github.com/disqus/disqus-python/blob/605f33c7b735fcb85e16041c27658fbba49d7a7b/disqusapi/utils.py#L8-L48
[ "def", "build_interfaces_by_method", "(", "interfaces", ")", ":", "def", "traverse", "(", "block", ",", "parts", ")", ":", "try", ":", "method", "=", "block", "[", "'method'", "]", ".", "lower", "(", ")", "except", "KeyError", ":", "for", "k", ",", "v"...
605f33c7b735fcb85e16041c27658fbba49d7a7b
train
get_normalized_request_string
Returns a normalized request string as described iN OAuth2 MAC spec. http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.3.1
disqusapi/utils.py
def get_normalized_request_string(method, url, nonce, params, ext='', body_hash=None): """ Returns a normalized request string as described iN OAuth2 MAC spec. http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.3.1 """ urlparts = urlparse.urlparse(url) if urlparts.query: ...
def get_normalized_request_string(method, url, nonce, params, ext='', body_hash=None): """ Returns a normalized request string as described iN OAuth2 MAC spec. http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.3.1 """ urlparts = urlparse.urlparse(url) if urlparts.query: ...
[ "Returns", "a", "normalized", "request", "string", "as", "described", "iN", "OAuth2", "MAC", "spec", "." ]
disqus/disqus-python
python
https://github.com/disqus/disqus-python/blob/605f33c7b735fcb85e16041c27658fbba49d7a7b/disqusapi/utils.py#L59-L87
[ "def", "get_normalized_request_string", "(", "method", ",", "url", ",", "nonce", ",", "params", ",", "ext", "=", "''", ",", "body_hash", "=", "None", ")", ":", "urlparts", "=", "urlparse", ".", "urlparse", "(", "url", ")", "if", "urlparts", ".", "query",...
605f33c7b735fcb85e16041c27658fbba49d7a7b
train
get_body_hash
Returns BASE64 ( HASH (text) ) as described in OAuth2 MAC spec. http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.2
disqusapi/utils.py
def get_body_hash(params): """ Returns BASE64 ( HASH (text) ) as described in OAuth2 MAC spec. http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.2 """ norm_params = get_normalized_params(params) return binascii.b2a_base64(hashlib.sha1(norm_params).digest())[:-1]
def get_body_hash(params): """ Returns BASE64 ( HASH (text) ) as described in OAuth2 MAC spec. http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3.2 """ norm_params = get_normalized_params(params) return binascii.b2a_base64(hashlib.sha1(norm_params).digest())[:-1]
[ "Returns", "BASE64", "(", "HASH", "(", "text", ")", ")", "as", "described", "in", "OAuth2", "MAC", "spec", "." ]
disqus/disqus-python
python
https://github.com/disqus/disqus-python/blob/605f33c7b735fcb85e16041c27658fbba49d7a7b/disqusapi/utils.py#L90-L98
[ "def", "get_body_hash", "(", "params", ")", ":", "norm_params", "=", "get_normalized_params", "(", "params", ")", "return", "binascii", ".", "b2a_base64", "(", "hashlib", ".", "sha1", "(", "norm_params", ")", ".", "digest", "(", ")", ")", "[", ":", "-", ...
605f33c7b735fcb85e16041c27658fbba49d7a7b
train
get_mac_signature
Returns HMAC-SHA1 (api secret, normalized request string)
disqusapi/utils.py
def get_mac_signature(api_secret, norm_request_string): """ Returns HMAC-SHA1 (api secret, normalized request string) """ hashed = hmac.new(str(api_secret), norm_request_string, hashlib.sha1) return binascii.b2a_base64(hashed.digest())[:-1]
def get_mac_signature(api_secret, norm_request_string): """ Returns HMAC-SHA1 (api secret, normalized request string) """ hashed = hmac.new(str(api_secret), norm_request_string, hashlib.sha1) return binascii.b2a_base64(hashed.digest())[:-1]
[ "Returns", "HMAC", "-", "SHA1", "(", "api", "secret", "normalized", "request", "string", ")" ]
disqus/disqus-python
python
https://github.com/disqus/disqus-python/blob/605f33c7b735fcb85e16041c27658fbba49d7a7b/disqusapi/utils.py#L101-L106
[ "def", "get_mac_signature", "(", "api_secret", ",", "norm_request_string", ")", ":", "hashed", "=", "hmac", ".", "new", "(", "str", "(", "api_secret", ")", ",", "norm_request_string", ",", "hashlib", ".", "sha1", ")", "return", "binascii", ".", "b2a_base64", ...
605f33c7b735fcb85e16041c27658fbba49d7a7b
train
Fs.open_file
input: filename and path. output: file contents.
j/Api.py
def open_file(self, access_mode="r"): """ input: filename and path. output: file contents. """ try: with open(self, access_mode, encoding='utf-8') as file: return file.read() except IOError: print(self + " File not found."...
def open_file(self, access_mode="r"): """ input: filename and path. output: file contents. """ try: with open(self, access_mode, encoding='utf-8') as file: return file.read() except IOError: print(self + " File not found."...
[ "input", ":", "filename", "and", "path", ".", "output", ":", "file", "contents", "." ]
codesardine/Jade-Application-Kit
python
https://github.com/codesardine/Jade-Application-Kit/blob/f94ba061f1e71c812f23ef4297473a5fce712367/j/Api.py#L8-L19
[ "def", "open_file", "(", "self", ",", "access_mode", "=", "\"r\"", ")", ":", "try", ":", "with", "open", "(", "self", ",", "access_mode", ",", "encoding", "=", "'utf-8'", ")", "as", "file", ":", "return", "file", ".", "read", "(", ")", "except", "IOE...
f94ba061f1e71c812f23ef4297473a5fce712367
train
MaximumLikelihoodEstimator._forward_backward
Estimation step: Runs the forward-back algorithm on trajectory with index itraj Parameters ---------- itraj : int index of the observation trajectory to process Results ------- logprob : float The probability to observe the observation sequence g...
bhmm/estimators/maximum_likelihood.py
def _forward_backward(self, itraj): """ Estimation step: Runs the forward-back algorithm on trajectory with index itraj Parameters ---------- itraj : int index of the observation trajectory to process Results ------- logprob : float ...
def _forward_backward(self, itraj): """ Estimation step: Runs the forward-back algorithm on trajectory with index itraj Parameters ---------- itraj : int index of the observation trajectory to process Results ------- logprob : float ...
[ "Estimation", "step", ":", "Runs", "the", "forward", "-", "back", "algorithm", "on", "trajectory", "with", "index", "itraj" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/estimators/maximum_likelihood.py#L221-L269
[ "def", "_forward_backward", "(", "self", ",", "itraj", ")", ":", "# get parameters", "A", "=", "self", ".", "_hmm", ".", "transition_matrix", "pi", "=", "self", ".", "_hmm", ".", "initial_distribution", "obs", "=", "self", ".", "_observations", "[", "itraj",...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
MaximumLikelihoodEstimator._update_model
Maximization step: Updates the HMM model given the hidden state assignment and count matrices Parameters ---------- gamma : [ ndarray(T,N, dtype=float) ] list of state probabilities for each trajectory count_matrix : [ ndarray(N,N, dtype=float) ] list of the Baum...
bhmm/estimators/maximum_likelihood.py
def _update_model(self, gammas, count_matrices, maxiter=10000000): """ Maximization step: Updates the HMM model given the hidden state assignment and count matrices Parameters ---------- gamma : [ ndarray(T,N, dtype=float) ] list of state probabilities for each traje...
def _update_model(self, gammas, count_matrices, maxiter=10000000): """ Maximization step: Updates the HMM model given the hidden state assignment and count matrices Parameters ---------- gamma : [ ndarray(T,N, dtype=float) ] list of state probabilities for each traje...
[ "Maximization", "step", ":", "Updates", "the", "HMM", "model", "given", "the", "hidden", "state", "assignment", "and", "count", "matrices" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/estimators/maximum_likelihood.py#L284-L330
[ "def", "_update_model", "(", "self", ",", "gammas", ",", "count_matrices", ",", "maxiter", "=", "10000000", ")", ":", "gamma0_sum", "=", "self", ".", "_init_counts", "(", "gammas", ")", "C", "=", "self", ".", "_transition_counts", "(", "count_matrices", ")",...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
MaximumLikelihoodEstimator.compute_viterbi_paths
Computes the viterbi paths using the current HMM model
bhmm/estimators/maximum_likelihood.py
def compute_viterbi_paths(self): """ Computes the viterbi paths using the current HMM model """ # get parameters K = len(self._observations) A = self._hmm.transition_matrix pi = self._hmm.initial_distribution # compute viterbi path for each trajectory ...
def compute_viterbi_paths(self): """ Computes the viterbi paths using the current HMM model """ # get parameters K = len(self._observations) A = self._hmm.transition_matrix pi = self._hmm.initial_distribution # compute viterbi path for each trajectory ...
[ "Computes", "the", "viterbi", "paths", "using", "the", "current", "HMM", "model" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/estimators/maximum_likelihood.py#L332-L352
[ "def", "compute_viterbi_paths", "(", "self", ")", ":", "# get parameters", "K", "=", "len", "(", "self", ".", "_observations", ")", "A", "=", "self", ".", "_hmm", ".", "transition_matrix", "pi", "=", "self", ".", "_hmm", ".", "initial_distribution", "# compu...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
MaximumLikelihoodEstimator.fit
Maximum-likelihood estimation of the HMM using the Baum-Welch algorithm Returns ------- model : HMM The maximum likelihood HMM model.
bhmm/estimators/maximum_likelihood.py
def fit(self): """ Maximum-likelihood estimation of the HMM using the Baum-Welch algorithm Returns ------- model : HMM The maximum likelihood HMM model. """ logger().info("=================================================================") lo...
def fit(self): """ Maximum-likelihood estimation of the HMM using the Baum-Welch algorithm Returns ------- model : HMM The maximum likelihood HMM model. """ logger().info("=================================================================") lo...
[ "Maximum", "-", "likelihood", "estimation", "of", "the", "HMM", "using", "the", "Baum", "-", "Welch", "algorithm" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/estimators/maximum_likelihood.py#L354-L446
[ "def", "fit", "(", "self", ")", ":", "logger", "(", ")", ".", "info", "(", "\"=================================================================\"", ")", "logger", "(", ")", ".", "info", "(", "\"Running Baum-Welch:\"", ")", "logger", "(", ")", ".", "info", "(", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
sample_gaussian
Generate random samples from a Gaussian distribution. Parameters ---------- mean : array_like, shape (n_features,) Mean of the distribution. covar : array_like, optional Covariance of the distribution. The shape depends on `covariance_type`: scalar if 'spherical', ...
bhmm/_external/sklearn/mixture/gmm.py
def sample_gaussian(mean, covar, covariance_type='diag', n_samples=1, random_state=None): """Generate random samples from a Gaussian distribution. Parameters ---------- mean : array_like, shape (n_features,) Mean of the distribution. covar : array_like, optional ...
def sample_gaussian(mean, covar, covariance_type='diag', n_samples=1, random_state=None): """Generate random samples from a Gaussian distribution. Parameters ---------- mean : array_like, shape (n_features,) Mean of the distribution. covar : array_like, optional ...
[ "Generate", "random", "samples", "from", "a", "Gaussian", "distribution", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L63-L107
[ "def", "sample_gaussian", "(", "mean", ",", "covar", ",", "covariance_type", "=", "'diag'", ",", "n_samples", "=", "1", ",", "random_state", "=", "None", ")", ":", "rng", "=", "check_random_state", "(", "random_state", ")", "n_dim", "=", "len", "(", "mean"...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
_covar_mstep_diag
Performing the covariance M step for diagonal cases
bhmm/_external/sklearn/mixture/gmm.py
def _covar_mstep_diag(gmm, X, responsibilities, weighted_X_sum, norm, min_covar): """Performing the covariance M step for diagonal cases""" avg_X2 = np.dot(responsibilities.T, X * X) * norm avg_means2 = gmm.means_ ** 2 avg_X_means = gmm.means_ * weighted_X_sum * norm return avg...
def _covar_mstep_diag(gmm, X, responsibilities, weighted_X_sum, norm, min_covar): """Performing the covariance M step for diagonal cases""" avg_X2 = np.dot(responsibilities.T, X * X) * norm avg_means2 = gmm.means_ ** 2 avg_X_means = gmm.means_ * weighted_X_sum * norm return avg...
[ "Performing", "the", "covariance", "M", "step", "for", "diagonal", "cases" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L684-L690
[ "def", "_covar_mstep_diag", "(", "gmm", ",", "X", ",", "responsibilities", ",", "weighted_X_sum", ",", "norm", ",", "min_covar", ")", ":", "avg_X2", "=", "np", ".", "dot", "(", "responsibilities", ".", "T", ",", "X", "*", "X", ")", "*", "norm", "avg_me...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
_covar_mstep_spherical
Performing the covariance M step for spherical cases
bhmm/_external/sklearn/mixture/gmm.py
def _covar_mstep_spherical(*args): """Performing the covariance M step for spherical cases""" cv = _covar_mstep_diag(*args) return np.tile(cv.mean(axis=1)[:, np.newaxis], (1, cv.shape[1]))
def _covar_mstep_spherical(*args): """Performing the covariance M step for spherical cases""" cv = _covar_mstep_diag(*args) return np.tile(cv.mean(axis=1)[:, np.newaxis], (1, cv.shape[1]))
[ "Performing", "the", "covariance", "M", "step", "for", "spherical", "cases" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L693-L696
[ "def", "_covar_mstep_spherical", "(", "*", "args", ")", ":", "cv", "=", "_covar_mstep_diag", "(", "*", "args", ")", "return", "np", ".", "tile", "(", "cv", ".", "mean", "(", "axis", "=", "1", ")", "[", ":", ",", "np", ".", "newaxis", "]", ",", "(...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
_covar_mstep_full
Performing the covariance M step for full cases
bhmm/_external/sklearn/mixture/gmm.py
def _covar_mstep_full(gmm, X, responsibilities, weighted_X_sum, norm, min_covar): """Performing the covariance M step for full cases""" # Eq. 12 from K. Murphy, "Fitting a Conditional Linear Gaussian # Distribution" n_features = X.shape[1] cv = np.empty((gmm.n_components, n_fea...
def _covar_mstep_full(gmm, X, responsibilities, weighted_X_sum, norm, min_covar): """Performing the covariance M step for full cases""" # Eq. 12 from K. Murphy, "Fitting a Conditional Linear Gaussian # Distribution" n_features = X.shape[1] cv = np.empty((gmm.n_components, n_fea...
[ "Performing", "the", "covariance", "M", "step", "for", "full", "cases" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L699-L714
[ "def", "_covar_mstep_full", "(", "gmm", ",", "X", ",", "responsibilities", ",", "weighted_X_sum", ",", "norm", ",", "min_covar", ")", ":", "# Eq. 12 from K. Murphy, \"Fitting a Conditional Linear Gaussian", "# Distribution\"", "n_features", "=", "X", ".", "shape", "[", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM._get_covars
Covariance parameters for each mixture component. The shape depends on `cvtype`:: (`n_states`, 'n_features') if 'spherical', (`n_features`, `n_features`) if 'tied', (`n_states`, `n_features`) if 'diag', (`n_states`, `n_f...
bhmm/_external/sklearn/mixture/gmm.py
def _get_covars(self): """Covariance parameters for each mixture component. The shape depends on `cvtype`:: (`n_states`, 'n_features') if 'spherical', (`n_features`, `n_features`) if 'tied', (`n_states`, `n_features`) if 'di...
def _get_covars(self): """Covariance parameters for each mixture component. The shape depends on `cvtype`:: (`n_states`, 'n_features') if 'spherical', (`n_features`, `n_features`) if 'tied', (`n_states`, `n_features`) if 'di...
[ "Covariance", "parameters", "for", "each", "mixture", "component", ".", "The", "shape", "depends", "on", "cvtype", "::" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L261-L277
[ "def", "_get_covars", "(", "self", ")", ":", "if", "self", ".", "covariance_type", "==", "'full'", ":", "return", "self", ".", "covars_", "elif", "self", ".", "covariance_type", "==", "'diag'", ":", "return", "[", "np", ".", "diag", "(", "cov", ")", "f...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM._set_covars
Provide values for covariance
bhmm/_external/sklearn/mixture/gmm.py
def _set_covars(self, covars): """Provide values for covariance""" covars = np.asarray(covars) _validate_covars(covars, self.covariance_type, self.n_components) self.covars_ = covars
def _set_covars(self, covars): """Provide values for covariance""" covars = np.asarray(covars) _validate_covars(covars, self.covariance_type, self.n_components) self.covars_ = covars
[ "Provide", "values", "for", "covariance" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L279-L283
[ "def", "_set_covars", "(", "self", ",", "covars", ")", ":", "covars", "=", "np", ".", "asarray", "(", "covars", ")", "_validate_covars", "(", "covars", ",", "self", ".", "covariance_type", ",", "self", ".", "n_components", ")", "self", ".", "covars_", "=...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM.score_samples
Return the per-sample likelihood of the data under the model. Compute the log probability of X under the model and return the posterior distribution (responsibilities) of each mixture component for each element of X. Parameters ---------- X: array_like, shape (n_samples...
bhmm/_external/sklearn/mixture/gmm.py
def score_samples(self, X): """Return the per-sample likelihood of the data under the model. Compute the log probability of X under the model and return the posterior distribution (responsibilities) of each mixture component for each element of X. Parameters ---------- ...
def score_samples(self, X): """Return the per-sample likelihood of the data under the model. Compute the log probability of X under the model and return the posterior distribution (responsibilities) of each mixture component for each element of X. Parameters ---------- ...
[ "Return", "the", "per", "-", "sample", "likelihood", "of", "the", "data", "under", "the", "model", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L285-L322
[ "def", "score_samples", "(", "self", ",", "X", ")", ":", "check_is_fitted", "(", "self", ",", "'means_'", ")", "X", "=", "check_array", "(", "X", ")", "if", "X", ".", "ndim", "==", "1", ":", "X", "=", "X", "[", ":", ",", "np", ".", "newaxis", "...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM.score
Compute the log probability under the model. Parameters ---------- X : array_like, shape (n_samples, n_features) List of n_features-dimensional data points. Each row corresponds to a single data point. Returns ------- logprob : array_like, shape...
bhmm/_external/sklearn/mixture/gmm.py
def score(self, X, y=None): """Compute the log probability under the model. Parameters ---------- X : array_like, shape (n_samples, n_features) List of n_features-dimensional data points. Each row corresponds to a single data point. Returns ----...
def score(self, X, y=None): """Compute the log probability under the model. Parameters ---------- X : array_like, shape (n_samples, n_features) List of n_features-dimensional data points. Each row corresponds to a single data point. Returns ----...
[ "Compute", "the", "log", "probability", "under", "the", "model", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L324-L339
[ "def", "score", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "logprob", ",", "_", "=", "self", ".", "score_samples", "(", "X", ")", "return", "logprob" ]
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM.predict
Predict label for data. Parameters ---------- X : array-like, shape = [n_samples, n_features] Returns ------- C : array, shape = (n_samples,)
bhmm/_external/sklearn/mixture/gmm.py
def predict(self, X): """Predict label for data. Parameters ---------- X : array-like, shape = [n_samples, n_features] Returns ------- C : array, shape = (n_samples,) """ logprob, responsibilities = self.score_samples(X) return responsibi...
def predict(self, X): """Predict label for data. Parameters ---------- X : array-like, shape = [n_samples, n_features] Returns ------- C : array, shape = (n_samples,) """ logprob, responsibilities = self.score_samples(X) return responsibi...
[ "Predict", "label", "for", "data", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L341-L353
[ "def", "predict", "(", "self", ",", "X", ")", ":", "logprob", ",", "responsibilities", "=", "self", ".", "score_samples", "(", "X", ")", "return", "responsibilities", ".", "argmax", "(", "axis", "=", "1", ")" ]
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM.sample
Generate random samples from the model. Parameters ---------- n_samples : int, optional Number of samples to generate. Defaults to 1. Returns ------- X : array_like, shape (n_samples, n_features) List of samples
bhmm/_external/sklearn/mixture/gmm.py
def sample(self, n_samples=1, random_state=None): """Generate random samples from the model. Parameters ---------- n_samples : int, optional Number of samples to generate. Defaults to 1. Returns ------- X : array_like, shape (n_samples, n_features) ...
def sample(self, n_samples=1, random_state=None): """Generate random samples from the model. Parameters ---------- n_samples : int, optional Number of samples to generate. Defaults to 1. Returns ------- X : array_like, shape (n_samples, n_features) ...
[ "Generate", "random", "samples", "from", "the", "model", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L372-L412
[ "def", "sample", "(", "self", ",", "n_samples", "=", "1", ",", "random_state", "=", "None", ")", ":", "check_is_fitted", "(", "self", ",", "'means_'", ")", "if", "random_state", "is", "None", ":", "random_state", "=", "self", ".", "random_state", "random_s...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM.fit
Estimate model parameters with the expectation-maximization algorithm. A initialization step is performed before entering the em algorithm. If you want to avoid this step, set the keyword argument init_params to the empty string '' when creating the GMM object. Likewise, if you ...
bhmm/_external/sklearn/mixture/gmm.py
def fit(self, X, y=None): """Estimate model parameters with the expectation-maximization algorithm. A initialization step is performed before entering the em algorithm. If you want to avoid this step, set the keyword argument init_params to the empty string '' when creating the ...
def fit(self, X, y=None): """Estimate model parameters with the expectation-maximization algorithm. A initialization step is performed before entering the em algorithm. If you want to avoid this step, set the keyword argument init_params to the empty string '' when creating the ...
[ "Estimate", "model", "parameters", "with", "the", "expectation", "-", "maximization", "algorithm", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L414-L509
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "# initialization step", "X", "=", "check_array", "(", "X", ",", "dtype", "=", "np", ".", "float64", ")", "if", "X", ".", "shape", "[", "0", "]", "<", "self", ".", "n_component...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM._do_mstep
Perform the Mstep of the EM algorithm and return the class weihgts.
bhmm/_external/sklearn/mixture/gmm.py
def _do_mstep(self, X, responsibilities, params, min_covar=0): """ Perform the Mstep of the EM algorithm and return the class weihgts. """ weights = responsibilities.sum(axis=0) weighted_X_sum = np.dot(responsibilities.T, X) inverse_weights = 1.0 / (weights[:, np.newaxis] + 10 * ...
def _do_mstep(self, X, responsibilities, params, min_covar=0): """ Perform the Mstep of the EM algorithm and return the class weihgts. """ weights = responsibilities.sum(axis=0) weighted_X_sum = np.dot(responsibilities.T, X) inverse_weights = 1.0 / (weights[:, np.newaxis] + 10 * ...
[ "Perform", "the", "Mstep", "of", "the", "EM", "algorithm", "and", "return", "the", "class", "weihgts", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L511-L527
[ "def", "_do_mstep", "(", "self", ",", "X", ",", "responsibilities", ",", "params", ",", "min_covar", "=", "0", ")", ":", "weights", "=", "responsibilities", ".", "sum", "(", "axis", "=", "0", ")", "weighted_X_sum", "=", "np", ".", "dot", "(", "responsi...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM._n_parameters
Return the number of free parameters in the model.
bhmm/_external/sklearn/mixture/gmm.py
def _n_parameters(self): """Return the number of free parameters in the model.""" ndim = self.means_.shape[1] if self.covariance_type == 'full': cov_params = self.n_components * ndim * (ndim + 1) / 2. elif self.covariance_type == 'diag': cov_params = self.n_compon...
def _n_parameters(self): """Return the number of free parameters in the model.""" ndim = self.means_.shape[1] if self.covariance_type == 'full': cov_params = self.n_components * ndim * (ndim + 1) / 2. elif self.covariance_type == 'diag': cov_params = self.n_compon...
[ "Return", "the", "number", "of", "free", "parameters", "in", "the", "model", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L529-L541
[ "def", "_n_parameters", "(", "self", ")", ":", "ndim", "=", "self", ".", "means_", ".", "shape", "[", "1", "]", "if", "self", ".", "covariance_type", "==", "'full'", ":", "cov_params", "=", "self", ".", "n_components", "*", "ndim", "*", "(", "ndim", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GMM.bic
Bayesian information criterion for the current model fit and the proposed data Parameters ---------- X : array of shape(n_samples, n_dimensions) Returns ------- bic: float (the lower the better)
bhmm/_external/sklearn/mixture/gmm.py
def bic(self, X): """Bayesian information criterion for the current model fit and the proposed data Parameters ---------- X : array of shape(n_samples, n_dimensions) Returns ------- bic: float (the lower the better) """ return (-2 * self....
def bic(self, X): """Bayesian information criterion for the current model fit and the proposed data Parameters ---------- X : array of shape(n_samples, n_dimensions) Returns ------- bic: float (the lower the better) """ return (-2 * self....
[ "Bayesian", "information", "criterion", "for", "the", "current", "model", "fit", "and", "the", "proposed", "data" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/mixture/gmm.py#L543-L556
[ "def", "bic", "(", "self", ",", "X", ")", ":", "return", "(", "-", "2", "*", "self", ".", "score", "(", "X", ")", ".", "sum", "(", ")", "+", "self", ".", "_n_parameters", "(", ")", "*", "np", ".", "log", "(", "X", ".", "shape", "[", "0", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
BaseEstimator._get_param_names
Get parameter names for the estimator
bhmm/_external/sklearn/base.py
def _get_param_names(cls): """Get parameter names for the estimator""" # fetch the constructor or the original constructor before # deprecation wrapping if any init = getattr(cls.__init__, 'deprecated_original', cls.__init__) if init is object.__init__: # No explicit ...
def _get_param_names(cls): """Get parameter names for the estimator""" # fetch the constructor or the original constructor before # deprecation wrapping if any init = getattr(cls.__init__, 'deprecated_original', cls.__init__) if init is object.__init__: # No explicit ...
[ "Get", "parameter", "names", "for", "the", "estimator" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/base.py#L67-L90
[ "def", "_get_param_names", "(", "cls", ")", ":", "# fetch the constructor or the original constructor before", "# deprecation wrapping if any", "init", "=", "getattr", "(", "cls", ".", "__init__", ",", "'deprecated_original'", ",", "cls", ".", "__init__", ")", "if", "in...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
BaseEstimator.set_params
Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form ``<component>__<parameter>`` so that it's possible to update each component of a nested object. Returns -...
bhmm/_external/sklearn/base.py
def set_params(self, **params): """Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form ``<component>__<parameter>`` so that it's possible to update each component of ...
def set_params(self, **params): """Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form ``<component>__<parameter>`` so that it's possible to update each component of ...
[ "Set", "the", "parameters", "of", "this", "estimator", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/base.py#L129-L161
[ "def", "set_params", "(", "self", ",", "*", "*", "params", ")", ":", "if", "not", "params", ":", "# Simple optimisation to gain speed (inspect is slow)", "return", "self", "valid_params", "=", "self", ".", "get_params", "(", "deep", "=", "True", ")", "for", "k...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
init_model_gaussian1d
Generate an initial model with 1D-Gaussian output densities Parameters ---------- observations : list of ndarray((T_i), dtype=float) list of arrays of length T_i with observation data nstates : int The number of states. Examples -------- Generate initial model for a gaussi...
bhmm/init/gaussian.py
def init_model_gaussian1d(observations, nstates, reversible=True): """Generate an initial model with 1D-Gaussian output densities Parameters ---------- observations : list of ndarray((T_i), dtype=float) list of arrays of length T_i with observation data nstates : int The number of s...
def init_model_gaussian1d(observations, nstates, reversible=True): """Generate an initial model with 1D-Gaussian output densities Parameters ---------- observations : list of ndarray((T_i), dtype=float) list of arrays of length T_i with observation data nstates : int The number of s...
[ "Generate", "an", "initial", "model", "with", "1D", "-", "Gaussian", "output", "densities" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/init/gaussian.py#L26-L92
[ "def", "init_model_gaussian1d", "(", "observations", ",", "nstates", ",", "reversible", "=", "True", ")", ":", "ntrajectories", "=", "len", "(", "observations", ")", "# Concatenate all observations.", "collected_observations", "=", "np", ".", "array", "(", "[", "]...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GaussianOutputModel._p_o
Returns the output probability for symbol o from all hidden states Parameters ---------- o : float A single observation. Return ------ p_o : ndarray (N) p_o[i] is the probability density of the observation o from state i emission distribution ...
bhmm/output_models/gaussian.py
def _p_o(self, o): """ Returns the output probability for symbol o from all hidden states Parameters ---------- o : float A single observation. Return ------ p_o : ndarray (N) p_o[i] is the probability density of the observation o...
def _p_o(self, o): """ Returns the output probability for symbol o from all hidden states Parameters ---------- o : float A single observation. Return ------ p_o : ndarray (N) p_o[i] is the probability density of the observation o...
[ "Returns", "the", "output", "probability", "for", "symbol", "o", "from", "all", "hidden", "states" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/gaussian.py#L132-L168
[ "def", "_p_o", "(", "self", ",", "o", ")", ":", "if", "self", ".", "__impl__", "==", "self", ".", "__IMPL_C__", ":", "return", "gc", ".", "p_o", "(", "o", ",", "self", ".", "means", ",", "self", ".", "sigmas", ",", "out", "=", "None", ",", "dty...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GaussianOutputModel.p_obs
Returns the output probabilities for an entire trajectory and all hidden states Parameters ---------- oobs : ndarray((T), dtype=int) a discrete trajectory of length T Return ------ p_o : ndarray (T,N) the probability of generating the symbol at t...
bhmm/output_models/gaussian.py
def p_obs(self, obs, out=None): """ Returns the output probabilities for an entire trajectory and all hidden states Parameters ---------- oobs : ndarray((T), dtype=int) a discrete trajectory of length T Return ------ p_o : ndarray (T,N) ...
def p_obs(self, obs, out=None): """ Returns the output probabilities for an entire trajectory and all hidden states Parameters ---------- oobs : ndarray((T), dtype=int) a discrete trajectory of length T Return ------ p_o : ndarray (T,N) ...
[ "Returns", "the", "output", "probabilities", "for", "an", "entire", "trajectory", "and", "all", "hidden", "states" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/gaussian.py#L170-L212
[ "def", "p_obs", "(", "self", ",", "obs", ",", "out", "=", "None", ")", ":", "if", "self", ".", "__impl__", "==", "self", ".", "__IMPL_C__", ":", "res", "=", "gc", ".", "p_obs", "(", "obs", ",", "self", ".", "means", ",", "self", ".", "sigmas", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GaussianOutputModel.estimate
Fits the output model given the observations and weights Parameters ---------- observations : [ ndarray(T_k,) ] with K elements A list of K observation trajectories, each having length T_k and d dimensions weights : [ ndarray(T_k,nstates) ] with K elements A list...
bhmm/output_models/gaussian.py
def estimate(self, observations, weights): """ Fits the output model given the observations and weights Parameters ---------- observations : [ ndarray(T_k,) ] with K elements A list of K observation trajectories, each having length T_k and d dimensions weight...
def estimate(self, observations, weights): """ Fits the output model given the observations and weights Parameters ---------- observations : [ ndarray(T_k,) ] with K elements A list of K observation trajectories, each having length T_k and d dimensions weight...
[ "Fits", "the", "output", "model", "given", "the", "observations", "and", "weights" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/gaussian.py#L214-L272
[ "def", "estimate", "(", "self", ",", "observations", ",", "weights", ")", ":", "# sizes", "N", "=", "self", ".", "nstates", "K", "=", "len", "(", "observations", ")", "# fit means", "self", ".", "_means", "=", "np", ".", "zeros", "(", "N", ")", "w_su...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GaussianOutputModel.sample
Sample a new set of distribution parameters given a sample of observations from the given state. Both the internal parameters and the attached HMM model are updated. Parameters ---------- observations : [ numpy.array with shape (N_k,) ] with `nstates` elements observations...
bhmm/output_models/gaussian.py
def sample(self, observations, prior=None): """ Sample a new set of distribution parameters given a sample of observations from the given state. Both the internal parameters and the attached HMM model are updated. Parameters ---------- observations : [ numpy.array with...
def sample(self, observations, prior=None): """ Sample a new set of distribution parameters given a sample of observations from the given state. Both the internal parameters and the attached HMM model are updated. Parameters ---------- observations : [ numpy.array with...
[ "Sample", "a", "new", "set", "of", "distribution", "parameters", "given", "a", "sample", "of", "observations", "from", "the", "given", "state", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/gaussian.py#L274-L320
[ "def", "sample", "(", "self", ",", "observations", ",", "prior", "=", "None", ")", ":", "for", "state_index", "in", "range", "(", "self", ".", "nstates", ")", ":", "# Update state emission distribution parameters.", "observations_in_state", "=", "observations", "[...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GaussianOutputModel.generate_observation_from_state
Generate a single synthetic observation data from a given state. Parameters ---------- state_index : int Index of the state from which observations are to be generated. Returns ------- observation : float A single observation from the given state...
bhmm/output_models/gaussian.py
def generate_observation_from_state(self, state_index): """ Generate a single synthetic observation data from a given state. Parameters ---------- state_index : int Index of the state from which observations are to be generated. Returns ------- ...
def generate_observation_from_state(self, state_index): """ Generate a single synthetic observation data from a given state. Parameters ---------- state_index : int Index of the state from which observations are to be generated. Returns ------- ...
[ "Generate", "a", "single", "synthetic", "observation", "data", "from", "a", "given", "state", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/gaussian.py#L322-L349
[ "def", "generate_observation_from_state", "(", "self", ",", "state_index", ")", ":", "observation", "=", "self", ".", "sigmas", "[", "state_index", "]", "*", "np", ".", "random", ".", "randn", "(", ")", "+", "self", ".", "means", "[", "state_index", "]", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GaussianOutputModel.generate_observations_from_state
Generate synthetic observation data from a given state. Parameters ---------- state_index : int Index of the state from which observations are to be generated. nobs : int The number of observations to generate. Returns ------- observation...
bhmm/output_models/gaussian.py
def generate_observations_from_state(self, state_index, nobs): """ Generate synthetic observation data from a given state. Parameters ---------- state_index : int Index of the state from which observations are to be generated. nobs : int The numbe...
def generate_observations_from_state(self, state_index, nobs): """ Generate synthetic observation data from a given state. Parameters ---------- state_index : int Index of the state from which observations are to be generated. nobs : int The numbe...
[ "Generate", "synthetic", "observation", "data", "from", "a", "given", "state", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/gaussian.py#L351-L380
[ "def", "generate_observations_from_state", "(", "self", ",", "state_index", ",", "nobs", ")", ":", "observations", "=", "self", ".", "sigmas", "[", "state_index", "]", "*", "np", ".", "random", ".", "randn", "(", "nobs", ")", "+", "self", ".", "means", "...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
GaussianOutputModel.generate_observation_trajectory
Generate synthetic observation data from a given state sequence. Parameters ---------- s_t : numpy.array with shape (T,) of int type s_t[t] is the hidden state sampled at time t Returns ------- o_t : numpy.array with shape (T,) of type dtype o_t[...
bhmm/output_models/gaussian.py
def generate_observation_trajectory(self, s_t): """ Generate synthetic observation data from a given state sequence. Parameters ---------- s_t : numpy.array with shape (T,) of int type s_t[t] is the hidden state sampled at time t Returns ------- ...
def generate_observation_trajectory(self, s_t): """ Generate synthetic observation data from a given state sequence. Parameters ---------- s_t : numpy.array with shape (T,) of int type s_t[t] is the hidden state sampled at time t Returns ------- ...
[ "Generate", "synthetic", "observation", "data", "from", "a", "given", "state", "sequence", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/gaussian.py#L382-L418
[ "def", "generate_observation_trajectory", "(", "self", ",", "s_t", ")", ":", "# Determine number of samples to generate.", "T", "=", "s_t", ".", "shape", "[", "0", "]", "o_t", "=", "np", ".", "zeros", "(", "[", "T", "]", ",", "dtype", "=", "config", ".", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
SampledHMM.initial_distribution_samples
r""" Samples of the initial distribution
bhmm/hmm/generic_sampled_hmm.py
def initial_distribution_samples(self): r""" Samples of the initial distribution """ res = np.empty((self.nsamples, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :] = self._sampled_hmms[i].stationary_distribution return res
def initial_distribution_samples(self): r""" Samples of the initial distribution """ res = np.empty((self.nsamples, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :] = self._sampled_hmms[i].stationary_distribution return res
[ "r", "Samples", "of", "the", "initial", "distribution" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_sampled_hmm.py#L70-L75
[ "def", "initial_distribution_samples", "(", "self", ")", ":", "res", "=", "np", ".", "empty", "(", "(", "self", ".", "nsamples", ",", "self", ".", "nstates", ")", ",", "dtype", "=", "config", ".", "dtype", ")", "for", "i", "in", "range", "(", "self",...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
SampledHMM.transition_matrix_samples
r""" Samples of the transition matrix
bhmm/hmm/generic_sampled_hmm.py
def transition_matrix_samples(self): r""" Samples of the transition matrix """ res = np.empty((self.nsamples, self.nstates, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :, :] = self._sampled_hmms[i].transition_matrix return res
def transition_matrix_samples(self): r""" Samples of the transition matrix """ res = np.empty((self.nsamples, self.nstates, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :, :] = self._sampled_hmms[i].transition_matrix return res
[ "r", "Samples", "of", "the", "transition", "matrix" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_sampled_hmm.py#L116-L121
[ "def", "transition_matrix_samples", "(", "self", ")", ":", "res", "=", "np", ".", "empty", "(", "(", "self", ".", "nsamples", ",", "self", ".", "nstates", ",", "self", ".", "nstates", ")", ",", "dtype", "=", "config", ".", "dtype", ")", "for", "i", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
SampledHMM.eigenvalues_samples
r""" Samples of the eigenvalues
bhmm/hmm/generic_sampled_hmm.py
def eigenvalues_samples(self): r""" Samples of the eigenvalues """ res = np.empty((self.nsamples, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :] = self._sampled_hmms[i].eigenvalues return res
def eigenvalues_samples(self): r""" Samples of the eigenvalues """ res = np.empty((self.nsamples, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :] = self._sampled_hmms[i].eigenvalues return res
[ "r", "Samples", "of", "the", "eigenvalues" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_sampled_hmm.py#L139-L144
[ "def", "eigenvalues_samples", "(", "self", ")", ":", "res", "=", "np", ".", "empty", "(", "(", "self", ".", "nsamples", ",", "self", ".", "nstates", ")", ",", "dtype", "=", "config", ".", "dtype", ")", "for", "i", "in", "range", "(", "self", ".", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
SampledHMM.eigenvectors_left_samples
r""" Samples of the left eigenvectors of the hidden transition matrix
bhmm/hmm/generic_sampled_hmm.py
def eigenvectors_left_samples(self): r""" Samples of the left eigenvectors of the hidden transition matrix """ res = np.empty((self.nsamples, self.nstates, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :, :] = self._sampled_hmms[i].eigenvectors_left ...
def eigenvectors_left_samples(self): r""" Samples of the left eigenvectors of the hidden transition matrix """ res = np.empty((self.nsamples, self.nstates, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :, :] = self._sampled_hmms[i].eigenvectors_left ...
[ "r", "Samples", "of", "the", "left", "eigenvectors", "of", "the", "hidden", "transition", "matrix" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_sampled_hmm.py#L162-L167
[ "def", "eigenvectors_left_samples", "(", "self", ")", ":", "res", "=", "np", ".", "empty", "(", "(", "self", ".", "nsamples", ",", "self", ".", "nstates", ",", "self", ".", "nstates", ")", ",", "dtype", "=", "config", ".", "dtype", ")", "for", "i", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
SampledHMM.eigenvectors_right_samples
r""" Samples of the right eigenvectors of the hidden transition matrix
bhmm/hmm/generic_sampled_hmm.py
def eigenvectors_right_samples(self): r""" Samples of the right eigenvectors of the hidden transition matrix """ res = np.empty((self.nsamples, self.nstates, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :, :] = self._sampled_hmms[i].eigenvectors_right ...
def eigenvectors_right_samples(self): r""" Samples of the right eigenvectors of the hidden transition matrix """ res = np.empty((self.nsamples, self.nstates, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :, :] = self._sampled_hmms[i].eigenvectors_right ...
[ "r", "Samples", "of", "the", "right", "eigenvectors", "of", "the", "hidden", "transition", "matrix" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_sampled_hmm.py#L185-L190
[ "def", "eigenvectors_right_samples", "(", "self", ")", ":", "res", "=", "np", ".", "empty", "(", "(", "self", ".", "nsamples", ",", "self", ".", "nstates", ",", "self", ".", "nstates", ")", ",", "dtype", "=", "config", ".", "dtype", ")", "for", "i", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
SampledHMM.timescales_samples
r""" Samples of the timescales
bhmm/hmm/generic_sampled_hmm.py
def timescales_samples(self): r""" Samples of the timescales """ res = np.empty((self.nsamples, self.nstates-1), dtype=config.dtype) for i in range(self.nsamples): res[i, :] = self._sampled_hmms[i].timescales return res
def timescales_samples(self): r""" Samples of the timescales """ res = np.empty((self.nsamples, self.nstates-1), dtype=config.dtype) for i in range(self.nsamples): res[i, :] = self._sampled_hmms[i].timescales return res
[ "r", "Samples", "of", "the", "timescales" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_sampled_hmm.py#L208-L213
[ "def", "timescales_samples", "(", "self", ")", ":", "res", "=", "np", ".", "empty", "(", "(", "self", ".", "nsamples", ",", "self", ".", "nstates", "-", "1", ")", ",", "dtype", "=", "config", ".", "dtype", ")", "for", "i", "in", "range", "(", "se...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
SampledHMM.lifetimes_samples
r""" Samples of the timescales
bhmm/hmm/generic_sampled_hmm.py
def lifetimes_samples(self): r""" Samples of the timescales """ res = np.empty((self.nsamples, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :] = self._sampled_hmms[i].lifetimes return res
def lifetimes_samples(self): r""" Samples of the timescales """ res = np.empty((self.nsamples, self.nstates), dtype=config.dtype) for i in range(self.nsamples): res[i, :] = self._sampled_hmms[i].lifetimes return res
[ "r", "Samples", "of", "the", "timescales" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_sampled_hmm.py#L231-L236
[ "def", "lifetimes_samples", "(", "self", ")", ":", "res", "=", "np", ".", "empty", "(", "(", "self", ".", "nsamples", ",", "self", ".", "nstates", ")", ",", "dtype", "=", "config", ".", "dtype", ")", "for", "i", "in", "range", "(", "self", ".", "...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
OutputModel.set_implementation
Sets the implementation of this module Parameters ---------- impl : str One of ["python", "c"]
bhmm/output_models/outputmodel.py
def set_implementation(self, impl): """ Sets the implementation of this module Parameters ---------- impl : str One of ["python", "c"] """ if impl.lower() == 'python': self.__impl__ = self.__IMPL_PYTHON__ elif impl.lower() == 'c':...
def set_implementation(self, impl): """ Sets the implementation of this module Parameters ---------- impl : str One of ["python", "c"] """ if impl.lower() == 'python': self.__impl__ = self.__IMPL_PYTHON__ elif impl.lower() == 'c':...
[ "Sets", "the", "implementation", "of", "this", "module" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/outputmodel.py#L69-L86
[ "def", "set_implementation", "(", "self", ",", "impl", ")", ":", "if", "impl", ".", "lower", "(", ")", "==", "'python'", ":", "self", ".", "__impl__", "=", "self", ".", "__IMPL_PYTHON__", "elif", "impl", ".", "lower", "(", ")", "==", "'c'", ":", "sel...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
OutputModel.log_p_obs
Returns the element-wise logarithm of the output probabilities for an entire trajectory and all hidden states This is a default implementation that will take the log of p_obs(obs) and should only be used if p_obs(obs) is numerically stable. If there is any danger of running into numerical problems *dur...
bhmm/output_models/outputmodel.py
def log_p_obs(self, obs, out=None, dtype=np.float32): """ Returns the element-wise logarithm of the output probabilities for an entire trajectory and all hidden states This is a default implementation that will take the log of p_obs(obs) and should only be used if p_obs(obs) is numerica...
def log_p_obs(self, obs, out=None, dtype=np.float32): """ Returns the element-wise logarithm of the output probabilities for an entire trajectory and all hidden states This is a default implementation that will take the log of p_obs(obs) and should only be used if p_obs(obs) is numerica...
[ "Returns", "the", "element", "-", "wise", "logarithm", "of", "the", "output", "probabilities", "for", "an", "entire", "trajectory", "and", "all", "hidden", "states" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/outputmodel.py#L93-L117
[ "def", "log_p_obs", "(", "self", ",", "obs", ",", "out", "=", "None", ",", "dtype", "=", "np", ".", "float32", ")", ":", "if", "out", "is", "None", ":", "return", "np", ".", "log", "(", "self", ".", "p_obs", "(", "obs", ")", ")", "else", ":", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
OutputModel._handle_outliers
Sets observation probabilities of outliers to uniform if ignore_outliers is set. Parameters ---------- p_o : ndarray((T, N)) output probabilities
bhmm/output_models/outputmodel.py
def _handle_outliers(self, p_o): """ Sets observation probabilities of outliers to uniform if ignore_outliers is set. Parameters ---------- p_o : ndarray((T, N)) output probabilities """ if self.ignore_outliers: outliers = np.where(p_o.sum(axis=1)=...
def _handle_outliers(self, p_o): """ Sets observation probabilities of outliers to uniform if ignore_outliers is set. Parameters ---------- p_o : ndarray((T, N)) output probabilities """ if self.ignore_outliers: outliers = np.where(p_o.sum(axis=1)=...
[ "Sets", "observation", "probabilities", "of", "outliers", "to", "uniform", "if", "ignore_outliers", "is", "set", ".", "Parameters", "----------", "p_o", ":", "ndarray", "((", "T", "N", "))", "output", "probabilities" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/output_models/outputmodel.py#L119-L131
[ "def", "_handle_outliers", "(", "self", ",", "p_o", ")", ":", "if", "self", ".", "ignore_outliers", ":", "outliers", "=", "np", ".", "where", "(", "p_o", ".", "sum", "(", "axis", "=", "1", ")", "==", "0", ")", "[", "0", "]", "if", "outliers", "."...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
forward
Compute P( obs | A, B, pi ) and all forward coefficients. Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the observation probability for observation at time t given hidden state i pi : ...
bhmm/hidden/impl_python/hidden.py
def forward(A, pobs, pi, T=None, alpha_out=None, dtype=np.float32): """Compute P( obs | A, B, pi ) and all forward coefficients. Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the obser...
def forward(A, pobs, pi, T=None, alpha_out=None, dtype=np.float32): """Compute P( obs | A, B, pi ) and all forward coefficients. Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the obser...
[ "Compute", "P", "(", "obs", "|", "A", "B", "pi", ")", "and", "all", "forward", "coefficients", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hidden/impl_python/hidden.py#L33-L96
[ "def", "forward", "(", "A", ",", "pobs", ",", "pi", ",", "T", "=", "None", ",", "alpha_out", "=", "None", ",", "dtype", "=", "np", ".", "float32", ")", ":", "# set T", "if", "T", "is", "None", ":", "T", "=", "pobs", ".", "shape", "[", "0", "]...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
backward
Compute all backward coefficients. With scaling! Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the observation probability for observation at time t given hidden state i beta_out : nda...
bhmm/hidden/impl_python/hidden.py
def backward(A, pobs, T=None, beta_out=None, dtype=np.float32): """Compute all backward coefficients. With scaling! Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the observation probab...
def backward(A, pobs, T=None, beta_out=None, dtype=np.float32): """Compute all backward coefficients. With scaling! Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the observation probab...
[ "Compute", "all", "backward", "coefficients", ".", "With", "scaling!" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hidden/impl_python/hidden.py#L99-L148
[ "def", "backward", "(", "A", ",", "pobs", ",", "T", "=", "None", ",", "beta_out", "=", "None", ",", "dtype", "=", "np", ".", "float32", ")", ":", "# set T", "if", "T", "is", "None", ":", "T", "=", "pobs", ".", "shape", "[", "0", "]", "# if not ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
transition_counts
Sum for all t the probability to transition from state i to state j. Parameters ---------- alpha : ndarray((T,N), dtype = float), optional, default = None alpha[t,i] is the ith forward coefficient of time t. beta : ndarray((T,N), dtype = float), optional, default = None beta[t,i] is the...
bhmm/hidden/impl_python/hidden.py
def transition_counts(alpha, beta, A, pobs, T=None, out=None, dtype=np.float32): """ Sum for all t the probability to transition from state i to state j. Parameters ---------- alpha : ndarray((T,N), dtype = float), optional, default = None alpha[t,i] is the ith forward coefficient of time t. ...
def transition_counts(alpha, beta, A, pobs, T=None, out=None, dtype=np.float32): """ Sum for all t the probability to transition from state i to state j. Parameters ---------- alpha : ndarray((T,N), dtype = float), optional, default = None alpha[t,i] is the ith forward coefficient of time t. ...
[ "Sum", "for", "all", "t", "the", "probability", "to", "transition", "from", "state", "i", "to", "state", "j", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hidden/impl_python/hidden.py#L151-L204
[ "def", "transition_counts", "(", "alpha", ",", "beta", ",", "A", ",", "pobs", ",", "T", "=", "None", ",", "out", "=", "None", ",", "dtype", "=", "np", ".", "float32", ")", ":", "# set T", "if", "T", "is", "None", ":", "T", "=", "pobs", ".", "sh...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
viterbi
Estimate the hidden pathway of maximum likelihood using the Viterbi algorithm. Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the observation probability for observation at time t given hid...
bhmm/hidden/impl_python/hidden.py
def viterbi(A, pobs, pi, dtype=np.float32): """ Estimate the hidden pathway of maximum likelihood using the Viterbi algorithm. Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the observa...
def viterbi(A, pobs, pi, dtype=np.float32): """ Estimate the hidden pathway of maximum likelihood using the Viterbi algorithm. Parameters ---------- A : ndarray((N,N), dtype = float) transition matrix of the hidden states pobs : ndarray((T,N), dtype = float) pobs[t,i] is the observa...
[ "Estimate", "the", "hidden", "pathway", "of", "maximum", "likelihood", "using", "the", "Viterbi", "algorithm", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hidden/impl_python/hidden.py#L207-L247
[ "def", "viterbi", "(", "A", ",", "pobs", ",", "pi", ",", "dtype", "=", "np", ".", "float32", ")", ":", "T", ",", "N", "=", "pobs", ".", "shape", "[", "0", "]", ",", "pobs", ".", "shape", "[", "1", "]", "# temporary viterbi state", "psi", "=", "...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
sample_path
alpha : ndarray((T,N), dtype = float), optional, default = None alpha[t,i] is the ith forward coefficient of time t. beta : ndarray((T,N), dtype = float), optional, default = None beta[t,i] is the ith forward coefficient of time t. A : ndarray((N,N), dtype = float) transition matrix of t...
bhmm/hidden/impl_python/hidden.py
def sample_path(alpha, A, pobs, T=None, dtype=np.float32): """ alpha : ndarray((T,N), dtype = float), optional, default = None alpha[t,i] is the ith forward coefficient of time t. beta : ndarray((T,N), dtype = float), optional, default = None beta[t,i] is the ith forward coefficient of time ...
def sample_path(alpha, A, pobs, T=None, dtype=np.float32): """ alpha : ndarray((T,N), dtype = float), optional, default = None alpha[t,i] is the ith forward coefficient of time t. beta : ndarray((T,N), dtype = float), optional, default = None beta[t,i] is the ith forward coefficient of time ...
[ "alpha", ":", "ndarray", "((", "T", "N", ")", "dtype", "=", "float", ")", "optional", "default", "=", "None", "alpha", "[", "t", "i", "]", "is", "the", "ith", "forward", "coefficient", "of", "time", "t", ".", "beta", ":", "ndarray", "((", "T", "N",...
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hidden/impl_python/hidden.py#L250-L285
[ "def", "sample_path", "(", "alpha", ",", "A", ",", "pobs", ",", "T", "=", "None", ",", "dtype", "=", "np", ".", "float32", ")", ":", "N", "=", "pobs", ".", "shape", "[", "1", "]", "# set T", "if", "T", "is", "None", ":", "T", "=", "pobs", "."...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
coarse_grain_transition_matrix
Coarse grain transition matrix P using memberships M Computes .. math: Pc = (M' M)^-1 M' P M Parameters ---------- P : ndarray(n, n) microstate transition matrix M : ndarray(n, m) membership matrix. Membership to macrostate m for each microstate. Returns -----...
bhmm/init/discrete.py
def coarse_grain_transition_matrix(P, M): """ Coarse grain transition matrix P using memberships M Computes .. math: Pc = (M' M)^-1 M' P M Parameters ---------- P : ndarray(n, n) microstate transition matrix M : ndarray(n, m) membership matrix. Membership to macros...
def coarse_grain_transition_matrix(P, M): """ Coarse grain transition matrix P using memberships M Computes .. math: Pc = (M' M)^-1 M' P M Parameters ---------- P : ndarray(n, n) microstate transition matrix M : ndarray(n, m) membership matrix. Membership to macros...
[ "Coarse", "grain", "transition", "matrix", "P", "using", "memberships", "M" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/init/discrete.py#L26-L57
[ "def", "coarse_grain_transition_matrix", "(", "P", ",", "M", ")", ":", "# coarse-grain matrix: Pc = (M' M)^-1 M' P M", "W", "=", "np", ".", "linalg", ".", "inv", "(", "np", ".", "dot", "(", "M", ".", "T", ",", "M", ")", ")", "A", "=", "np", ".", "dot",...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
regularize_hidden
Regularizes the hidden initial distribution and transition matrix. Makes sure that the hidden initial distribution and transition matrix have nonzero probabilities by setting them to eps and then renormalizing. Avoids zeros that would cause estimation algorithms to crash or get stuck in suboptimal stat...
bhmm/init/discrete.py
def regularize_hidden(p0, P, reversible=True, stationary=False, C=None, eps=None): """ Regularizes the hidden initial distribution and transition matrix. Makes sure that the hidden initial distribution and transition matrix have nonzero probabilities by setting them to eps and then renormalizing. Avoid...
def regularize_hidden(p0, P, reversible=True, stationary=False, C=None, eps=None): """ Regularizes the hidden initial distribution and transition matrix. Makes sure that the hidden initial distribution and transition matrix have nonzero probabilities by setting them to eps and then renormalizing. Avoid...
[ "Regularizes", "the", "hidden", "initial", "distribution", "and", "transition", "matrix", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/init/discrete.py#L60-L116
[ "def", "regularize_hidden", "(", "p0", ",", "P", ",", "reversible", "=", "True", ",", "stationary", "=", "False", ",", "C", "=", "None", ",", "eps", "=", "None", ")", ":", "# input", "n", "=", "P", ".", "shape", "[", "0", "]", "if", "eps", "is", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
regularize_pobs
Regularizes the output probabilities. Makes sure that the output probability distributions has nonzero probabilities by setting them to eps and then renormalizing. Avoids zeros that would cause estimation algorithms to crash or get stuck in suboptimal states. Parameters ---------- B : ndar...
bhmm/init/discrete.py
def regularize_pobs(B, nonempty=None, separate=None, eps=None): """ Regularizes the output probabilities. Makes sure that the output probability distributions has nonzero probabilities by setting them to eps and then renormalizing. Avoids zeros that would cause estimation algorithms to crash or get stu...
def regularize_pobs(B, nonempty=None, separate=None, eps=None): """ Regularizes the output probabilities. Makes sure that the output probability distributions has nonzero probabilities by setting them to eps and then renormalizing. Avoids zeros that would cause estimation algorithms to crash or get stu...
[ "Regularizes", "the", "output", "probabilities", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/init/discrete.py#L119-L164
[ "def", "regularize_pobs", "(", "B", ",", "nonempty", "=", "None", ",", "separate", "=", "None", ",", "eps", "=", "None", ")", ":", "# input", "B", "=", "B", ".", "copy", "(", ")", "# modify copy", "n", ",", "m", "=", "B", ".", "shape", "# number of...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
init_discrete_hmm_spectral
Initializes discrete HMM using spectral clustering of observation counts Initializes HMM as described in [1]_. First estimates a Markov state model on the given observations, then uses PCCA+ to coarse-grain the transition matrix [2]_ which initializes the HMM transition matrix. The HMM output probabili...
bhmm/init/discrete.py
def init_discrete_hmm_spectral(C_full, nstates, reversible=True, stationary=True, active_set=None, P=None, eps_A=None, eps_B=None, separate=None): """Initializes discrete HMM using spectral clustering of observation counts Initializes HMM as described in [1]_. First estimates a M...
def init_discrete_hmm_spectral(C_full, nstates, reversible=True, stationary=True, active_set=None, P=None, eps_A=None, eps_B=None, separate=None): """Initializes discrete HMM using spectral clustering of observation counts Initializes HMM as described in [1]_. First estimates a M...
[ "Initializes", "discrete", "HMM", "using", "spectral", "clustering", "of", "observation", "counts" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/init/discrete.py#L167-L338
[ "def", "init_discrete_hmm_spectral", "(", "C_full", ",", "nstates", ",", "reversible", "=", "True", ",", "stationary", "=", "True", ",", "active_set", "=", "None", ",", "P", "=", "None", ",", "eps_A", "=", "None", ",", "eps_B", "=", "None", ",", "separat...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
init_discrete_hmm_ml
Initializes discrete HMM using maximum likelihood of observation counts
bhmm/init/discrete.py
def init_discrete_hmm_ml(C_full, nstates, reversible=True, stationary=True, active_set=None, P=None, eps_A=None, eps_B=None, separate=None): """Initializes discrete HMM using maximum likelihood of observation counts""" raise NotImplementedError('ML-initialization not yet implemented')
def init_discrete_hmm_ml(C_full, nstates, reversible=True, stationary=True, active_set=None, P=None, eps_A=None, eps_B=None, separate=None): """Initializes discrete HMM using maximum likelihood of observation counts""" raise NotImplementedError('ML-initialization not yet implemented')
[ "Initializes", "discrete", "HMM", "using", "maximum", "likelihood", "of", "observation", "counts" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/init/discrete.py#L342-L345
[ "def", "init_discrete_hmm_ml", "(", "C_full", ",", "nstates", ",", "reversible", "=", "True", ",", "stationary", "=", "True", ",", "active_set", "=", "None", ",", "P", "=", "None", ",", "eps_A", "=", "None", ",", "eps_B", "=", "None", ",", "separate", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.update
r""" Updates the transition matrix and recomputes all derived quantities
bhmm/hmm/generic_hmm.py
def update(self, Pi, Tij): r""" Updates the transition matrix and recomputes all derived quantities """ from msmtools import analysis as msmana # update transition matrix by copy self._Tij = np.array(Tij) assert msmana.is_transition_matrix(self._Tij), 'Given transition matrix is...
def update(self, Pi, Tij): r""" Updates the transition matrix and recomputes all derived quantities """ from msmtools import analysis as msmana # update transition matrix by copy self._Tij = np.array(Tij) assert msmana.is_transition_matrix(self._Tij), 'Given transition matrix is...
[ "r", "Updates", "the", "transition", "matrix", "and", "recomputes", "all", "derived", "quantities" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L79-L93
[ "def", "update", "(", "self", ",", "Pi", ",", "Tij", ")", ":", "from", "msmtools", "import", "analysis", "as", "msmana", "# update transition matrix by copy", "self", ".", "_Tij", "=", "np", ".", "array", "(", "Tij", ")", "assert", "msmana", ".", "is_trans...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.is_stationary
r""" Whether the MSM is stationary, i.e. whether the initial distribution is the stationary distribution of the hidden transition matrix.
bhmm/hmm/generic_hmm.py
def is_stationary(self): r""" Whether the MSM is stationary, i.e. whether the initial distribution is the stationary distribution of the hidden transition matrix. """ # for disconnected matrices, the stationary distribution depends on the estimator, so we can't compute # it directly. Th...
def is_stationary(self): r""" Whether the MSM is stationary, i.e. whether the initial distribution is the stationary distribution of the hidden transition matrix. """ # for disconnected matrices, the stationary distribution depends on the estimator, so we can't compute # it directly. Th...
[ "r", "Whether", "the", "MSM", "is", "stationary", "i", ".", "e", ".", "whether", "the", "initial", "distribution", "is", "the", "stationary", "distribution", "of", "the", "hidden", "transition", "matrix", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L167-L172
[ "def", "is_stationary", "(", "self", ")", ":", "# for disconnected matrices, the stationary distribution depends on the estimator, so we can't compute", "# it directly. Therefore we test whether the initial distribution is stationary.", "return", "np", ".", "allclose", "(", "np", ".", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.stationary_distribution
r""" Compute stationary distribution of hidden states if possible. Raises ------ ValueError if the HMM is not stationary
bhmm/hmm/generic_hmm.py
def stationary_distribution(self): r""" Compute stationary distribution of hidden states if possible. Raises ------ ValueError if the HMM is not stationary """ assert _tmatrix_disconnected.is_connected(self._Tij, strong=False), \ 'No unique stationary distri...
def stationary_distribution(self): r""" Compute stationary distribution of hidden states if possible. Raises ------ ValueError if the HMM is not stationary """ assert _tmatrix_disconnected.is_connected(self._Tij, strong=False), \ 'No unique stationary distri...
[ "r", "Compute", "stationary", "distribution", "of", "hidden", "states", "if", "possible", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L185-L196
[ "def", "stationary_distribution", "(", "self", ")", ":", "assert", "_tmatrix_disconnected", ".", "is_connected", "(", "self", ".", "_Tij", ",", "strong", "=", "False", ")", ",", "'No unique stationary distribution because transition matrix is not connected'", "import", "m...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.timescales
r""" Relaxation timescales of the hidden transition matrix Returns ------- ts : ndarray(m) relaxation timescales in units of the input trajectory time step, defined by :math:`-tau / ln | \lambda_i |, i = 2,...,nstates`, where :math:`\lambda_i` are the hidden ...
bhmm/hmm/generic_hmm.py
def timescales(self): r""" Relaxation timescales of the hidden transition matrix Returns ------- ts : ndarray(m) relaxation timescales in units of the input trajectory time step, defined by :math:`-tau / ln | \lambda_i |, i = 2,...,nstates`, where :ma...
def timescales(self): r""" Relaxation timescales of the hidden transition matrix Returns ------- ts : ndarray(m) relaxation timescales in units of the input trajectory time step, defined by :math:`-tau / ln | \lambda_i |, i = 2,...,nstates`, where :ma...
[ "r", "Relaxation", "timescales", "of", "the", "hidden", "transition", "matrix" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L243-L258
[ "def", "timescales", "(", "self", ")", ":", "from", "msmtools", ".", "analysis", ".", "dense", ".", "decomposition", "import", "timescales_from_eigenvalues", "as", "_timescales", "self", ".", "_ensure_spectral_decomposition", "(", ")", "ts", "=", "_timescales", "(...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.lifetimes
r""" Lifetimes of states of the hidden transition matrix Returns ------- l : ndarray(nstates) state lifetimes in units of the input trajectory time step, defined by :math:`-tau / ln | p_{ii} |, i = 1,...,nstates`, where :math:`p_{ii}` are the diagonal entries...
bhmm/hmm/generic_hmm.py
def lifetimes(self): r""" Lifetimes of states of the hidden transition matrix Returns ------- l : ndarray(nstates) state lifetimes in units of the input trajectory time step, defined by :math:`-tau / ln | p_{ii} |, i = 1,...,nstates`, where :math:`p_{...
def lifetimes(self): r""" Lifetimes of states of the hidden transition matrix Returns ------- l : ndarray(nstates) state lifetimes in units of the input trajectory time step, defined by :math:`-tau / ln | p_{ii} |, i = 1,...,nstates`, where :math:`p_{...
[ "r", "Lifetimes", "of", "states", "of", "the", "hidden", "transition", "matrix" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L261-L272
[ "def", "lifetimes", "(", "self", ")", ":", "return", "-", "self", ".", "_lag", "/", "np", ".", "log", "(", "np", ".", "diag", "(", "self", ".", "transition_matrix", ")", ")" ]
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.sub_hmm
r""" Returns HMM on a subset of states Returns the HMM restricted to the selected subset of states. Will raise exception if the hidden transition matrix cannot be normalized on this subset
bhmm/hmm/generic_hmm.py
def sub_hmm(self, states): r""" Returns HMM on a subset of states Returns the HMM restricted to the selected subset of states. Will raise exception if the hidden transition matrix cannot be normalized on this subset """ # restrict initial distribution pi_sub = self._Pi[...
def sub_hmm(self, states): r""" Returns HMM on a subset of states Returns the HMM restricted to the selected subset of states. Will raise exception if the hidden transition matrix cannot be normalized on this subset """ # restrict initial distribution pi_sub = self._Pi[...
[ "r", "Returns", "HMM", "on", "a", "subset", "of", "states" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L274-L295
[ "def", "sub_hmm", "(", "self", ",", "states", ")", ":", "# restrict initial distribution", "pi_sub", "=", "self", ".", "_Pi", "[", "states", "]", "pi_sub", "/=", "pi_sub", ".", "sum", "(", ")", "# restrict transition matrix", "P_sub", "=", "self", ".", "_Tij...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.count_matrix
Compute the transition count matrix from hidden state trajectory. Returns ------- C : numpy.array with shape (nstates,nstates) C[i,j] is the number of transitions observed from state i to state j Raises ------ RuntimeError A RuntimeError is raise...
bhmm/hmm/generic_hmm.py
def count_matrix(self): # TODO: does this belong here or to the BHMM sampler, or in a subclass containing HMM with data? """Compute the transition count matrix from hidden state trajectory. Returns ------- C : numpy.array with shape (nstates,nstates) C[i,j] is the nu...
def count_matrix(self): # TODO: does this belong here or to the BHMM sampler, or in a subclass containing HMM with data? """Compute the transition count matrix from hidden state trajectory. Returns ------- C : numpy.array with shape (nstates,nstates) C[i,j] is the nu...
[ "Compute", "the", "transition", "count", "matrix", "from", "hidden", "state", "trajectory", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L297-L319
[ "def", "count_matrix", "(", "self", ")", ":", "# TODO: does this belong here or to the BHMM sampler, or in a subclass containing HMM with data?", "if", "self", ".", "hidden_state_trajectories", "is", "None", ":", "raise", "RuntimeError", "(", "'HMM model does not have a hidden stat...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.count_init
Compute the counts at the first time step Returns ------- n : ndarray(nstates) n[i] is the number of trajectories starting in state i
bhmm/hmm/generic_hmm.py
def count_init(self): """Compute the counts at the first time step Returns ------- n : ndarray(nstates) n[i] is the number of trajectories starting in state i """ if self.hidden_state_trajectories is None: raise RuntimeError('HMM model does not h...
def count_init(self): """Compute the counts at the first time step Returns ------- n : ndarray(nstates) n[i] is the number of trajectories starting in state i """ if self.hidden_state_trajectories is None: raise RuntimeError('HMM model does not h...
[ "Compute", "the", "counts", "at", "the", "first", "time", "step" ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L321-L334
[ "def", "count_init", "(", "self", ")", ":", "if", "self", ".", "hidden_state_trajectories", "is", "None", ":", "raise", "RuntimeError", "(", "'HMM model does not have a hidden state trajectory.'", ")", "n", "=", "[", "traj", "[", "0", "]", "for", "traj", "in", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.collect_observations_in_state
Collect a vector of all observations belonging to a specified hidden state. Parameters ---------- observations : list of numpy.array List of observed trajectories. state_index : int The index of the hidden state for which corresponding observations are to be retr...
bhmm/hmm/generic_hmm.py
def collect_observations_in_state(self, observations, state_index): # TODO: this would work well in a subclass with data """Collect a vector of all observations belonging to a specified hidden state. Parameters ---------- observations : list of numpy.array List of ob...
def collect_observations_in_state(self, observations, state_index): # TODO: this would work well in a subclass with data """Collect a vector of all observations belonging to a specified hidden state. Parameters ---------- observations : list of numpy.array List of ob...
[ "Collect", "a", "vector", "of", "all", "observations", "belonging", "to", "a", "specified", "hidden", "state", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L398-L431
[ "def", "collect_observations_in_state", "(", "self", ",", "observations", ",", "state_index", ")", ":", "# TODO: this would work well in a subclass with data", "if", "not", "self", ".", "hidden_state_trajectories", ":", "raise", "RuntimeError", "(", "'HMM model does not have ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a
train
HMM.generate_synthetic_state_trajectory
Generate a synthetic state trajectory. Parameters ---------- nsteps : int Number of steps in the synthetic state trajectory to be generated. initial_Pi : np.array of shape (nstates,), optional, default=None The initial probability distribution, if samples are not...
bhmm/hmm/generic_hmm.py
def generate_synthetic_state_trajectory(self, nsteps, initial_Pi=None, start=None, stop=None, dtype=np.int32): """Generate a synthetic state trajectory. Parameters ---------- nsteps : int Number of steps in the synthetic state trajectory to be generated. initial_Pi :...
def generate_synthetic_state_trajectory(self, nsteps, initial_Pi=None, start=None, stop=None, dtype=np.int32): """Generate a synthetic state trajectory. Parameters ---------- nsteps : int Number of steps in the synthetic state trajectory to be generated. initial_Pi :...
[ "Generate", "a", "synthetic", "state", "trajectory", "." ]
bhmm/bhmm
python
https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L433-L479
[ "def", "generate_synthetic_state_trajectory", "(", "self", ",", "nsteps", ",", "initial_Pi", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "dtype", "=", "np", ".", "int32", ")", ":", "# consistency check", "if", "initial_Pi", "is", ...
9804d18c2ddb684fb4d90b544cc209617a89ca9a