Exemple #1
0
var_index = data.columns.values.tolist()

# vector of class responses associated with data
resp = load_data.getResponseMatrix1D()
resp2 = load_data.getResponseMatrix2D()

#### Create object to normalize and un-normalize data
norm_trans = pre.StandardScaler().fit(d)
data_norm = norm_trans.transform(d)

#### Train OPLS
opls = OPLS(2, resp2).fit(data_norm, resp)

#### Train PLS for comparison
pls = PLS(2).fit(data_norm, resp)
pls.rotated_data = pls.transform(data_norm)
pls.responses = resp2

#### Figures
opls.plotProjectionScatterMultiClass(2, labels=["Healthy", "Not Healthy"])
OPLS.plotProjectionScatterMultiClass(pls, 2, labels=["Healthy", "Not Healthy"])

plt.figure()
plt.plot(opls.analysis.coef_[:, 0]**2)
#plt.plot(opls.analysis.coef_[:,1]**2)
plt.title("OPLS Weights")

plt.figure()
plt.plot(pls.coef_[:, 0]**2)
#plt.plot(pls.x_weights_[:,1]**2)
plt.title("PLS Weights")