Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Data Science SCIPY for Gradient evaluation with optimization:-

SCIPY provide an optimize package to provide optimization to linear-gradient evaluation using multiple algorithms

Optimization and Fit in SciPy – scipy.optimize

Optimization provides a useful algorithm for minimization of curve fitting, multidimensional or scalar, and root fitting.

%matplotlib inline
import matplotlib.pyplot as plt
from scipy import optimize
import numpy as np
fre  = 5 
#Sample rate
fre_samp = 50
t = np.linspace(0, 2, 2 * fre_samp, endpoint = False )
a = np.sin(fre  * 2 * np.pi * t)
def function(a): return a*2 + 20 * np.sin(a) plt.plot(a, function(a)) #use BFGS algorithm for optimization optimize.fmin_bfgs(function, 0)

Nelder –Mead Algorithm:

  • Nelder-Mead algorithm selects through method parameter.
  • It provides the most straightforward way of minimization for fair behaved function.
  • Nelder – Mead algorithm is not used for gradient evaluations because it may take a longer time to find the solution.
  • import numpy as np
    from scipy import optimize
    #define function f(x)
    def f(x):   
        return .4*(1 - x[0])**2
    optimize.minimize(f, [2, -1], method="Nelder-Mead")

Post a Comment

POST Answer of Questions and ASK to Doubt

Previous Post Next Post