O'Reilly logo

Machine Learning with Spark - Second Edition by Nick Pentreath, Manpreet Singh Ghotra, Rajdeep Dua

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lagranges multipliers

In the math optimization problem, the method of Lagrange multipliers is used as a tool for finding the local minima and maxima of a function subject to equality constraints. An example involves finding the maximum entropy distribution subject to given constraints.

This is best explained with an example. Let's say we have to maximize K (x, y) = -x2 -y2 subject to y = x + 1.

The constraint function is g (x, y) = x-y+1=0. The L multiplier then becomes this:

Differentiating with respect to x, y, and lambda, and setting to 0 we get the following:

Solving the preceding equations, we get x=-0.5, y=0.5, lambda=-1.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required