Regression Example With ARDRegression in Python

    Automatic Relevance Determination (ARD) is based on Bayesian inference method. Scikit-learn API provides ADRRegression class to fit the regression model by using ARD method. The ADRRegression considers the model weights as a Gaussian distributed and  estimates the lambda and alpha parameters through the iteration.

    In this tutorial, we'll briefly learn how to fit and predict regression data by using ARDRegression class in Python. We'll apply the model for a randomly generated regression data and Boston housing price dataset to check the performance. The tutorial covers:

  1. Preparing the data
  2. Training the model
  3. Predicting and accuracy check
  4. Boston housing dataset prediction
  5. Source code listing
   We'll start by loading the required libraries.

Regression Example With RPART Tree Model in R

    Decision trees can be implemented by using the 'rpart' package in R. The 'rpart' package extends to Recursive Partitioning and Regression Trees which applies the tree-based model for regression and classification problems.

    In this tutorial, we'll briefly learn how to fit and predict regression data by using 'rpart' function in R. The tutorial covers:
  1. Preparing the data
  2. Fitting the model and prediction
  3. Accuracy checking
  4. Source code listing
We'll start by loading the required libraries.

library(rpart)
library(caret)

Classification Example with KNeighborsClassifier in Python

      The k-neighbors is commonly used and easy to apply classification method which implements the k neighbors queries to classify data. It is an instant-based and non-parametric learning method. In this method, the classifier learns from the instances in the training dataset and classifies new input by using the previously measured scores. 

    Scikit-learn API provides the KNeighborsClassifier class to implement k-neighbors method for classification problems. In this tutorial, we'll briefly learn how to classify data by using the KNeighborsClassifier class in Python. The tutorial covers:

  1. Preparing the data
  2. Training the model
  3. Predicting and accuracy check
  4. Iris dataset classification example
  5. Source code listing
   We'll start by loading the required libraries and functions.

from sklearn.neighbors import KNeighborsClassifier
from sklearn.datasets import load_iris
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
 

Regression Example With DecisionTreeRegressor in Python

    Decision tree is one of the well known and powerful supervised machine learning algorithms that can be used for classification and regression problems. The model is based on decision rules extracted from the training data. In regression problem, the model uses the value instead of class and mean squared error is used to for a decision accuracy.

    Decision tree model is not good in generalization and sensitive to the changes in training data. A small change in a training dataset may effect the model predictive accuracy.

     Scikit-learn API provides the DecisionTreeRegressor class to apply decision tree method for regression task. 

    In this tutorial, we'll briefly learn how to fit and predict regression data by using the DecisionTreeRegressor class in Python. We'll apply the model for a randomly generated regression data and Boston housing dataset to check the performance. The tutorial covers:

  1. Preparing the data
  2. Training the model
  3. Predicting and accuracy check
  4. Boston housing dataset prediction
  5. Source code listing
   We'll start by loading the required libraries.

Regression Example with RandomForestRegressor in Python

    Random forest is an ensemble learning algorithm based on decision tree learners. The estimator fits multiple decision trees on randomly extracted subsets from the dataset and averages their prediction.

    Scikit-learn API provides the RandomForestRegressor class included in ensemble module to implement the random forest for regression problem. 

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

  1. Preparing the data
  2. Training the model
  3. Predicting and accuracy check
  4. Boston dataset prediction
  5. Source code listing
   We'll start by loading the required libraries.

Fitting Example With SciPy curve_fit Function in Python

    The SciPy API provides a 'curve_fit' function in its optimization library to fit the data with a given function. This method applies non-linear least squares to fit the data and extract the optimal parameters out of it. 

    In this tutorial, we'll learn how to fit the curve with the curve_fit() function by using various fitting functions in Python. 

    We'll start by loading the required libraries.

from numpy import array, exp
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt