• Python - SciPy

    Optimization and Fit in SciPy – scipy.optimize

    Optimization and Fit in SciPy – scipy.optimize Optimization provides a useful algorithm for minimization of curve fitting, multidimensional or scalar and root fitting. Let’s take an example of a Scalar Function, to find minimum scalar function %matplotlib inline import matplotlib.pyplot as plt from scipy import optimize import numpy as np def function(a): return a*2 + 20 * np.sin(a) plt.plot(a, function(a)) plt.show() #use BFGS algorithm for optimization optimize.fmin_bfgs(function, 0) Output: Optimization terminated successfully. Current function value: -23.241676 Iterations: 4 Function evaluations: 18 Gradient evaluations: 6 array([-1.67096375]) In this example, optimization is done with the help of the gradient descent algorithm from the initial…

  • Python

    Best Way to Learn Python (2021 Step-by-Step Guide)

    Python is a very popular language. It’s also one of the languages that I recommend for beginners to start with. But how do you go about learning this language? The best way to learn Python is to understand the big picture of all what you need to learn before you dive in and start learning. In this article, I divide the path of learning Python into 6 levels. Each level covers a subset of the language that you need to master before you move on to the next one. My focus on this article is for you to be a competent well-rounded programmer so you…