|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
还是接上一期,上一期中我们已经准备好了训练数据以及标签数据,这期我就来分享如何搭建神经网络,如何训练数据,以及验证数据。
由于系统的输出,其实是1~5分,每个分值的概率,并不是一个确定的数,我们可以选取概率最高的那一项作为最终判断依据。
同时由于评分系统,本身也是一个比较主观的判别,所以我这里假设“如果机器输出的评分与实际评分的差值在1分以内,那么就姑且认为,机器判断正确。”比如,机器评分是5分,实际评分4分,那么至少可以认为机器判断的大方向是正确的。
来看看最后测试的结果:Number 1:
Predict Possibility:[0.99978167, 0.00021406148, 1.945744e-08, 9.819261e-09, 4.2863462e-06]
Predict Score: 1
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 2:
Predict Possibility:[0.001749899, 0.019494539, 0.73307097, 0.22133107, 0.024353491]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 3:
Predict Possibility:[0.029935809, 0.87214047, 0.092281148, 0.0033485622, 0.0022940091]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 4:
Predict Possibility:[0.00019793805, 0.99956518, 0.00023677615, 6.241082e-08, 5.7142415e-08]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 5:
Predict Possibility:[1.4945568e-05, 0.73525119, 0.26472792, 5.4393436e-06, 5.2597414e-07]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 6:
Predict Possibility:[0.0026597835, 0.95268631, 0.044455651, 0.00013314823, 6.5051252e-05]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 7:
Predict Possibility:[0.014282497, 0.087877244, 0.61626542, 0.21083198, 0.070742927]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 8:
Predict Possibility:[0.36809433, 0.63032234, 0.0011776465, 7.2351344e-05, 0.00033329072]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 9:
Predict Possibility:[0.99707258, 0.0029270439, 2.2190827e-08, 1.9557271e-09, 3.4118415e-07]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 10:
Predict Possibility:[0.0030183396, 0.9950316, 0.0019369514, 6.3654961e-06, 6.5967661e-06]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 11:
Predict Possibility:[0.97626036, 0.023463689, 3.0414765e-05, 9.3924855e-06, 0.0002361587]
Predict Score: 1
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 12:
Predict Possibility:[0.018464254, 0.087961212, 0.58183986, 0.23066187, 0.081072807]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 13:
Predict Possibility:[0.0030755131, 0.99611998, 0.00079955411, 2.1763813e-06, 2.8958607e-06]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 14:
Predict Possibility:[3.17949e-07, 7.3178785e-06, 0.0091606667, 0.98511201, 0.0057197628]
Predict Score: 4
Actual Score: 2
Predict almost correct:False
--------------------------------------------------
Number 15:
Predict Possibility:[0.99712485, 0.0028635394, 4.278412e-07, 1.1975935e-07, 1.1031056e-05]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 16:
Predict Possibility:[4.1829567e-06, 0.99997771, 1.8132665e-05, 1.2520859e-10, 9.2483937e-11]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 17:
Predict Possibility:[0.26556373, 0.708574, 0.0180513, 0.0026462707, 0.0051647187]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 18:
Predict Possibility:[0.38454115, 0.60722184, 0.0054740882, 0.00067909533, 0.0020838324]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 19:
Predict Possibility:[0.016069626, 0.85926974, 0.12065408, 0.0026253448, 0.001381196]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 20:
Predict Possibility:[0.00081175449, 0.76025605, 0.23861784, 0.00025126003, 6.3193729e-05]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 21:
Predict Possibility:[1.2798245e-07, 0.62911129, 0.37088853, 8.648864e-08, 2.3916837e-09]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 22:
Predict Possibility:[2.4768139e-09, 0.0056000142, 0.99439949, 4.645546e-07, 2.6838578e-09]
Predict Score: 3
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 23:
Predict Possibility:[1.6440014e-06, 0.38783067, 0.61216575, 1.9073186e-06, 9.6662298e-08]
Predict Score: 3
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 24:
Predict Possibility:[2.8320055e-10, 1.2149406e-05, 0.99996698, 2.0927348e-05, 2.8747523e-08]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 25:
Predict Possibility:[0.00076608628, 0.97383952, 0.025363227, 2.1711397e-05, 9.418799e-06]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 26:
Predict Possibility:[0.00018270146, 0.00051389594, 0.011806442, 0.55720007, 0.43029684]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 27:
Predict Possibility:[0.00012066097, 0.99522674, 0.0046515488, 7.0832465e-07, 3.0226664e-07]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 28:
Predict Possibility:[2.4015327e-16, 1.1673271e-10, 0.4990401, 0.50095981, 4.2516245e-08]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 29:
Predict Possibility:[0.00068837643, 0.016749892, 0.90618634, 0.069677636, 0.0066976938]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 30:
Predict Possibility:[0.10551931, 0.44131756, 0.30974817, 0.08310058, 0.060314428]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 31:
Predict Possibility:[0.0078189503, 0.99213177, 4.8955131e-05, 8.3885681e-08, 2.8432581e-07]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 32:
Predict Possibility:[0.02107277, 0.73274088, 0.23590836, 0.0068197749, 0.0034581576]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 33:
Predict Possibility:[0.0020512643, 0.0086253304, 0.17381483, 0.68661886, 0.12888967]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 34:
Predict Possibility:[9.1872016e-10, 1.3279191e-06, 0.51040971, 0.48952273, 6.6221015e-05]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 35:
Predict Possibility:[0.0079116439, 0.83752668, 0.1523692, 0.0015186104, 0.00067385682]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 36:
Predict Possibility:[0.00031755649, 0.038468704, 0.95421988, 0.0062324563, 0.00076133828]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 37:
Predict Possibility:[0.0010956764, 0.98616576, 0.012714136, 1.5632688e-05, 8.7877124e-06]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 38:
Predict Possibility:[2.5317388e-06, 2.3361629e-06, 2.6291145e-06, 0.00022691744, 0.99976557]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 39:
Predict Possibility:[0.041211907, 0.25633502, 0.55134398, 0.10117358, 0.049935602]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 40:
Predict Possibility:[7.9837363e-08, 6.7659398e-06, 0.055280365, 0.94332987, 0.0013829548]
Predict Score: 4
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 41:
Predict Possibility:[0.0098136812, 0.25057128, 0.70300764, 0.02760813, 0.0089991959]
Predict Score: 3
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 42:
Predict Possibility:[6.7260204e-05, 0.014236595, 0.98193687, 0.0034765007, 0.00028273536]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 43:
Predict Possibility:[0.0030983579, 0.31307846, 0.67615592, 0.0061809598, 0.0014863645]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 44:
Predict Possibility:[2.5579032e-16, 2.2038807e-13, 2.4026351e-06, 0.99999464, 2.9341929e-06]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 45:
Predict Possibility:[0.0018732431, 0.99060458, 0.007494424, 1.6311955e-05, 1.1477965e-05]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 46:
Predict Possibility:[4.1918689e-08, 0.079176739, 0.92082286, 4.3357056e-07, 6.7512764e-09]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 47:
Predict Possibility:[7.8204951e-15, 1.5113388e-09, 0.67332542, 0.32667443, 1.2761181e-07]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 48:
Predict Possibility:[5.2045416e-06, 0.0011575436, 0.99053919, 0.0081364876, 0.00016147984]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 49:
Predict Possibility:[0.75803947, 0.23929189, 0.00106043, 0.00020250832, 0.0014056897]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 50:
Predict Possibility:[6.648439e-10, 6.4270607e-06, 0.99920017, 0.00079290685, 5.1661476e-07]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 51:
Predict Possibility:[1.0031947e-11, 2.8070545e-07, 0.9934057, 0.0065937871, 2.4725531e-07]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 52:
Predict Possibility:[0.0019405648, 0.16798998, 0.81847215, 0.0096642775, 0.0019330508]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 53:
Predict Possibility:[1.9138809e-19, 3.7794025e-16, 6.3598421e-08, 0.99999952, 3.3644682e-07]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 54:
Predict Possibility:[4.1230389e-05, 0.99941981, 0.00053901359, 3.1615645e-08, 1.7947073e-08]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 55:
Predict Possibility:[0.040703885, 0.28460628, 0.55194974, 0.082353614, 0.040386446]
Predict Score: 3
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 56:
Predict Possibility:[2.8098571e-05, 0.060048155, 0.93960822, 0.0002926364, 2.2850296e-05]
Predict Score: 3
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 57:
Predict Possibility:[0.99983847, 0.00016152223, 1.793413e-11, 8.7558937e-13, 1.2652568e-09]
Predict Score: 1
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 58:
Predict Possibility:[3.9769656e-21, 3.3190367e-16, 5.2806413e-06, 0.99999475, 5.8578569e-09]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 59:
Predict Possibility:[0.0040138466, 0.99572915, 0.00025537427, 6.0185016e-07, 1.1102981e-06]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 60:
Predict Possibility:[0.0074199182, 0.98913711, 0.003391237, 2.4120118e-05, 2.7514376e-05]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 61:
Predict Possibility:[1.0360038e-19, 8.7302034e-16, 7.5469706e-07, 0.99999917, 6.7287928e-08]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 62:
Predict Possibility:[4.1458546e-07, 3.0232593e-06, 0.00099521922, 0.91140521, 0.087596171]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 63:
Predict Possibility:[0.00027665365, 0.0024075049, 0.15298101, 0.80187827, 0.042456631]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 64:
Predict Possibility:[0.92989427, 0.058779825, 0.00099350221, 0.00069477852, 0.0096377367]
Predict Score: 1
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 65:
Predict Possibility:[1.2883065e-05, 9.9215242e-05, 0.015684599, 0.95245647, 0.031746864]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 66:
Predict Possibility:[0.0096183503, 0.045081377, 0.44473192, 0.39892894, 0.10163943]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 67:
Predict Possibility:[0.00067466247, 0.0066967369, 0.45317701, 0.50049978, 0.038951825]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 68:
Predict Possibility:[0.099439964, 0.28288212, 0.25645891, 0.17516327, 0.18605575]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 69:
Predict Possibility:[0.10747682, 0.44292602, 0.30526102, 0.083338402, 0.060997762]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 70:
Predict Possibility:[4.0889014e-10, 9.046639e-10, 1.3751382e-07, 0.0082037579, 0.99179608]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 71:
Predict Possibility:[0.006222195, 0.99377549, 2.2611459e-06, 9.572253e-10, 6.9270651e-09]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 72:
Predict Possibility:[0.026823549, 0.051497415, 0.20580362, 0.46183497, 0.25404039]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 73:
Predict Possibility:[0.04396842, 0.079821795, 0.24103843, 0.38504076, 0.25013062]
Predict Score: 4
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 74:
Predict Possibility:[9.6110945e-08, 1.5236938e-06, 0.0019731268, 0.9896605, 0.0083647026]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 75:
Predict Possibility:[0.19224049, 0.73230624, 0.050376493, 0.010585361, 0.014491459]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 76:
Predict Possibility:[0.061446313, 0.069888279, 0.05692175, 0.10978007, 0.70196366]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 77:
Predict Possibility:[3.5639728e-13, 2.6462983e-09, 0.056990914, 0.94300431, 4.6820687e-06]
Predict Score: 4
Actual Score: 2
Predict almost correct:False
--------------------------------------------------
Number 78:
Predict Possibility:[0.0060484577, 0.0088391239, 0.034181871, 0.27369407, 0.67723656]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 79:
Predict Possibility:[3.340036e-13, 5.2139287e-10, 0.0020533567, 0.99793673, 9.949541e-06]
Predict Score: 4
Actual Score: 2
Predict almost correct:False
--------------------------------------------------
Number 80:
Predict Possibility:[0.00094432174, 0.99766809, 0.0013847881, 1.4591e-06, 1.348765e-06]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 81:
Predict Possibility:[0.0064718565, 0.10280412, 0.82768059, 0.049548432, 0.013495017]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 82:
Predict Possibility:[0.012666906, 0.054497514, 0.508614, 0.33211887, 0.092102818]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 83:
Predict Possibility:[7.4404702e-06, 1.9381503e-05, 0.00082668621, 0.34425291, 0.65489358]
Predict Score: 5
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 84:
Predict Possibility:[0.0077068214, 0.092611872, 0.81398714, 0.067579471, 0.018114781]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 85:
Predict Possibility:[0.053289354, 0.081964917, 0.1784678, 0.32879388, 0.35748413]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 86:
Predict Possibility:[0.31548786, 0.68427277, 0.00019627386, 5.1096686e-06, 3.7958089e-05]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 87:
Predict Possibility:[0.00015761144, 0.99560285, 0.0042383149, 7.7341389e-07, 3.7316445e-07]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 88:
Predict Possibility:[0.00077690143, 0.51131743, 0.48701829, 0.00074550963, 0.00014183376]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 89:
Predict Possibility:[0.99997318, 2.6761954e-05, 1.55458e-12, 1.2127761e-13, 4.3249798e-10]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 90:
Predict Possibility:[0.31862581, 0.68114579, 0.00019248901, 4.3991054e-06, 3.1616732e-05]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 91:
Predict Possibility:[0.067549959, 0.93242145, 2.7448583e-05, 1.2574104e-07, 9.5011552e-07]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 92:
Predict Possibility:[0.96599704, 0.033997566, 1.3045666e-06, 8.0879914e-08, 4.0490149e-06]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 93:
Predict Possibility:[0.99925882, 0.00074119115, 1.2948463e-09, 1.1612746e-10, 5.1471602e-08]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 94:
Predict Possibility:[0.99936563, 0.00063443772, 7.831979e-14, 1.5762636e-16, 8.5652579e-13]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 95:
Predict Possibility:[0.18903033, 0.72600454, 0.058533769, 0.011605574, 0.014825732]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 96:
Predict Possibility:[0.00088497868, 0.0062669669, 0.29361662, 0.64823258, 0.050998855]
Predict Score: 4
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 97:
Predict Possibility:[0.0061750896, 0.063813761, 0.79895449, 0.10679697, 0.024259808]
Predict Score: 3
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 98:
Predict Possibility:[1.9304123e-08, 1.2375758e-06, 0.0105387, 0.98841548, 0.0010445031]
Predict Score: 4
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 99:
Predict Possibility:[2.1676867e-06, 0.99997628, 2.1501339e-05, 8.8876531e-11, 5.3165635e-11]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 100:
Predict Possibility:[1.0447113e-06, 1.5469643e-05, 0.0080780843, 0.98161131, 0.010294101]
Predict Score: 4
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 101:
Predict Possibility:[0.48907915, 0.51092005, 6.7363209e-07, 2.6255698e-09, 1.0578933e-07]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 102:
Predict Possibility:[0.0069594625, 0.022057883, 0.21890378, 0.59826291, 0.15381594]
Predict Score: 4
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 103:
Predict Possibility:[0.99999952, 4.2196024e-07, 8.7963338e-15, 1.6259172e-15, 3.5294444e-11]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 104:
Predict Possibility:[0.99667114, 0.0022221406, 3.3895778e-06, 3.6514086e-06, 0.0010996303]
Predict Score: 1
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 105:
Predict Possibility:[0.26235712, 0.73444515, 0.0025146278, 0.00016065149, 0.00052239432]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 106:
Predict Possibility:[0.00017040125, 0.12850773, 0.87033617, 0.00088024017, 0.00010555823]
Predict Score: 3
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 107:
Predict Possibility:[4.3093469e-13, 3.3492026e-10, 0.00063779787, 0.99935025, 1.1970588e-05]
Predict Score: 4
Actual Score: 1
Predict almost correct:False
--------------------------------------------------
Number 108:
Predict Possibility:[4.5704606e-15, 2.7721882e-11, 0.0013685082, 0.99863029, 1.1898574e-06]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 109:
Predict Possibility:[0.0012802647, 0.99865663, 6.295793e-05, 4.2348827e-08, 8.6382713e-08]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 110:
Predict Possibility:[0.00084443478, 0.99901128, 0.00014399432, 1.0058852e-07, 1.4971874e-07]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 111:
Predict Possibility:[3.7467261e-27, 2.5167735e-22, 1.2319636e-10, 1.0, 3.4848041e-10]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 112:
Predict Possibility:[1.1196017e-08, 0.99805731, 0.0019426033, 2.8811691e-11, 2.0592781e-12]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 113:
Predict Possibility:[0.51494515, 0.47959396, 0.0032019776, 0.00044691126, 0.0018120192]
Predict Score: 1
Actual Score: 3
Predict almost correct:False
--------------------------------------------------
Number 114:
Predict Possibility:[0.00013029973, 0.99885607, 0.0010133232, 1.7896308e-07, 1.1360333e-07]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 115:
Predict Possibility:[7.7053358e-10, 3.0460902e-07, 0.041396204, 0.95841318, 0.00019037558]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 116:
Predict Possibility:[0.1077923, 0.44580114, 0.30347088, 0.082472377, 0.060463268]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 117:
Predict Possibility:[0.06658002, 0.60889912, 0.27173272, 0.031939086, 0.020849016]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 118:
Predict Possibility:[0.015414838, 0.54250866, 0.42580703, 0.011565114, 0.0047043278]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 119:
Predict Possibility:[0.56928021, 0.39519289, 0.01403851, 0.0051012454, 0.016387101]
Predict Score: 1
Actual Score: 3
Predict almost correct:False
--------------------------------------------------
Number 120:
Predict Possibility:[1.406141e-05, 0.99958128, 0.00040466228, 8.7359622e-09, 4.1285366e-09]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 121:
Predict Possibility:[0.92911875, 0.070861876, 6.2244812e-06, 4.0912946e-07, 1.2729563e-05]
Predict Score: 1
Actual Score: 3
Predict almost correct:False
--------------------------------------------------
Number 122:
Predict Possibility:[8.9000801e-16, 6.1684197e-13, 3.4043871e-06, 0.9999913, 5.1957809e-06]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 123:
Predict Possibility:[5.1893721e-07, 7.6749157e-06, 0.0055228998, 0.98498881, 0.0094800675]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 124:
Predict Possibility:[0.050421685, 0.9232952, 0.023912566, 0.0011205114, 0.0012500185]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 125:
Predict Possibility:[0.016460489, 0.63691419, 0.33408606, 0.0087325042, 0.0038068152]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 126:
Predict Possibility:[6.8988033e-05, 0.00051734562, 0.047122538, 0.91190922, 0.040381886]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 127:
Predict Possibility:[0.03805425, 0.014788249, 0.0027491017, 0.0089561278, 0.93545222]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 128:
Predict Possibility:[0.023102911, 0.047671873, 0.22114356, 0.47407895, 0.23400277]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 129:
Predict Possibility:[2.6069528e-12, 3.7803571e-10, 6.5014043e-05, 0.99986374, 7.1282921e-05]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 130:
Predict Possibility:[0.00019725173, 0.00011438046, 6.2228035e-05, 0.0011395197, 0.99848664]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 131:
Predict Possibility:[7.9201314e-14, 1.2251193e-11, 4.656757e-06, 0.99995315, 4.2179425e-05]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 132:
Predict Possibility:[2.7820257e-05, 1.9723133e-05, 1.4285762e-05, 0.00053031446, 0.99940789]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 133:
Predict Possibility:[0.00010248242, 0.00066609966, 0.049347892, 0.90719104, 0.042692512]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 134:
Predict Possibility:[3.6338328e-11, 2.8742749e-11, 3.2611466e-10, 1.0653712e-05, 0.99998939]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 135:
Predict Possibility:[0.0048658275, 0.9939388, 0.0011844127, 4.5837792e-06, 6.2858467e-06]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 136:
Predict Possibility:[7.269399e-07, 0.21419765, 0.78579897, 2.6080231e-06, 8.3470979e-08]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 137:
Predict Possibility:[0.0086272592, 0.98832673, 0.0029948077, 2.2811058e-05, 2.8360162e-05]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 138:
Predict Possibility:[1.2481048e-07, 3.0834472e-05, 0.51169425, 0.4877634, 0.00051141292]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 139:
Predict Possibility:[4.3326559e-10, 1.4947829e-05, 0.99995351, 3.1484022e-05, 4.3982212e-08]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 140:
Predict Possibility:[0.016509458, 0.77295858, 0.20376574, 0.004546525, 0.0022196376]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 141:
Predict Possibility:[0.038213897, 0.092296079, 0.31159803, 0.35356155, 0.20433047]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 142:
Predict Possibility:[0.15114881, 0.84885061, 6.4485317e-07, 7.8627171e-10, 2.1930118e-08]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 143:
Predict Possibility:[0.7107836, 0.22398949, 0.0093808221, 0.0067311358, 0.049114976]
Predict Score: 1
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 144:
Predict Possibility:[2.3588107e-05, 0.0025851135, 0.97981137, 0.017081337, 0.00049868849]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 145:
Predict Possibility:[0.015290137, 0.15065567, 0.69349903, 0.10510475, 0.035450473]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 146:
Predict Possibility:[9.8189385e-06, 5.4739849e-05, 0.0058587827, 0.91667634, 0.077400275]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 147:
Predict Possibility:[2.2148245e-07, 3.3027365e-05, 0.37560675, 0.62324578, 0.0011141406]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 148:
Predict Possibility:[0.0040556011, 0.86387897, 0.13113914, 0.00066282618, 0.00026343489]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 149:
Predict Possibility:[0.019476004, 0.98052382, 2.0578507e-07, 5.4594083e-11, 1.1067972e-09]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 150:
Predict Possibility:[0.015751356, 0.041134607, 0.2666997, 0.50116175, 0.17525262]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 151:
Predict Possibility:[0.99925882, 0.00071588025, 2.2524364e-07, 1.2192609e-07, 2.4900619e-05]
Predict Score: 1
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 152:
Predict Possibility:[0.47606996, 0.52247351, 0.000985055, 7.42021e-05, 0.00039727884]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 153:
Predict Possibility:[0.00091835862, 0.036487658, 0.93394238, 0.025162669, 0.0034889306]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 154:
Predict Possibility:[0.02717923, 0.35434246, 0.55481356, 0.044719253, 0.018945528]
Predict Score: 3
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 155:
Predict Possibility:[0.67950916, 0.11476571, 0.0080757216, 0.010661366, 0.18698798]
Predict Score: 1
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 156:
Predict Possibility:[0.036206517, 0.10606736, 0.42694196, 0.29159039, 0.13919376]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 157:
Predict Possibility:[2.3387176e-05, 0.010924245, 0.98733008, 0.0016286294, 9.3691022e-05]
Predict Score: 3
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 158:
Predict Possibility:[2.6294106e-06, 1.7309663e-05, 0.0033548574, 0.94149762, 0.055127591]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 159:
Predict Possibility:[2.0049051e-06, 0.001663012, 0.99712521, 0.0011846491, 2.510278e-05]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 160:
Predict Possibility:[7.5846979e-10, 4.169196e-06, 0.97258466, 0.027406108, 5.1421171e-06]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 161:
Predict Possibility:[0.016644008, 0.21632792, 0.68493503, 0.060263474, 0.021829607]
Predict Score: 3
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 162:
Predict Possibility:[0.0072965585, 0.062408667, 0.75120908, 0.14306605, 0.036019728]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 163:
Predict Possibility:[0.0078164684, 0.014341813, 0.049737036, 0.22459127, 0.70351338]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 164:
Predict Possibility:[0.0012387553, 0.0037556265, 0.063236438, 0.77535081, 0.15641834]
Predict Score: 4
Actual Score: 2
Predict almost correct:False
--------------------------------------------------
Number 165:
Predict Possibility:[0.00028455275, 0.00054105301, 0.006492856, 0.32750642, 0.66517508]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 166:
Predict Possibility:[2.7654393e-10, 1.0762714e-06, 0.93707258, 0.062919788, 6.5902582e-06]
Predict Score: 3
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 167:
Predict Possibility:[0.00056727178, 0.99880171, 0.00063035125, 4.057446e-07, 3.9708934e-07]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 168:
Predict Possibility:[0.17113808, 0.082353681, 0.019737342, 0.041215006, 0.68555588]
Predict Score: 5
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 169:
Predict Possibility:[0.00040685889, 5.8849917e-05, 7.9428673e-06, 0.00014954126, 0.99937683]
Predict Score: 5
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 170:
Predict Possibility:[0.00017883933, 0.0023749562, 0.33017519, 0.64246553, 0.024805419]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 171:
Predict Possibility:[0.05189357, 0.89569438, 0.047371984, 0.0025766268, 0.0024634132]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 172:
Predict Possibility:[1.9338552e-16, 1.1127415e-09, 0.99994349, 5.6496585e-05, 5.3778263e-11]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 173:
Predict Possibility:[0.018974822, 0.64573902, 0.32199895, 0.0090878047, 0.004199408]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 174:
Predict Possibility:[0.00082107587, 0.0016279365, 0.016763831, 0.43557939, 0.5452078]
Predict Score: 5
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 175:
Predict Possibility:[2.3579194e-06, 0.9987098, 0.0012878488, 4.3792636e-09, 1.0837183e-09]
Predict Score: 2
Actual Score: 5
Predict almost correct:False
--------------------------------------------------
Number 176:
Predict Possibility:[9.7077015e-15, 2.9360709e-09, 0.92764801, 0.072351962, 4.3945551e-08]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 177:
Predict Possibility:[0.00019593647, 0.00084419589, 0.030738836, 0.84218931, 0.12603173]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 178:
Predict Possibility:[0.014376077, 0.033392131, 0.19044048, 0.52174032, 0.24005097]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 179:
Predict Possibility:[2.6301268e-25, 8.9849053e-21, 8.4295798e-10, 1.0, 1.894862e-09]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 180:
Predict Possibility:[0.0066577233, 0.01579194, 0.12339226, 0.62377423, 0.23038392]
Predict Score: 4
Actual Score: 5
Predict almost correct:True
--------------------------------------------------
Number 181:
Predict Possibility:[0.00056249596, 0.99932885, 0.00010852599, 5.7118882e-08, 8.0392901e-08]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 182:
Predict Possibility:[7.6552373e-05, 0.0056557371, 0.97501433, 0.01838021, 0.00087316107]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 183:
Predict Possibility:[0.0045400746, 0.047104467, 0.78909987, 0.13217863, 0.027076963]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 184:
Predict Possibility:[0.0038373903, 0.098275751, 0.85889435, 0.031902194, 0.0070902891]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 185:
Predict Possibility:[0.08347971, 0.81663281, 0.083744638, 0.0084103178, 0.0077326382]
Predict Score: 2
Actual Score: 1
Predict almost correct:True
--------------------------------------------------
Number 186:
Predict Possibility:[1.8254592e-05, 0.4386276, 0.56132847, 2.3781835e-05, 1.8477496e-06]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 187:
Predict Possibility:[0.0049517285, 0.69198626, 0.30022633, 0.0021052484, 0.00073044369]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 188:
Predict Possibility:[3.1529158e-14, 3.8490519e-10, 0.028988415, 0.97100979, 1.7154946e-06]
Predict Score: 4
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 189:
Predict Possibility:[2.9600938e-05, 0.010746003, 0.98676866, 0.0023258554, 0.0001298126]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 190:
Predict Possibility:[0.0017581395, 0.99558568, 0.0026455836, 5.6728245e-06, 4.8574461e-06]
Predict Score: 2
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 191:
Predict Possibility:[0.00010708478, 0.99989212, 7.3772634e-07, 3.0679185e-11, 9.8099646e-11]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 192:
Predict Possibility:[6.0813036e-05, 0.0087831467, 0.98338264, 0.0073647248, 0.00040863291]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 193:
Predict Possibility:[0.99695051, 0.0030284161, 5.1060164e-07, 1.6654373e-07, 2.0423317e-05]
Predict Score: 1
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
Number 194:
Predict Possibility:[0.00041997863, 0.026518919, 0.95873278, 0.012854496, 0.0014738034]
Predict Score: 3
Actual Score: 4
Predict almost correct:True
--------------------------------------------------
Number 195:
Predict Possibility:[0.037879463, 0.068869658, 0.2169282, 0.40290517, 0.27341756]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 196:
Predict Possibility:[0.0011491809, 0.82274115, 0.17579585, 0.00024293464, 7.0851631e-05]
Predict Score: 2
Actual Score: 4
Predict almost correct:False
--------------------------------------------------
Number 197:
Predict Possibility:[0.00082571863, 0.12878795, 0.86404121, 0.0055132709, 0.00083184725]
Predict Score: 3
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 198:
Predict Possibility:[0.00055521168, 0.99929249, 0.00015207804, 8.1493965e-08, 1.0853429e-07]
Predict Score: 2
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 199:
Predict Possibility:[3.3302055e-07, 9.3414983e-06, 0.013019409, 0.98241085, 0.0045600072]
Predict Score: 4
Actual Score: 3
Predict almost correct:True
--------------------------------------------------
Number 200:
Predict Possibility:[0.00012237504, 0.080679148, 0.91759813, 0.001466056, 0.00013423694]
Predict Score: 3
Actual Score: 2
Predict almost correct:True
--------------------------------------------------
75.5 percent predict almost correct.
可以看到,有超过3/4的预测与实际评分相差1分以内,可以说明机器评分的在大方向上还是比较可靠的。
可以提高准确率的方法还有,这个在后一期中介绍。
来看看,整个建模过程:
打开昨天保存的训练数据和标签数据with open('x_data.p', 'rb') as x:
x_data = pickle.load(x)
with open('y_data.p', 'rb') as y:
y_data = pickle.load(y)
#建模,用全连接模型
model = Sequential()
#添加输入层,一共15207个词向量,提取1024个特征值(这个特征值的大小可以自己调试,会影响到最终的准确率,太少准确率会变差,但是速度会快。但是太高,准确率同样会变差,因为把每个值都当作特征,其实就等于没有特征了。)
model.add(Dense(1024, input_dim=15207))
#添加sigmoid激励函数
model.add(Activation('sigmoid'))
#添加隐藏层
model.add(Dense(1024))
#添加sigmoid激励函数
model.add(Activation('sigmoid'))
#再加隐藏层
model.add(Dense(512))
#添加relu激励函数
model.add(Activation('relu'))
#还是加隐藏层
model.add(Dense(512))
#添加relu激励函数
model.add(Activation('relu'))
#最终加输出层
model.add(Dense(5))
#添加softmax激励函数,用于分类
model.add(Activation('softmax'))
#编译模型,用RMSprop优化器,评价函数用categorical_crossentropy(与softmax搭配),增加准确率监控
model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
#训练模型,训练20次,每次1800多条数据
model.fit(x_data[200:, :], y_data[200:, :], batch_size=50, nb_epoch=20, verbose=True)
#保存训练结果
model.save('douban.h5')
#用前200条数据进行测试f = open('Predict_result.txt', 'w')
c = 0
for k in range(200):
temp = list(model.predict(x_data[k:k+1, :])[0])
score = temp.index(max(temp))+1
for i in range(5):
if y_data[k:k+1, :][0][i] == 1:
act_score = i+1
result = True if abs(act_score-score) <= 1 else False
if result: c += 1
print 'Number %d:' % (k+1)
print 'Predict Possibility:' , temp
print 'Predict Score: %d' % score
print ' Actual Score: %d' % act_score
print 'Predict almost correct:', result
print '-'*30
f.write('Number %d:' % (k+1) + '\n')
f.write('Predict Possibility:' + str(temp) + '\n')
f.write('Predict Score: %d' % score + '\n')
f.write(' Actual Score: %d' % act_score + '\n')
f.write('Predict almost correct:' + str(result) + '\n')
f.write('-'*50 + '\n')
print '%.1f percent predict almost correct.' % (c/2.0)
f.write('%.1f percent predict almost correct.' % (c/2.0))
f.close()
完整代码:
在下一期中,我会分享如何把这套系统运用到实际电影评分中去,如何把一段电影评论转化为电影评分,以及之后可以如何改良这套系统。
敬请期待! |
|