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 
 
 

Spline Interpolation Example in Python

     Interpolation is a method of estimating unknown data points in a given dataset range. Discovering new values between two data points makes the curve smoother. Spline interpolation is a type of piecewise polynomial interpolation method.
    The SciPy API provides several functions to implement the interpolation method for a given dataset.

    In this tutorial, you'll learn how to apply interpolation for a given dataset by using SciPy API functions in Python. The tutorial covers;

  1. Preparing test data
  2. Direct spline interpolation
  3. Spline interpolation with InterpolatedUnivariateSpline
  4. Source code listing

    We'll start by loading the required libraries.

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

PySpark Generalized Linear Regression Example

    Generalized linear regression is a linear regression that follows any distribution other than normal distribution. PySpark provides a GeneralizedLinearRegression model that includes Gaussian, Poisson, logistic regression methods to predict regression problems.

    In this tutorial, we'll briefly learn how to fit and predict regression data by using PySpark GeneralizedLinearRegression in Python. The tutorial covers:

  1. Preparing the data
  2. Prediction and accuracy check
  3. Visualizing the results
  4. Source code listing
   We'll start by loading the required libraries for this tutorial.

Fourier Transform Example with SciPy Functions

    A Fourier transform is a method to decompose signal data in a frequency components. By using this function, we can transform a time domain signal into the frequency domain one and a vice versa. It is widely used in signal processing and many other applications. 

    Discrete Fourier Transform (DFT) is an algorithm to transform a discrete (finite-duration) signal data. Fast Fourier Transform (FFT) is an efficient algorithm that implements DFT. 

    SciPy API provides several functions to implement Fourier transform.  

    In this tutorial, we'll briefly learn how to transform and inverse transform a signal data by SciPy API functions. The tutorial covers:

  1. Preparing the data
  2. Transform with fft()
  3. Transform with rfft()
  4. Inverse transform
  5. Source code listing
   We'll start by loading the required libraries for this tutorial.

PySpark Decision Tree Classification Example

         PySpark MLlib library provides a DecisionTreeClassifier model to implement classification with decision tree method. A decision tree method is one of the well known and powerful supervised machine learning algorithms that can be used for classification and regression tasks. It is a tree-like, top-down flow learning method to extract rules from the training data. The branches of the tree are based on certain decision outcomes.

    In this tutorial, we'll briefly learn how to fit and classify data by using PySpark DecisionTreeClassifier. 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.