CostDistribution#

class caf.toolkit.cost_utils.CostDistribution(df, *, min_col='min', max_col='max', avg_col='avg', trips_col='trips', weighted_avg_col=None)[source]#

Distribution of cost values between variable bounds.

Alternate constructors are available in the See Also section

Parameters:
  • df (pd.DataFrame) – A DataFrame containing the binned cost distribution data. Must have columns named: min_col, max_col, avg_col, trips_col.

  • min_col (str) – The name of the columns in df that contains the lower bin edge value for each row.

  • max_col (str) – The name of the columns in df that contains the upper bin edge value for each row.

  • avg_col (str) – The name of the columns in df that contains the centre of the bin

  • trips_col (str) – The name of the columns in df that contains the value for each row.

  • weighted_avg_col (Optional[str]) – The name of the columns in df that contains the weighted average value for each row. If available, this is different from avg_col as it takes into account this distribution of values within each bound when calculating averages.

Attributes

avg_vals

Average values for each of the cost distribution bins.

band_share_vals

Band share values for each of the cost distribution bins.

bin_edges

Bin edges for the cost distribution.

df

A Pandas DataFrame containing the class data.

max_vals

Maximum values of the cost distribution in edges.

min_vals

Minimum values of the cost distribution bin edges.

n_bins

Bin edges for the cost distribution.

trip_vals

Trip values for each of the cost distribution bins.

weighted_avg_vals

Weighted average values for each of the cost distribution bins.

Methods

__init__(df, *[, min_col, max_col, avg_col, ...])

band_share_convergence(other)

Calculate the convergence between this and other.

band_share_residuals(other)

Calculate the band share residuals between this and other.

calculate_weighted_averages(matrix, ...)

Calculate weighted averages of bins in a cost distribution.

copy()

Create a copy of this instance.

create_similar(trip_vals)

Create a similar cost distribution with different trip values.

from_data(matrix, cost_matrix, *[, ...])

Convert values and a cost matrix into a CostDistribution.

from_data_no_bins(matrix, cost_matrix, ...)

Convert values and a cost matrix into a CostDistribution.

from_file(filepath, *[, min_col, max_col, ...])

Build an instance from a file on disk.

trip_residuals(other)

Calculate the trip residuals between this and other.

Attributes Documentation

avg_vals#

Average values for each of the cost distribution bins.

band_share_vals#

Band share values for each of the cost distribution bins.

bin_edges#

Bin edges for the cost distribution.

df#

A Pandas DataFrame containing the class data.

max_vals#

Maximum values of the cost distribution in edges.

min_vals#

Minimum values of the cost distribution bin edges.

n_bins#

Bin edges for the cost distribution.

trip_vals#

Trip values for each of the cost distribution bins.

weighted_avg_vals#

Weighted average values for each of the cost distribution bins.