Distance Metrics

Distance measures

Module Documentation

fitr.criticism.distance.likelihood_distance(loglik_func, data, params, diff_metric='sq', dist_metric='cosine', verbose=False)

Estimates the likelihood of the data from the i’th subject using the parameter estimates of the j’th subject, for all i and j, then computes the distance between subjects’ likelihood difference vectors

Parameters:
loglik_func : function

The log-likelihood function to be used

data : dict

Data formatted for input into the log-likelihood function

params : ndarray(shape=(nsubjects, nparams))

Array of parameter estimates

diff_metric : {‘sq’, ‘diff’, ‘abs’}

Which type of difference measure to compute, ‘diff’ is simple subtractive difference, whereas ‘sq’ and ‘abs’ are the squared and absolute differences, respectively

dist_metric : str (default=’cosine’)

The pairwise distance metric to use. Any option that can be passed into sklearn.metrics.pairwise_distances can work.

verbose : bool

Whether to print out progress

Returns:
ndarray(shape=(nsubjects, nsubjects))
fitr.criticism.distance.parameter_distance(params, dist_metric='canberra', scale='minmax', return_scaled=False)

Computes distances between subjects’ respective parameter estimates

Parameters:
params : ndarray(shape=(nsubjects, nsubjects))

Array of parameter estimates

dist_metric : str (default=’canberra’)

Distance metric to be used. Can take any value acceptable by sklearn.metrics.pairwise_distances.

scale : {‘minmax’, ‘standard’, ‘none’}

How to scale the parameters for distance computation

return_scaled : bool

Whether to return scaled parameters