utils.desirability.DMax

utils.desirability.DMax(low, high, scale=1, tol=None, missing=None)

Implements a desirability function for maximization.

The desirability function assigns a value of 0 for inputs below the low threshold, a value of 1 for inputs above the high threshold, and scales the desirability between 0 and 1 for inputs within the range [low, high] using a specified scale factor.

Attributes

Name Type Description
low float The lower threshold for the desirability function.
high float The upper threshold for the desirability function.
scale float The scaling factor for the desirability function. Must be greater than 0.
tol float A tolerance value to replace desirability values of 0. Defaults to None.
missing float The value to use for missing inputs. Defaults to a non-informative value.

Functions

Predicts the desirability values for the given input data.

Plots the desirability function.

References

Many thanks to Max Kuhn for his implementation of the ‘desirability’ package in R. This class is based on the ‘desirability’ package in R, see: https://cran.r-project.org/package=desirability

Examples

from spotdesirability import DMax
import numpy as np
import matplotlib.pyplot as plt
# Create a DMax object
dmax = DMax(low=0, high=10, scale=1)
# Predict desirability for a range of inputs
inputs = np.array([-5, 0, 5, 10, 15])
desirability = dmax.predict(inputs)
print(desirability)
# [0. 0. 0.5 1. 1.]
# Plot the desirability function
dmax.plot()
[0.  0.  0.5 1.  1. ]

Methods

Name Description
predict Predicts the desirability values for the given input data.