plqcom.PLQProperty

PLQProperty: Several functions to check the properties of a PLQ function.

Functions

is_continuous(plq_loss)

Check whether a PLQ loss function is continuous

is_convex(plq_loss)

Check whether a PLQ loss function is convex

check_cutoff(plq_loss)

Check whether there exists a cutoff between the knots, if so, add the cutoff to the knot list and update

find_min(plq_loss)

Find the minimum knots and value of the PLQ function, if the minimum value is greater than zero

plq_to_rehloss(plq_loss)

convert the PLQLoss function to a ReHLoss function piece by piece.

Module Contents

plqcom.PLQProperty.is_continuous(plq_loss)

Check whether a PLQ loss function is continuous

Parameters:
plq_lossPLQLoss

A PLQLoss object

Returns:
bool

Whether the PLQ function is continuous, True for continuous, False for not continuous

Examples

>>> from plqcom import PLQLoss, is_continuous
>>> plq_loss = PLQLoss(cutpoints=np.array([0.]),quad_coef={'a': np.array([0, 0]), 'b': np.array([-1, 1]), 'c': np.array([1, 1])})
>>> is_continuous(plq_loss)
True
plqcom.PLQProperty.is_convex(plq_loss)

Check whether a PLQ loss function is convex

Parameters:
plq_lossPLQLoss

A PLQLoss object

Returns:
bool

Whether the PLQ function is convex, True for convex, False for not convex

Examples

>>> from plqcom import PLQLoss, is_convex
>>> plq_loss = PLQLoss(cutpoints=np.array([0.]),quad_coef={'a': np.array([0, 0]), 'b': np.array([-1, 1]), 'c': np.array([1, 1])})
>>> is_convex(plq_loss)
True
plqcom.PLQProperty.check_cutoff(plq_loss)

Check whether there exists a cutoff between the knots, if so, add the cutoff to the knot list and update the coefficients

Parameters:
plq_lossPLQLoss

A PLQLoss object

Examples

>>> from plqcom import PLQLoss, check_cutoff
>>> plq_loss = PLQLoss(cutpoints=np.array([0.]),quad_coef={'a': np.array([0, 0]), 'b': np.array([-1, 1]), 'c': np.array([1, 1])})
>>> check_cutoff(plq_loss)
>>> plq_loss.cutpoints
array([-inf,   0.,  inf])
plqcom.PLQProperty.find_min(plq_loss)

Find the minimum knots and value of the PLQ function, if the minimum value is greater than zero record the minimum value and knot, remove the minimum value from the PLQ function and update the coefficients

Parameters:
plq_lossPLQLoss

A PLQLoss object

Examples

>>> from plqcom import PLQLoss, find_min
>>> plq_loss = PLQLoss(cutpoints=np.array([0]),quad_coef={'a': np.array([0, 0]), 'b': np.array([-1, 1]), 'c': np.array([1, 1])})
>>> find_min(plq_loss)
>>> plq_loss.min_val
1.0
plqcom.PLQProperty.plq_to_rehloss(plq_loss)
convert the PLQLoss function to a ReHLoss function piece by piece.

The details are described in the technical details.

Parameters:
plq_lossPLQLoss

A PLQLoss object

Returns:
an object of ReHLoss

Examples

>>> from plqcom import PLQLoss, plq_to_rehloss
>>> plq_loss = PLQLoss(cutpoints=np.array([0]),quad_coef={'a': np.array([0, 0]), 'b': np.array([-1, 1]), 'c': np.array([1, 1])})
>>> reh_loss = plq_to_rehloss(plq_loss)