portfolio_optimization.components.results module

This module contains a container for Results object.

class portfolio_optimization.components.results.Results(portfolio_data, provided_emission_constraints=None, provided_growth_target=None)[source]

Bases: object

Results container

__init__(portfolio_data, provided_emission_constraints=None, provided_growth_target=None)[source]

Init of Results container.

Parameters:
  • portfolio_data (PortfolioData) – the portfolio data

  • provided_emission_constraints (Optional[list[tuple[str, str, float, str]]]) – list of all the emission constraints that are provided. Each list element contains the emission_now, emission_future and reduction_percentage_target input.

  • provided_growth_target (Optional[float]) – target outstanding amount growth factor if the growth factor constraint is set, otherwise None.

__len__()[source]

Return the number of samples stored in the Results object.

Return type:

int

add_result(outstanding_future_samples)[source]

Adds a new outstanding_future data point to results container.

Parameters:

outstanding_future_samples (ndarray[Any, dtype[float64]]) – outstanding amounts in the future for each sample of the dataset.

Return type:

None

drop_duplicates()[source]

Drops duplicates in results DataFrame

Return type:

None

head(n=5)[source]

Returns first n rows of self.results_df DataFrame

Parameters:
  • selected_columns – By default all columns

  • n (int) – number of results to return

Return type:

DataFrame

slice_results(tolerance=0.0)[source]

Helper function that slices the results in two groups, those results that satisfy all constraints and those that violate at least one of the growth factor or emission constraints.

Parameters:

tolerance (float) – tolerance on how strict the constraints need to be satisfied (in percentage point). Example: if the desired target growth rate is 1.2, if the tolerance is set to 0.05 (5%). Solutions that increase outstanding amount by a factor of 1.15 are considered to satisfy the constraints given the tolerance.

Return type:

tuple[tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]], tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]]

Returns:

Relative difference (diversification, roc) coordinates for solutions that satisfy all constraints, and for those that do not satisfy all constraints.

Raises:

ValueError – when there are no emission or growth factor constraints set.