utils.desirability.DArb

utils.desirability.DArb(x, d, tol=None, missing=None)

Implements an arbitrary desirability function.

This class allows users to define a custom desirability function by specifying input values (x) and their corresponding desirability values (d).

Attributes

Name Type Description
x numpy.ndarray The input values for the desirability function.
d numpy.ndarray The desirability values corresponding to the input values.
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 DArb
import numpy as np
import matplotlib.pyplot as plt
# Define input and desirability values
x = [-5, 0, 5, 10]
d = [0, 0.5, 1, 0.2]
# Create a DArb object
darb = DArb(x, d)
# Predict desirability for a range of inputs
inputs = np.array([-10, -5, 0, 5, 10, 15])
desirability = darb.predict(inputs)
print(desirability)
# [0.  0.  0.5 1.  0.2 0.2]
# Plot the desirability function
darb.plot()
[0.  0.  0.5 1.  0.2 0.2]

Methods

Name Description
plot Plots the arbitrary desirability function.
predict Predicts the desirability values for the given input data.