Optimizers try to find the minimum value of a function through gradient descent

Minimizers can be used with the scipy.optimize library

scipy.optimize libraryimport scipy.optimize as SPO
def f(x):
Y = (X-1.5)**2 + 0.5
return Y
# First, we pass in a guess
x_guess = 2.0
# Then, call the optimizer and pass in the function defined by f(x)
min_result = spo.minimize(f, x_guess, method='SLSQP', options={'disp': True})
# Print the minima coords
print(min_result.x) # x_coord
print(min_result.fun) # y_coord
# Plot function values, mark minima
Xplot = np.linspace(0.5, 2.5, 21)
Yplot = f(Xplot)
plt.plot(Xplot, Yplot)
plt.plot(min_result.x, min_result.fun, 'ro')
plt.title("Minima of an objective function")
plt.show()
Given a line drawn by any 2 points on a graph, if the line is above the graph then it is a convex problem

Optimizers need a problem to minimize, hence for linear regression, we can provide it with the sum of squared residuals.

<aside> 📌 SUMMARY: Minimization can be done in many dimensions, and one popular thing to minimize is the sum of squared errors to find a good line fit
</aside>