utils.desirability.DBox

utils.desirability.DBox(low, high, tol=None, missing=None)

Implements a box-like desirability function.

The desirability function assigns a value of 1 for inputs within the range [low, high] and a value of 0 for inputs outside this range.

Attributes

Name Type Description
low float The lower threshold for the desirability function.
high float The upper threshold for the desirability function.
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 DBox
import numpy as np
import matplotlib.pyplot as plt
# Create a DBox object
dbox = DBox(low=-1.682, high=1.682)
# Predict desirability for a range of inputs
inputs = np.array([-3, -1.682, 0, 1.682, 3])
desirability = dbox.predict(inputs)
print(desirability)
# [0. 1. 1. 1. 0.]
# Plot the desirability function
dbox.plot()
[0. 1. 1. 1. 0.]

Methods

Name Description
plot Plots the box-like desirability function.
predict Predicts the desirability values for the given input data.