Friday 13 April 2012

My Naive Bayesian Classifier Sanity Check

Following on from my previous post, as part of my initial attempts to "come up with a robust rule set that combines all these disparate indicators into a coherent whole," I have written a simple Octave script to conduct a basic sanity check of my Naive Bayesian Classifier. The purpose of this is to ensure that the various classifications are not wildly fluctuating between bull and bear market modes with no discernible order. This particular test identifies which market modes are indicated immediately prior to an "up with no retracement" mode being indicated. This code box shows the Octave terminal output of the test script, which is named "sliced_charts".
octave:1> sliced_charts
Enter matrix e.g. gcmatrix: clmatrix
points_of_interest =  147
uwr_to_unr =  126
uwr_to_unr_percent =  0.85714
cyc_to_unr =  16
cyc_to_unr_percent =  0.10884
octave:2> sliced_charts
Enter matrix e.g. gcmatrix: homatrix
points_of_interest =  130
uwr_to_unr =  106
uwr_to_unr_percent =  0.81538
cyc_to_unr =  20
cyc_to_unr_percent =  0.15385
octave:3> sliced_charts
Enter matrix e.g. gcmatrix: ngmatrix
points_of_interest =  123
uwr_to_unr =  104
uwr_to_unr_percent =  0.84553
cyc_to_unr =  15
cyc_to_unr_percent =  0.12195
octave:4> sliced_charts
Enter matrix e.g. gcmatrix: rbmatrix
points_of_interest =  162
uwr_to_unr =  134
uwr_to_unr_percent =  0.82716
cyc_to_unr =  23
cyc_to_unr_percent =  0.14198
octave:5> sliced_charts
Enter matrix e.g. gcmatrix: ccmatrix
points_of_interest =  123
uwr_to_unr =  95
uwr_to_unr_percent =  0.77236
cyc_to_unr =  24
cyc_to_unr_percent =  0.19512
octave:6> sliced_charts
Enter matrix e.g. gcmatrix: kcmatrix
points_of_interest =  114
uwr_to_unr =  98
uwr_to_unr_percent =  0.85965
cyc_to_unr =  14
cyc_to_unr_percent =  0.12281
octave:7> sliced_charts
Enter matrix e.g. gcmatrix: ojmatrix
points_of_interest =  129
uwr_to_unr =  109
uwr_to_unr_percent =  0.84496
cyc_to_unr =  17
cyc_to_unr_percent =  0.13178
octave:8> sliced_charts
Enter matrix e.g. gcmatrix: sbmatrix
points_of_interest =  141
uwr_to_unr =  113
uwr_to_unr_percent =  0.80142
cyc_to_unr =  23
cyc_to_unr_percent =  0.16312
octave:9> sliced_charts
Enter matrix e.g. gcmatrix: ctmatrix
points_of_interest =  114
uwr_to_unr =  90
uwr_to_unr_percent =  0.78947
cyc_to_unr =  16
cyc_to_unr_percent =  0.14035
octave:10> sliced_charts
Enter matrix e.g. gcmatrix: lbmatrix
points_of_interest =  113
uwr_to_unr =  89
uwr_to_unr_percent =  0.78761
cyc_to_unr =  19
cyc_to_unr_percent =  0.16814
octave:11> sliced_charts
Enter matrix e.g. gcmatrix: hgmatrix
points_of_interest =  132
uwr_to_unr =  118
uwr_to_unr_percent =  0.89394
cyc_to_unr =  14
cyc_to_unr_percent =  0.10606
octave:12> sliced_charts
Enter matrix e.g. gcmatrix: smatrix
points_of_interest =  141
uwr_to_unr =  118
uwr_to_unr_percent =  0.83688
cyc_to_unr =  20
cyc_to_unr_percent =  0.14184
octave:13> sliced_charts
Enter matrix e.g. gcmatrix: smmatrix
points_of_interest =  140
uwr_to_unr =  110
uwr_to_unr_percent =  0.78571
cyc_to_unr =  29
cyc_to_unr_percent =  0.20714
octave:14> sliced_charts
Enter matrix e.g. gcmatrix: bomatrix
points_of_interest =  121
uwr_to_unr =  97
uwr_to_unr_percent =  0.80165
cyc_to_unr =  16
cyc_to_unr_percent =  0.13223
octave:15> sliced_charts
Enter matrix e.g. gcmatrix: cmatrix
points_of_interest =  128
uwr_to_unr =  103
uwr_to_unr_percent =  0.80469
cyc_to_unr =  23
cyc_to_unr_percent =  0.17969
octave:16> sliced_charts
Enter matrix e.g. gcmatrix: omatrix
points_of_interest =  128
uwr_to_unr =  104
uwr_to_unr_percent =  0.81250
cyc_to_unr =  20
cyc_to_unr_percent =  0.15625
octave:17> sliced_charts
Enter matrix e.g. gcmatrix: wmatrix
points_of_interest =  105
uwr_to_unr =  91
uwr_to_unr_percent =  0.86667
cyc_to_unr =  11
cyc_to_unr_percent =  0.10476
octave:18> sliced_charts
Enter matrix e.g. gcmatrix: lcmatrix
points_of_interest =  144
uwr_to_unr =  119
uwr_to_unr_percent =  0.82639
cyc_to_unr =  23
cyc_to_unr_percent =  0.15972
octave:19> sliced_charts
Enter matrix e.g. gcmatrix: fcmatrix
points_of_interest =  132
uwr_to_unr =  110
uwr_to_unr_percent =  0.83333
cyc_to_unr =  19
cyc_to_unr_percent =  0.14394
octave:20> sliced_charts
Enter matrix e.g. gcmatrix: lhmatrix
points_of_interest =  136
uwr_to_unr =  113
uwr_to_unr_percent =  0.83088
cyc_to_unr =  21
cyc_to_unr_percent =  0.15441
octave:21> sliced_charts
Enter matrix e.g. gcmatrix: gcmatrix
points_of_interest =  137
uwr_to_unr =  118
uwr_to_unr_percent =  0.86131
cyc_to_unr =  16
cyc_to_unr_percent =  0.11679
octave:22> sliced_charts
Enter matrix e.g. gcmatrix: simatrix
points_of_interest =  121
uwr_to_unr =  102
uwr_to_unr_percent =  0.84298
cyc_to_unr =  15
cyc_to_unr_percent =  0.12397
octave:23> sliced_charts
Enter matrix e.g. gcmatrix: plmatrix
points_of_interest =  149
uwr_to_unr =  126
uwr_to_unr_percent =  0.84564
cyc_to_unr =  18
cyc_to_unr_percent =  0.12081
octave:24> sliced_charts
Enter matrix e.g. gcmatrix: pamatrix
points_of_interest =  129
uwr_to_unr =  103
uwr_to_unr_percent =  0.79845
cyc_to_unr =  22
cyc_to_unr_percent =  0.17054
octave:25> sliced_charts
Enter matrix e.g. gcmatrix: usmatrix
points_of_interest =  143
uwr_to_unr =  122
uwr_to_unr_percent =  0.85315
cyc_to_unr =  16
cyc_to_unr_percent =  0.11189
octave:26> sliced_charts
Enter matrix e.g. gcmatrix: tymatrix
points_of_interest =  148
uwr_to_unr =  128
uwr_to_unr_percent =  0.86486
cyc_to_unr =  17
cyc_to_unr_percent =  0.11486
octave:27> sliced_charts
Enter matrix e.g. gcmatrix: edmatrix
points_of_interest =  150
uwr_to_unr =  118
uwr_to_unr_percent =  0.78667
cyc_to_unr =  26
cyc_to_unr_percent =  0.17333
octave:28> sliced_charts
Enter matrix e.g. gcmatrix: dxmatrix
points_of_interest =  141
uwr_to_unr =  122
uwr_to_unr_percent =  0.86525
cyc_to_unr =  14
cyc_to_unr_percent =  0.099291
octave:29> sliced_charts
Enter matrix e.g. gcmatrix: spmatrix
points_of_interest =  158
uwr_to_unr =  123
uwr_to_unr_percent =  0.77848
cyc_to_unr =  31
cyc_to_unr_percent =  0.19620
octave:30> sliced_charts
Enter matrix e.g. gcmatrix: esmatrix
points_of_interest =  160
uwr_to_unr =  125
uwr_to_unr_percent =  0.78125
cyc_to_unr =  30
cyc_to_unr_percent =  0.18750
octave:31> sliced_charts
Enter matrix e.g. gcmatrix: ndmatrix
points_of_interest =  129
uwr_to_unr =  116
uwr_to_unr_percent =  0.89922
cyc_to_unr =  12
cyc_to_unr_percent =  0.093023
octave:32> sliced_charts
Enter matrix e.g. gcmatrix: eurusdmatrix
points_of_interest =  79
uwr_to_unr =  69
uwr_to_unr_percent =  0.87342
cyc_to_unr =  9
cyc_to_unr_percent =  0.11392
octave:33> sliced_charts
Enter matrix e.g. gcmatrix: gbpusdmatrix
points_of_interest =  84
uwr_to_unr =  72
uwr_to_unr_percent =  0.85714
cyc_to_unr =  11
cyc_to_unr_percent =  0.13095
octave:34> sliced_charts
Enter matrix e.g. gcmatrix: usdchfmatrix
points_of_interest =  80
uwr_to_unr =  73
uwr_to_unr_percent =  0.91250
cyc_to_unr =  6
cyc_to_unr_percent =  0.075000
octave:35> sliced_charts
Enter matrix e.g. gcmatrix: usdyenmatrix
points_of_interest =  74
uwr_to_unr =  62
uwr_to_unr_percent =  0.83784
cyc_to_unr =  8
cyc_to_unr_percent =  0.10811
octave:36> sliced_charts
Enter matrix e.g. gcmatrix: eurchfmatrix
points_of_interest =  93
uwr_to_unr =  80
uwr_to_unr_percent =  0.86022
cyc_to_unr =  10
cyc_to_unr_percent =  0.10753
octave:37> sliced_charts
Enter matrix e.g. gcmatrix: eurgbpmatrix
points_of_interest =  91
uwr_to_unr =  78
uwr_to_unr_percent =  0.85714
cyc_to_unr =  11
cyc_to_unr_percent =  0.12088
octave:38> sliced_charts
Enter matrix e.g. gcmatrix: euryenmatrix
points_of_interest =  103
uwr_to_unr =  88
uwr_to_unr_percent =  0.85437
cyc_to_unr =  14
cyc_to_unr_percent =  0.13592
octave:39> sliced_charts
Enter matrix e.g. gcmatrix: eurausmatrix
points_of_interest =  73
uwr_to_unr =  64
uwr_to_unr_percent =  0.87671
cyc_to_unr =  9
cyc_to_unr_percent =  0.12329
octave:40> sliced_charts
Enter matrix e.g. gcmatrix: eurcadmatrix
points_of_interest =  76
uwr_to_unr =  56
uwr_to_unr_percent =  0.73684
cyc_to_unr =  17
cyc_to_unr_percent =  0.22368
octave:41> sliced_charts
Enter matrix e.g. gcmatrix: usdcadmatrix
points_of_interest =  73
uwr_to_unr =  60
uwr_to_unr_percent =  0.82192
cyc_to_unr =  13
cyc_to_unr_percent =  0.17808
octave:42> sliced_charts
Enter matrix e.g. gcmatrix: gbpchfmatrix
points_of_interest =  98
uwr_to_unr =  84
uwr_to_unr_percent =  0.85714
cyc_to_unr =  12
cyc_to_unr_percent =  0.12245
octave:43> sliced_charts
Enter matrix e.g. gcmatrix: gbpyenmatrix
points_of_interest =  97
uwr_to_unr =  84
uwr_to_unr_percent =  0.86598
cyc_to_unr =  11
cyc_to_unr_percent =  0.11340
octave:44> sliced_charts
Enter matrix e.g. gcmatrix: auscadmatrix
points_of_interest =  107
uwr_to_unr =  92
uwr_to_unr_percent =  0.85981
cyc_to_unr =  14
cyc_to_unr_percent =  0.13084
octave:45> sliced_charts
Enter matrix e.g. gcmatrix: aususdmatrix
points_of_interest =  97
uwr_to_unr =  82
uwr_to_unr_percent =  0.84536
cyc_to_unr =  14
cyc_to_unr_percent =  0.14433
octave:46> sliced_charts
Enter matrix e.g. gcmatrix: ausyenmatrix
points_of_interest =  103
uwr_to_unr =  89
uwr_to_unr_percent =  0.86408
cyc_to_unr =  11
cyc_to_unr_percent =  0.10680
  • The clmatrix indicates which market is being tested e.g. crude oil (cl)
  • points of interest is the number of times the market mode changes to "up with no retracement" from a previously different classification
  • uwr_to_unr is the number of times such a change is from "up with retracement" to "up with no retracement"
  • cyc_to_unr is similarly from "cyclic" to "up with no retracement"
  • the *_percent is the previous two expressed as a percentage of the points of interest
It is pleasing to see such high percentages overall. I will perform a similar analysis for "down with retracement" and discuss the significance of this in my next post.

No comments: