Nelder-Mead Optimization Example in Python

    Optimization is a technique for finding the minimum or maximum value of the function from the set of available options. Finding the shortest path from point A to point B by evaluating multiple alternative directions can be a simple example of an optimization problem. 

    Nelder-Mead algorithm is a direct search optimization method to solve optimization problems. In this tutorial, I'll explain how to use Nelder-Mead method to find a minima of a given function in Python. SciPy API provides the minimize() function that can be used to apply several optimization methods and we can implement Nelder-Mead method by using this function.

    The tutorial covers:

  1. Nelder-Mead method implementation
  2. Source code listing

 We'll start by loading the required libraries.

 
from scipy.optimize import minimize 
import matplotlib.pyplot as plt
import numpy as np 
 
 

Univariate Function Optimization Example in Python

    Optimization is a technique for finding the minimum or maximum value of the function from the set of available options. Finding the shortest path from point A to point B by evaluating multiple alternative directions can be a simple example of an optimization problem. 

    Finding a single input scalar (minimum) that defines optimal output of the target function is called univariate function optimization. SciPy API provides the minimize_scalar() function to implement univariate optimization with a given method. 

    In this tutorial, you'll learn how to perform univariate function optimization by using the minimize_scalar() function with a Brent method in Python. The tutorial covers:

  1. Univariate function optimization
  2. Source code listing

 We'll start by loading the required libraries.


from scipy.optimize import minimize_scalar 
import matplotlib.pyplot as plt
import numpy as np 
 
 

MLLib Naive Bayes Classification Example with PySpark

    PySpark MLLib API provides a NaiveBayes class to classify data with Naive Bayes method. Naive Bayes, based on Bayes Theorem is a supervised learning technique to solve classification problems. The model calculates the probability and conditional probability of each class based on input data and performs the classification.

    In this tutorial, you'll briefly learn how to train and classify data by using PySpark NaiveBayes model. The tutorial covers:
  1. Preparing the data
  2. Prediction and accuracy check
  3. Source code listing
   We'll start by loading the required libraries for this tutorial.

MLlib Random Forest Classification Example with PySpark

          PySpark MLlib API provides a RandomForestClassifier class to classify data with random forest method. A random forest model is an ensemble learning algorithm based on decision tree learners. The model generates several decision trees and provides a combined result out of all outputs. Each tree in a forest votes and forest makes a decision based on all votes. A vote depends on the correlation between the trees and the strength of each tree.

    In this tutorial, we'll briefly learn how to train and classify data by using PySpark RandomForestClassifier. The tutorial covers:
  1. Preparing the data
  2. Prediction and accuracy check
  3. Source code listing
   We'll start by loading the required libraries for this tutorial.

Scattered Data Spline Fitting Example in Python

    Interpolation is a method of estimating unknown data points in a given range. Spline interpolation is a type of piecewise polynomial interpolation method. Spline interpolation is a useful method in smoothing the curve or surface data.    
    In my previous posts, I explained how to implement spline interpolation and B-spline curve fitting in Python.  We can apply the spline smoothing method to scattered data. In this tutorial, you'll learn how to fit scattered data by using spline functions in Python. 

    The tutorial covers,

  1. Preparing test data
  2. Spline curve fitting
  3. Fitting on various knots number

     We'll start by loading the required libraries for this tutorial.

 
from sklearn.datasets import load_boston
from scipy import interpolate
import matplotlib.pyplot as plt
import numpy as np 
 
 

B-spline Curve Fitting Example in Python

    B-spline or basis spline is a curve approximation method based on given coefficients. B-spline requires the parameters such as knots, spline coefficients, and degree of a spline. The SciPy API provides BSpline class to implement the B-spline fitting for a given dataset.
   In this tutorial, you'll learn how to implement B-spline interpolation by using a BSpline class in Python. The tutorial covers:

  1. B-spline interpolation
  2. Source code listing

 We'll start by loading the required libraries.

 
from scipy import interpolate
import matplotlib.pyplot as plt
import numpy as np