# Evaluation measures¶

 `common_part_of_commuters`(values1, values2) Compute the common part of commuters for two pairs of fluxes. `common_part_of_links`(values1, values2) Compute the common part of commuters for two pairs of fluxes. `common_part_of_commuters_distance`(values1, …) Compute the common part of commuters according to the distance. `r_squared`(true, pred) R^2 (coefficient of determination) regression score function. `rmse`(true, pred) Root mean squared error regression loss `nrmse`(true, pred) Normalized mean squared error regression loss `information_gain`(true, pred) The information gain `pearson_correlation`(true, pred) Calculates a Pearson correlation coefficient and the p-value for testing non-correlation. `spearman_correlation`(true, pred) Calculates a Spearman rank-order correlation coefficient and the p-value to test for non-correlation. `kullback_leibler_divergence`(true, pred) Compute the Kullback-Leibler divergence S = sum(pk * log(pk / qk), axis=0). `max_error`(true, pred) The maximum error between the two arrays
skmob.measures.evaluation.common_part_of_commuters(values1, values2)

Compute the common part of commuters for two pairs of fluxes.

Parameters
• values1 (numpy array) – the values for the first array

• values2 – the values for the second array

Returns

float the common part of commuters

skmob.measures.evaluation.common_part_of_commuters_distance(values1, values2)

Compute the common part of commuters according to the distance.

Parameters
• values1 (numpy array) – the values for the first array

• values2 (numpy array) – the values for the second array

Returns

float the common part of commuters according to the distance

Compute the common part of commuters for two pairs of fluxes.

Parameters
• values1 (numpy array) – the values for the first array

• values2 (numpy array) – the values for the second array

Returns

float the common part of commuters

skmob.measures.evaluation.information_gain(true, pred)

The information gain

Parameters
• true (numpy array array-like of shape = (n_samples) or (n_samples, n_outputs)) – Ground truth (correct) target values.

• pred (numpy array-like of shape = (n_samples) or (n_samples, n_outputs)) – Estimated target values.

Returns

float A non-negative floating point value (the best value is 0.0)

skmob.measures.evaluation.kullback_leibler_divergence(true, pred)

Compute the Kullback-Leibler divergence S = sum(pk * log(pk / qk), axis=0).

Parameters
• true (numpy array array-like of shape = (n_samples) or (n_samples, n_outputs)) – Ground truth (correct) target values.

• pred (numpy array-like of shape = (n_samples) or (n_samples, n_outputs)) – Estimated target values.

Returns

float the calculated Kullback-Leibler divergence

skmob.measures.evaluation.max_error(true, pred)

The maximum error between the two arrays

Parameters
• true (numpy array array-like of shape = (n_samples) or (n_samples, n_outputs)) – Ground truth (correct) target values.

• pred (numpy array-like of shape = (n_samples) or (n_samples, n_outputs)) – Estimated target values.

Returns

float max error between the two samples

skmob.measures.evaluation.nrmse(true, pred)

Normalized mean squared error regression loss

Parameters
• true (numpy array array-like of shape = (n_samples) or (n_samples, n_outputs)) – Ground truth (correct) target values.

• pred (numpy array-like of shape = (n_samples) or (n_samples, n_outputs)) – Estimated target values.

Returns

float A non-negative floating point value (the best value is 0.0)

skmob.measures.evaluation.pearson_correlation(true, pred)

Calculates a Pearson correlation coefficient and the p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. Strictly speaking, Pearson’s correlation requires that each dataset be normally distributed. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Correlations of -1 or +1 imply an exact linear relationship. Positive correlations imply that as x increases, so does y. Negative correlations imply that as x increases, y decreases. The p-value roughly indicates the probability of an uncorrelated system producing datasets that have a Pearson correlation at least as extreme as the one computed from these datasets. The p-values are not entirely reliable but are probably reasonable for datasets larger than 500 or so.

Parameters
• true (numpy array array-like of shape = (n_samples) or (n_samples, n_outputs)) – Ground truth (correct) target values.

• pred (numpy array-like of shape = (n_samples) or (n_samples, n_outputs)) – Estimated target values.

Returns

tuple (Pearson’s correlation coefficient, 2-tailed p-value)

skmob.measures.evaluation.r_squared(true, pred)

R^2 (coefficient of determination) regression score function.

Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R^2 score of 0.0.

Parameters
• true (numpy array array-like of shape = (n_samples) or (n_samples, n_outputs)) – Ground truth (correct) target values.

• pred (numpy array-like of shape = (n_samples) or (n_samples, n_outputs)) – Estimated target values.

Returns

float

skmob.measures.evaluation.rmse(true, pred)

Root mean squared error regression loss

Parameters
• true (numpy array array-like of shape = (n_samples) or (n_samples, n_outputs)) – Ground truth (correct) target values.

• pred (numpy array-like of shape = (n_samples) or (n_samples, n_outputs)) – Estimated target values.

Returns

float A non-negative floating point value (the best value is 0.0)

skmob.measures.evaluation.spearman_correlation(true, pred)

Calculates a Spearman rank-order correlation coefficient and the p-value to test for non-correlation. The Spearman correlation is a nonparametric measure of the monotonicity of the relationship between two datasets. Unlike the Pearson correlation, the Spearman correlation does not assume that both datasets are normally distributed. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Correlations of -1 or +1 imply an exact monotonic relationship. Positive correlations imply that as x increases, so does y. Negative correlations imply that as x increases, y decreases. The p-value roughly indicates the probability of an uncorrelated system producing datasets that have a Spearman correlation at least as extreme as the one computed from these datasets. The p-values are not entirely reliable but are probably reasonable for datasets larger than 500 or so.

Parameters
• true (numpy array array-like of shape = (n_samples) or (n_samples, n_outputs)) – Ground truth (correct) target values.

• pred (numpy array-like of shape = (n_samples) or (n_samples, n_outputs)) – Estimated target values.

Returns

tuple (Spearman’s correlation coefficient, 2-tailed p-value)