# ceml.costfunctions¶

## ceml.costfunctions.costfunctions¶

class ceml.costfunctions.costfunctions.CostFunction(input_to_output=None, **kwds)

Bases: abc.ABC

Base class of a cost function.

Note

The class CostFunction can not be instantiated because it contains an abstract method.

abstract score_impl(x)

Applying the cost function to a given input.

Abstract method for computing applying the cost function to a given input x.

Note

All derived classes must implement this method.

class ceml.costfunctions.costfunctions.CostFunctionDifferentiable(input_to_output=None, **kwds)

Base class of a differentiable cost function.

Note

The class CostFunctionDifferentiable can not be instantiated because it contains an abstract method.

abstract grad(mask=None)

Abstract method for computing the gradient of the cost function.

Returns

A function that computes the gradient for a given input.

Return type

callable

Note

All derived classes must implement this method.

class ceml.costfunctions.costfunctions.RegularizedCost(penalize_input, penalize_output, C=1.0, **kwds)

Regularized cost function.

The RegularizedCost class implements a regularized cost function. The cost function is the sum of a regularization term (weighted by the regularization strength C) and a term that penalizes wrong predictions.

Parameters
score_impl(x)

Applying the cost function to a given input.

Computes the cost function fo a given input x.

Parameters

x (numpy.array) – Value of the unknown variable.

Returns

The loss/cost.

Return type

float