Importing Libraries and Setting up the Variables

Python libraries make it very easy for us to handle the data and perform typical and complex tasks with a single line of code.

  • Numpy – Numpy arrays are very fast and can perform large computations in a very short time.
  • Matplotlib/Seaborn – This library is used to draw visualizations.
  • Sklearn – This module contains multiple libraries having pre-implemented functions to perform tasks from data preprocessing to model development and evaluation.
  • Scipy – SciPy is a python library that is useful in solving many mathematical equations and algorithms at its core it uses NumPy to handle the numbers.

Python3




# importing necessary libraries
import numpy as np
from sklearn.covariance import LedoitWolf, OAS
from scipy.linalg import toeplitz, cholesky
import matplotlib.pyplot as plt
 
# creating seeds for high productivity
np.random.seed(0)
numOffeatures = 250
 
# Simulation Covariance Matrix
r = 0.25
# covariance estimation
realTimeCovariance = toeplitz(r ** np.arange(numOffeatures))
# matrix generation
colorMatrix = cholesky(realTimeCovariance)


Ledoit-Wolf vs OAS Estimation in Scikit Learn

Generally, Shrinkage is used to regularize the usual covariance maximum likelihood estimation. Ledoit and Wolf proposed a formula which is known as the Ledoit-Wolf covariance estimation formula; This close formula can compute the asymptotically optimal shrinkage parameter with minimizing a Mean Square Error(MSE) criterion feature. After that, one researcher Chen et al. made improvements in the Ledoit-Wolf Shrinkage parameter. He proposed Oracle Approximating Shrinkage (OAS) coefficient whose convergence is significantly better under the assumption that the data are Gaussian.

There are some basic concepts are needed  to develop the Ledoit-Wolf estimators given below  step by step:

Similar Reads

Importing Libraries and Setting up the Variables

Python libraries make it very easy for us to handle the data and perform typical and complex tasks with a single line of code....

Creating Variables to Store Results

...

Visualizing MSE and Shrinkage

Now we will initialize some NumPy matrices so, that we can store the results from the estimation to them. Here, the mean squared error calculation logic and shrinkage estimation logic of both Ledoit-Wolf and OAS is being specified....