moocore.

r2_exact#

moocore.r2_exact(data, /, ref, *, maximise=False)[source]#

Exact R2 indicator.

Computes the exact R2 indicator with respect to a given ideal/utopian reference point assuming minimization of all objectives.

See also

For details of the R2 indicator, see (Exact) R2 Indicator.

Warning

The current implementation only supports 2 objectives.

Parameters:
  • data (ArrayLike) – Numpy array of numerical values, where each row gives the coordinates of a point. If the array is created from the read_datasets() function, remove the last column.

  • ref (ArrayLike) – Reference point as a 1D vector. Must be same length as a single point in the data.

  • maximise (bool | Sequence[bool], default: False) – Whether the objectives must be maximised instead of minimised. Either a single boolean value that applies to all objectives or a list of booleans, with one value per objective. Also accepts a 1D numpy array with value 0/1 for each objective.

Returns:

float – A single numerical value, the exact R2 indicator.

Notes

The current implementation exclusively supports bi-objective solution sets and runs in \(O(n \log n)\). For more details on the computation of the exact R2 indicator refer to Schäpermeier and Kerschke[1].

References

Examples

>>> dat = np.array([[5, 5], [4, 6], [2, 7], [7, 4]])
>>> moocore.r2_exact(dat, ref=[0, 0])
2.594191919191919

This function assumes that objectives must be minimized by default. We can easily specify maximization:

>>> dat = np.array([[5, 5], [4, 6], [2, 7], [7, 4]])
>>> moocore.r2_exact(dat, ref=[10, 10], maximise=True)
2.519696969696969

Merge all the sets of a dataset by removing the set number column:

>>> dat = moocore.get_dataset("input1.dat")[:, :-1]
>>> len(dat)
100

Dominated points are ignored, so this:

>>> moocore.r2_exact(dat, ref=0)
0.3336076878950565

gives the same exact R2 value as this:

>>> dat = moocore.filter_dominated(dat)
>>> len(dat)
6
>>> moocore.r2_exact(dat, ref=0)
0.3336076878950565