Univariate method

This method focuses on removing values that fall far away from the median value for a single value. Typically, the evaluation metric is called the cleaning parameter. This parameter will define which values to remove from the distribution. Choosing an aggressive cleaning parameter could remove diverse data. On the contrary, choosing too large of a cleaning parameter won't change much about the distribution.

Here's an example of how to perform a univariate fit on some sample data:

#!/usr/bin/env python
from numpy import linspace,exp
from numpy.random import randn
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline

########## Univariate Fit
x = linspace(-5, 5, 200)
y = exp(-x**2) + randn(200)/10
s = UnivariateSpline(x, y, s=1)
xs = linspace(-5, 5, 1000)
ys = s(xs)
plt.plot(x, y, '.-')
plt.plot(xs, ys)
plt.show()0

Here's the breakdown of the code:

  1. Import all of the required packages to attempt this section:
#!/usr/bin/env python
from numpy import linspace,exp
from numpy.random import randn
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline
  1. Define the line:
########## Univariate Fit
x = linspace(-5, 5, 200)
y = exp(-x**2) + randn(200)/10
  1. Fit a univariate model to the data:
s = UnivariateSpline(x, y, s=1)
  1. Define parameters for the line:
xs = linspace(-5, 5, 1000)
ys = s(xs)
  1. Plot the parameters:
plt.plot(x, y, '.-')
plt.plot(xs, ys)
plt.show()0
  1. Create a Dockerfile and install it in the imbalanced-learn package:
FROM base_image

ADD demo.py /demo.py
  1. Create a run file:
#/bin/bash
nvidia-docker build -t ch2 .

xhost +
docker run -it
--runtime=nvidia
--rm
-e DISPLAY=$DISPLAY
-v /tmp/.X11-unix:/tmp/.X11-unix
ch2 python demo.py
  1. Run the code by issuing this command at the Terminal:
sudo ./run.sh
  1. Following are the results from running this code:

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.182.62