Skip to content

Commit

Permalink
test cases added
Browse files Browse the repository at this point in the history
  • Loading branch information
Gscorreia89 committed Nov 27, 2017
1 parent 75abad8 commit a426f15
Show file tree
Hide file tree
Showing 23 changed files with 2,484 additions and 231 deletions.
2 changes: 1 addition & 1 deletion pyChemometrics/ChemometricsPCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def cross_validation(self, x, cv_method=KFold(7, True), outputdist=False, press_
# Assemble the dictionary and data matrices

self.cvParameters = {'Mean_VarExpRatio_Training': np.array(cv_varexplained_training).mean(axis=0),
'Stdev_VarExpRatio_Training': np.array(cv_varexplained_training).mean(axis=0),
'Stdev_VarExpRatio_Training': np.array(cv_varexplained_training).std(axis=0),
'Mean_VarExp_Test': np.mean(cv_varexplained_test),
'Stdev_VarExp_Test': np.std(cv_varexplained_test),
'Q2': q_squared}
Expand Down
4 changes: 2 additions & 2 deletions pyChemometrics/ChemometricsPLS.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def dmodx(self, x):
:return: The Normalised DmodX measure for each sample
"""
resids_ssx = self._residual_ssx(x)
s = np.sqrt(resids_ssx/(self.loadings_p.shape[1] - self.ncomps))
s = np.sqrt(resids_ssx/(self.loadings_p.shape[0] - self.ncomps))
dmodx = np.sqrt((s/self.modelParameters['S0X'])**2)
return dmodx

Expand Down Expand Up @@ -896,7 +896,7 @@ def cross_validation(self, x, y, cv_method=KFold(7, True), outputdist=False,
# Store everything...
self.cvParameters = {'Q2X': q_squaredx, 'Q2Y': q_squaredy, 'MeanR2X_Training': np.mean(R2X_training),
'MeanR2Y_Training': np.mean(R2Y_training), 'StdevR2X_Training': np.std(R2X_training),
'StdevR2Y_Training': np.std(R2X_training), 'MeanR2X_Test': np.mean(R2X_test),
'StdevR2Y_Training': np.std(R2Y_training), 'MeanR2X_Test': np.mean(R2X_test),
'MeanR2Y_Test': np.mean(R2Y_test), 'StdevR2X_Test': np.std(R2X_test),
'StdevR2Y_Test': np.std(R2Y_test), 'Mean_Loadings_q': cv_loadings_q.mean(0),
'Stdev_Loadings_q': cv_loadings_q.std(0), 'Mean_Loadings_p': cv_loadings_p.mean(0),
Expand Down
6 changes: 6 additions & 0 deletions tests/test_data/pca_cvloads.csv

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions tests/test_data/pca_dmodx.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
9.547376961753462066e-01
9.134740377440152548e-01
9.842701383396834647e-01
9.836699856730368730e-01
9.326253893852096688e-01
1.001708853877684602e+00
9.025494297656555531e-01
9.218346863457997920e-01
9.843910690320103463e-01
8.995566039350099130e-01
1.026222835362880170e+00
8.955576038509589498e-01
1.009725911484453675e+00
1.007834747199417791e+00
9.539441176181948645e-01
1.028741229385197853e+00
8.642982065052304819e-01
8.836940372455542869e-01
1.023890341453291164e+00
9.974846455984128779e-01
1.039254082586831496e+00
1.012418347832000132e+00
9.283675994460589553e-01
9.822058819958369158e-01
9.934262141600184171e-01
9.673194962164211042e-01
1.064093641416990144e+00
1.002620298536794019e+00
9.636817480969475103e-01
9.136389972525551517e-01
9.220140398107449231e-01
9.295380941017938881e-01
9.390269790418417362e-01
9.599846518180223942e-01
8.803473498642546691e-01
9.449256342528226105e-01
1.003120926502196975e+00
9.301976094030653952e-01
9.469911129479037237e-01
9.612956184120269310e-01
9.655866608148460095e-01
9.245286067378550854e-01
9.805635267834800217e-01
9.215028436139562906e-01
9.012275003721835764e-01
9.367326031629195082e-01
1.022791253922555654e+00
9.879571060789544834e-01
9.490283072078524729e-01
8.535581206675064703e-01
200 changes: 200 additions & 0 deletions tests/test_data/pls_betas.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
-1.674513092061086922e-02
6.381051733661757819e-02
1.065227472421580515e-02
3.346870675391705290e-03
-1.427334254916423975e-02
6.569500166303836319e-02
7.281314810589848384e-03
-6.201410075608012468e-02
-3.173384700688089421e-02
1.032402742510815305e-02
3.467555430476414267e-03
2.064564965515705564e-02
3.403098616044916702e-03
3.783429416627589331e-02
-2.787488873378988347e-03
-3.561716089901897225e-02
1.126575683989128329e-02
-1.900302572870866263e-02
2.604550578423189822e-02
2.489149987742058506e-02
9.758052839553506275e-03
1.851878833098708280e-02
6.562814342591065386e-02
2.991483221214649713e-02
9.927121281124419439e-03
-8.985658189418363473e-03
4.115822675201876932e-03
1.303034521605426002e-02
-2.977537879518609570e-02
2.234220072518418310e-02
5.469329777701221335e-02
5.102661855502343274e-02
1.814298565290684007e-02
5.011093117923179352e-03
-4.634310132988119640e-03
1.128005735166679770e-02
4.661724799938300745e-02
-4.982126107831993250e-03
9.034842402921794413e-02
1.530888649750023790e-02
-1.978683599887670966e-02
1.949295771858360754e-02
1.824646935631036443e-02
-1.504658772146159201e-02
-2.542584436830095523e-02
7.749675922316603006e-05
-1.335843132970728452e-02
-1.142694341038918981e-02
2.129334342850567816e-02
-1.531785444871861662e-02
5.533044602092716813e-03
-3.085767737845927783e-02
4.166221251186095348e-02
-9.033136418974265641e-03
-2.724782614505988701e-02
-1.714501026261514016e-02
-5.738702102858050241e-04
-9.324947911327029562e-03
-1.629316873403144350e-02
-4.476680613700668998e-02
-1.924537438983084381e-02
2.933780441443945008e-02
2.608750156724396266e-02
2.960726442148307012e-03
-3.273367552497733618e-02
-3.914848346245448397e-03
2.634859315283939393e-02
-4.213482319880740984e-03
4.727083622664947360e-02
2.076646267466488328e-03
2.309119285318981390e-02
4.128217511480737623e-02
-4.673258316381567658e-04
-1.199750165452099886e-02
-2.152128112593101536e-02
-3.933017618114514197e-02
3.690857928042425018e-02
-3.835599501037467024e-02
-6.998301989199540163e-02
5.172107162722275331e-02
2.504937060061642601e-02
1.495109790487849331e-02
-1.430419252136162778e-02
-1.395058627240414531e-02
-2.135244327595241243e-02
-1.223263743540846035e-02
5.408672528633118835e-04
2.573634705303343845e-02
-6.717933367616337262e-03
1.887584506103862081e-02
3.433244847515343201e-02
2.191801841848224630e-02
3.757487889227023592e-02
9.061154794924283773e-02
3.769497662103861446e-03
1.467904543393474051e-02
-1.404384088275271655e-02
5.419292581157929972e-02
1.059971392011506246e-02
-2.739008316694563350e-02
2.637388642452629522e-02
-2.629453047320832321e-02
2.238061249520764684e-03
-4.685894855002829817e-02
-5.779797753214743761e-02
1.174730618235341958e-02
-4.690239881891848650e-02
7.723071122123467691e-02
-1.899724627280966610e-02
-3.937686008504235648e-03
6.697315923635635548e-02
-2.183953002037516966e-02
1.223964984671004064e-02
-3.622066832997462849e-02
-3.063559626483304890e-02
2.397232741060550953e-02
3.584148836742480360e-02
6.902796383752369397e-03
-5.794263745288690676e-02
-6.049739406711680985e-04
5.971673455482764958e-02
9.707908571682000165e-02
7.400507260034294710e-02
3.151794532028705936e-02
-2.001955588252358337e-02
-2.180641600359188928e-02
1.003215910792861973e-02
6.935094107522482391e-03
1.727776141753912392e-02
6.244629363326368449e-02
2.197266711183865073e-02
-4.324477311171820437e-02
-3.656672218824459641e-02
5.072512987117017147e-02
7.364669242102661606e-03
-3.885205633225091715e-02
-2.324252017736764056e-02
-8.930061590119045198e-03
3.050361679217159210e-03
-9.930350861138005636e-03
1.654016411562910308e-02
-5.144867161974704672e-02
5.595418554995535559e-02
6.319904084475350126e-02
-7.430142509107320881e-02
-2.609810830760637967e-02
-4.900717000544331514e-02
4.008453894359649550e-02
4.221123776572126979e-02
-2.247418709055682556e-02
2.188795474952334036e-02
2.438757751424040082e-02
3.288226951192740888e-03
3.606145850195170699e-02
6.284329873848852827e-04
-5.238934281849229498e-03
7.835619795188351194e-03
-8.543461480753579418e-02
3.914857789633053448e-02
-2.255600144459325718e-02
-1.325353693664368254e-02
-2.318974577832596043e-02
-8.305022351738101938e-02
-2.546238242999676257e-02
-1.529308734359976531e-02
-3.449135498610384626e-02
9.274583969900027786e-03
6.268654272853198609e-03
3.097152742840471318e-02
1.897937355085733968e-02
3.072121283174233941e-02
-1.784926561285942598e-02
-1.711230805833728608e-02
-6.023818269418949184e-03
1.394165933540217860e-02
2.538383264779345977e-02
-6.164818518486724769e-03
-9.728540136505725924e-03
1.811019123268079942e-02
-2.061036564507966878e-02
-1.971990793150094068e-02
5.043820466786677961e-03
4.756656126537225915e-02
-1.769210262443471002e-02
-2.386321673373085345e-02
3.711331836965944819e-02
-2.655579216614718796e-02
2.671795844199740394e-02
1.103352963092090952e-02
1.006855281108964550e-01
6.499913031194026920e-03
-2.671876809201738368e-02
-3.217777847150809362e-02
6.934771215165223823e-02
-1.732847562592464488e-02
-2.568700679373409068e-02
-2.971534139552490378e-02
2.512791339130080945e-02
3.027687762150269371e-02
-8.551355889434869573e-03
Loading

0 comments on commit a426f15

Please sign in to comment.