utils.desirability.DTarget

utils.desirability.DTarget(
    low,
    target,
    high,
    low_scale=1,
    high_scale=1,
    tol=None,
    missing=None,
)

Implements a desirability function for target optimization.

The desirability function assigns a value of 0 for inputs outside the range [low, high], scales the desirability between 0 and 1 for inputs within [low, target] using low_scale, and scales the desirability between 1 and 0 for inputs within [target, high] using high_scale.

Attributes

Name Type Description
low float The lower threshold for the desirability function.
target float The target value for the desirability function.
high float The upper threshold for the desirability function.
low_scale float The scaling factor for the desirability function below the target. Must be greater than 0.
high_scale float The scaling factor for the desirability function above the target. 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 DTarget
import numpy as np
import matplotlib.pyplot as plt
# Create a DTarget object
dtarget = DTarget(low=0, target=5, high=10, low_scale=1, high_scale=1)
# Predict desirability for a range of inputs
inputs = np.array([-5, 0, 2.5, 5, 7.5, 10, 15])
desirability = dtarget.predict(inputs)
print(desirability)
# [0.   0.   0.5  1.   0.5  0.   0.  ]
# Plot the desirability function
dtarget.plot()
[ 0.   0.   0.5  1.   0.5 -0.   0. ]

Methods

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