In [2]:
from __future__ import division
import numpy as np
from sklearn.svm import SVR
import matplotlib.pyplot as plt
import mpld3
%matplotlib inline
mpld3.enable_notebook()

In [31]:
basis = np.linspace(0,100,50)
data = 2 * np.sin(2*np.pi*basis/10) + 3 * np.sin(2*np.pi*basis/20) + 10.*np.random.random(len(basis))

In [40]:
svr_rbf = SVR(kernel='rbf', C=100000, gamma=0.1)
X = np.linspace(0,data.size,data.size)[:,None]
neg_pred = svr_rbf.fit(X[0:40], data[0:40]).predict(-X[0:10])

In [41]:
plt.plot(-basis[0:10],neg_pred, 'b-_')
plt.plot(basis,data, 'r-.')
plt.show()


So, here I've created a periodic signal and using 4 exterma as the test data as noted in the paper. I've tried to predict the test data in black, forward predict in green and back predict in blue.

The test data prediction (black) is spot on, however both the forward (green) and backward (blue) prediction are able to get the next exterma, however after that, they both decay. I am unsure on how to proceed from here.

Also, the values of $\gamma$ and C are important, however manually changing their values will get unwieldy as the EMD process needs to do this fitting multiple times for one full step of the EMD process. Is there a method to determine the "best" values for these two parameters?


In [7]:
plt.plot(basis[20:40],data[20:40]-pos_pred)


Out[7]:
[<matplotlib.lines.Line2D at 0x7f8937236a90>]