Module flowcon.datasets.uci.utils

Functions

def calc_whitening_transform(xs)

Calculates the parameters that whiten a dataset.

def copy_model_parms(source_model, target_model)

Copies the parameters of source_model to target_model.

def discrete_sample(p, n_samples=1)

Samples from a discrete distribution. :param p: a distribution with N elements :param n_samples: number of samples :return: vector of samples

def disp_imdata(xs, imsize, layout=(1, 1))

Displays an array of images, a page at a time. The user can navigate pages with left and right arrows, start over by pressing space, or close the figure by esc. :param xs: an numpy array with images as rows :param imsize: size of the images :param layout: layout of images in a page :return: none

def ess_importance(ws)

Calculates the effective sample size of a set of weighted independent samples (e.g. as given by importance sampling or sequential monte carlo). Takes as input the normalized sample weights.

def ess_mcmc(xs)

Calculates the effective sample size of a correlated sequence of samples, e.g. as given by markov chain monte carlo.

def get_data_root()
def isdistribution(p)

:param p: a vector representing a discrete pro bability distribution :return: True if p is a valid probability distribution

def isposint(n)

Determines whether number n is a positive integer. :param n: number :return: bool

def load(file)

Loads data from file.

def logistic(x)

Elementwise logistic sigmoid. :param x: numpy array :return: numpy array

def logit(x)

Elementwise logit (inverse logistic sigmoid). :param x: numpy array :return: numpy array

def make_folder(folder)

Creates given folder (or path) if it doesn't exist.

def one_hot_encode(labels, n_labels)

Transforms numeric labels to 1-hot encoded labels. Assumes numeric labels are in the range 0, 1, …, n_labels-1.

def plot_hist_marginals(data, lims=None, gt=None)

Plots marginal histograms and pairwise scatter plots of a dataset.

def plot_pdf_marginals(pdf, lims, gt=None, levels=(0.68, 0.95))

Plots marginals of a pdf, for each variable and pair of variables.

def probs2contours(probs, levels)

Takes an array of probabilities and produces an array of contours at specified percentile levels :param probs: probability array. doesn't have to sum to 1, but it is assumed it contains all the mass :param levels: percentile levels. have to be in [0.0, 1.0] :return: array of same shape as probs with percentile labels

def save(data, file)

Saves data to a file.

def whiten(xs, params)

Whitens a given dataset using the whitening transform provided.