添加15章代码和测试数据

This commit is contained in:
chenyyx
2017-04-08 01:08:05 +08:00
parent 2528ec734c
commit 1cc59bfc71
18 changed files with 1514 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
No handlers could be found for logger "mrjob.job"
using configs in c:/Users/Peter\.mrjob.conf
creating tmp directory /scratch/$USER\mrSVM.Peter.20111230.181815.061000
reading from STDIN
> 'c:\Python27\python.exe' mrSVM.py --step-num=0 --mapper '/scratch/$USER\mrSVM.Peter.20111230.181815.061000\input_part-00000'
writing to /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-0-mapper_part-00000
> 'c:\Python27\python.exe' mrSVM.py --step-num=0 --mapper '/scratch/$USER\mrSVM.Peter.20111230.181815.061000\input_part-00001'
writing to /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-0-mapper_part-00001
STDERR: No handlers could be found for logger "mrjob.job"
STDERR: No handlers could be found for logger "mrjob.job"
Counters from step 1:
(no counters found)
writing to /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-0-mapper-sorted
> sort '/scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-0-mapper_part-00000' '/scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-0-mapper_part-00001'
Piping files into sort for Windows compatibility
> sort
> 'c:\Python27\python.exe' mrSVM.py --step-num=0 --reducer '/scratch/$USER\mrSVM.Peter.20111230.181815.061000\input_part-00000'
writing to /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-0-reducer_part-00000
STDERR: No handlers could be found for logger "mrjob.job"
Counters from step 1:
(no counters found)
> 'c:\Python27\python.exe' mrSVM.py --step-num=1 --mapper '/scratch/$USER\mrSVM.Peter.20111230.181815.061000\input_part-00000'
writing to /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-1-mapper_part-00000
> 'c:\Python27\python.exe' mrSVM.py --step-num=1 --mapper '/scratch/$USER\mrSVM.Peter.20111230.181815.061000\input_part-00001'
writing to /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-1-mapper_part-00001
STDERR: No handlers could be found for logger "mrjob.job"
STDERR: No handlers could be found for logger "mrjob.job"
Counters from step 2:
(no counters found)
writing to /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-1-mapper-sorted
Piping files into sort for Windows compatibility
> sort
> 'c:\Python27\python.exe' mrSVM.py --step-num=1 --reducer '/scratch/$USER\mrSVM.Peter.20111230.181815.061000\input_part-00000'
writing to /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-1-reducer_part-00000
STDERR: No handlers could be found for logger "mrjob.job"
Counters from step 2:
(no counters found)
Moving /scratch/$USER\mrSVM.Peter.20111230.181815.061000\step-1-reducer_part-00000 -> /scratch/$USER\mrSVM.Peter.20111230.181815.061000\output\part-00000
Streaming final output from /scratch/$USER\mrSVM.Peter.20111230.181815.061000\output
removing tmp directory /scratch/$USER\mrSVM.Peter.20111230.181815.061000

View File

@@ -0,0 +1,3 @@
jj I am so sick of TV
ss jar jar got a purse
22 shit ass

View File

@@ -0,0 +1,101 @@
["w", [0.001, 0.001]]
["x", 79]
["x", 115]
["x", 107]
["x", 109]
["x", 109]
["x", 88]
["x", 56]
["x", 94]
["x", 50]
["x", 86]
["x", 75]
["x", 30]
["x", 20]
["x", 157]
["x", 15]
["x", 19]
["x", 63]
["x", 124]
["x", 132]
["x", 3]
["x", 140]
["x", 139]
["x", 127]
["x", 98]
["x", 30]
["x", 16]
["x", 4]
["x", 2]
["x", 75]
["x", 123]
["x", 42]
["x", 16]
["x", 94]
["x", 163]
["x", 159]
["x", 23]
["x", 16]
["x", 160]
["x", 5]
["x", 42]
["x", 53]
["x", 83]
["x", 46]
["x", 121]
["x", 73]
["x", 123]
["x", 93]
["x", 99]
["x", 106]
["x", 173]
["x", 192]
["x", 132]
["x", 57]
["x", 47]
["x", 164]
["x", 157]
["x", 199]
["x", 62]
["x", 175]
["x", 154]
["x", 110]
["x", 0]
["x", 116]
["x", 49]
["x", 76]
["x", 121]
["x", 178]
["x", 75]
["x", 167]
["x", 41]
["x", 105]
["x", 71]
["x", 5]
["x", 135]
["x", 80]
["x", 116]
["x", 198]
["x", 164]
["x", 105]
["x", 98]
["x", 156]
["x", 72]
["x", 54]
["x", 62]
["x", 57]
["x", 87]
["x", 68]
["x", 163]
["x", 140]
["x", 40]
["x", 70]
["x", 120]
["x", 172]
["x", 71]
["x", 82]
["x", 168]
["x", 42]
["x", 144]
["x", 27]
["x", 36]

View File

@@ -0,0 +1,200 @@
0.365032 2.465645 -1.000000
-2.494175 -0.292380 -1.000000
-3.039364 -0.123108 -1.000000
1.348150 0.255696 1.000000
2.768494 1.234954 1.000000
1.232328 -0.601198 1.000000
4.404247 3.393022 1.000000
0.697004 -2.009448 1.000000
-3.373117 -0.713336 -1.000000
2.723211 0.775903 1.000000
2.901695 1.707367 1.000000
-1.829946 0.607276 -1.000000
1.472144 -0.388337 1.000000
-1.032174 1.591800 -1.000000
-2.419741 -0.226650 -1.000000
1.336037 2.564594 -1.000000
-1.503680 1.256279 -1.000000
4.375646 2.089091 1.000000
-2.618399 -0.145791 -1.000000
0.175550 2.171503 -1.000000
-1.813659 0.861575 -1.000000
1.365379 -2.079521 1.000000
1.132693 -1.134835 1.000000
-1.909842 -0.203375 -1.000000
2.083515 -0.123439 1.000000
-2.942829 -0.263256 -1.000000
-0.550709 2.932391 -1.000000
2.345072 -0.738737 1.000000
-2.812098 0.556459 -1.000000
-0.517398 0.162645 -1.000000
-2.462396 0.010699 -1.000000
2.560602 -0.591844 1.000000
-2.232060 -1.372427 -1.000000
-0.228876 -3.268298 1.000000
3.941297 2.489183 1.000000
-2.858850 -1.349790 -1.000000
2.421014 -0.355223 1.000000
-1.112512 1.194459 -1.000000
-2.596897 -1.137791 -1.000000
2.238589 1.900233 1.000000
2.180268 1.177119 1.000000
-2.674983 -0.522555 -1.000000
-1.070534 -0.269203 -1.000000
0.634596 -1.968924 1.000000
-3.056496 -2.411444 -1.000000
-3.125469 -2.560011 -1.000000
-2.015606 0.258282 -1.000000
-1.742318 0.888477 -1.000000
1.321158 -0.087550 1.000000
0.931512 -1.726051 1.000000
-0.215167 1.522793 -1.000000
2.346521 0.316568 1.000000
2.138992 1.315335 1.000000
-3.631578 -1.493405 -1.000000
-0.713435 1.015818 -1.000000
-2.963170 -0.128725 -1.000000
-0.911295 1.120257 -1.000000
1.823362 1.383358 1.000000
3.912515 1.761468 1.000000
-3.142532 -1.332066 -1.000000
4.106318 2.468945 1.000000
2.208287 -0.357459 1.000000
-3.223791 -0.832623 -1.000000
-2.285363 -0.520775 -1.000000
2.565906 -0.456137 1.000000
-0.979234 1.913094 -1.000000
-2.389694 -2.358041 -1.000000
-2.652054 -1.866190 -1.000000
0.683886 -1.883523 1.000000
1.154997 -1.465108 1.000000
3.348935 0.365574 1.000000
2.987531 0.346268 1.000000
1.700014 -0.555228 1.000000
1.980124 0.139488 1.000000
0.978690 -1.633039 1.000000
2.593800 0.862643 1.000000
-2.251246 -0.353172 -1.000000
1.557428 -1.383201 1.000000
-2.597244 -1.826710 -1.000000
-2.886051 -1.337213 -1.000000
1.325410 0.845017 1.000000
1.837022 -0.151031 1.000000
-3.667084 -2.656341 -1.000000
-1.096365 0.149693 -1.000000
-2.971056 -2.411501 -1.000000
-2.465852 -0.235159 -1.000000
-2.394111 0.351272 -1.000000
1.515098 -0.965912 1.000000
2.158202 -0.966015 1.000000
-1.713482 -0.251601 -1.000000
-2.913806 -2.850934 -1.000000
1.705200 -0.789277 1.000000
3.421766 0.864792 1.000000
-1.762714 1.500557 -1.000000
-2.955547 0.049390 -1.000000
2.717396 1.466253 1.000000
-2.359607 -1.360212 -1.000000
2.573551 0.246011 1.000000
-2.515645 -1.120265 -1.000000
0.678309 -3.889064 1.000000
1.629286 -0.451862 1.000000
-1.484039 -0.211054 -1.000000
-3.791016 -0.954143 -1.000000
-2.843098 -0.847371 -1.000000
-2.170293 1.091531 -1.000000
-2.422544 -2.382615 -1.000000
-3.703473 -3.821757 -1.000000
-2.392575 2.190457 -1.000000
-1.311822 -1.069374 -1.000000
2.844847 1.022544 1.000000
1.123290 -0.470348 1.000000
0.459137 -2.125968 1.000000
4.034205 1.542917 1.000000
-0.934692 0.334676 -1.000000
-0.531720 2.098752 -1.000000
1.579150 -1.497762 1.000000
-3.052029 0.297103 -1.000000
0.259368 -0.931559 1.000000
2.223190 0.019637 1.000000
1.695683 -0.067089 1.000000
3.783554 2.380405 1.000000
-0.742719 1.599089 -1.000000
-3.034314 -1.068352 -1.000000
-2.603808 -0.125287 -1.000000
-3.444958 -3.611816 -1.000000
2.045444 -0.443405 1.000000
3.128574 0.859356 1.000000
0.690041 -0.852001 1.000000
2.055697 0.696273 1.000000
-2.772761 -1.353757 -1.000000
-2.989774 -1.698669 -1.000000
-2.376270 -1.554052 -1.000000
2.696921 1.840741 1.000000
1.808514 0.574293 1.000000
0.758408 0.621123 -1.000000
0.087100 -2.424081 1.000000
-1.965351 0.714902 -1.000000
-2.455455 -0.864560 -1.000000
2.242510 2.271935 1.000000
3.768713 1.966209 1.000000
1.781191 -1.035869 1.000000
3.428376 4.010583 1.000000
1.126828 0.854183 1.000000
-3.438612 -2.229961 -1.000000
-1.677236 1.302989 -1.000000
-0.457661 2.454553 -1.000000
-1.253217 0.094550 -1.000000
3.631693 -0.584668 1.000000
1.325739 -1.474299 1.000000
-2.468865 -0.954717 -1.000000
0.373049 -0.744924 1.000000
-2.724934 -1.931014 -1.000000
2.315489 1.487273 1.000000
-1.004495 0.396042 -1.000000
-2.633016 -2.421408 -1.000000
0.892135 -3.181581 1.000000
-2.142382 -1.194070 -1.000000
1.429072 4.755911 -1.000000
-1.470911 -0.587141 -1.000000
2.857367 0.926472 1.000000
2.209276 -0.856140 1.000000
0.636235 -1.853421 1.000000
-1.609996 1.717916 -1.000000
1.825889 -0.367680 1.000000
-1.300348 0.535824 -1.000000
1.234706 1.175943 1.000000
-2.958675 -2.503623 -1.000000
-3.104957 -0.401067 -1.000000
-3.257189 0.883429 -1.000000
1.748296 -2.783532 1.000000
-2.858730 -1.187591 -1.000000
2.776790 1.009201 1.000000
-3.020057 -1.590170 -1.000000
-2.758262 -0.589067 -1.000000
2.254778 -0.419287 1.000000
3.959366 2.400563 1.000000
0.042104 1.919803 -1.000000
-2.036118 0.639606 -1.000000
0.879784 -0.726036 1.000000
-2.004450 -0.741610 -1.000000
1.695901 -1.279977 1.000000
1.083409 -1.833836 1.000000
-0.910787 -0.004560 -1.000000
1.781328 -1.148702 1.000000
-1.977490 0.922950 -1.000000
-3.231551 -2.366104 -1.000000
-1.613525 0.913540 -1.000000
3.775281 3.594941 1.000000
-2.147825 2.515202 -1.000000
2.357556 -0.453303 1.000000
2.101682 1.621048 1.000000
2.583247 1.999725 1.000000
-0.701349 3.523552 -1.000000
-2.996146 -1.187950 -1.000000
2.993353 1.271228 1.000000
-1.773598 1.032358 -1.000000
-1.806425 0.713270 -1.000000
4.134091 2.962575 1.000000
-0.379995 0.272405 -1.000000
2.601370 1.032435 1.000000

View File

@@ -0,0 +1,303 @@
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 79]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 115]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 107]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 109]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 109]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 88]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 56]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 94]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 50]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 86]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 75]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 30]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 20]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 157]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 15]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 19]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 63]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 124]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 132]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 3]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 140]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 139]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 127]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 98]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 30]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 16]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 4]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 2]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 75]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 123]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 42]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 16]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 94]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 163]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 159]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 23]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 16]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 160]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 5]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 42]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 53]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 83]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 46]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 121]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 73]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 123]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 93]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 99]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 106]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 173]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 192]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 132]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 57]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 47]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 164]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 157]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 199]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 62]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 175]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 154]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 110]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 0]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 116]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 49]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 76]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 121]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 178]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 75]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 167]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 41]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 105]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 71]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 5]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 135]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 80]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 116]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 198]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 164]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 105]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 98]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 156]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 72]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 54]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 62]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 57]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 87]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 68]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 163]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 140]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 40]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 70]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 120]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 172]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 71]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 82]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 168]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 42]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 144]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 27]
shape(self.w): (2,)
shape(X[index,:]) (1, 2)
1 ["u", 36]
in the map_fin
1 ["w", [0.001, 0.001]]
1 ["t", 1]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,200 @@
0.365032 2.465645 -1
-2.494175 -0.292380 -1
-3.039364 -0.123108 -1
1.348150 0.255696 1
2.768494 1.234954 1
1.232328 -0.601198 1
4.404247 3.393022 1
0.697004 -2.009448 1
-3.373117 -0.713336 -1
2.723211 0.775903 1
2.901695 1.707367 1
-1.829946 0.607276 -1
1.472144 -0.388337 1
-1.032174 1.591800 -1
-2.419741 -0.226650 -1
1.336037 2.564594 -1
-1.503680 1.256279 -1
4.375646 2.089091 1
-2.618399 -0.145791 -1
0.175550 2.171503 -1
-1.813659 0.861575 -1
1.365379 -2.079521 1
1.132693 -1.134835 1
-1.909842 -0.203375 -1
2.083515 -0.123439 1
-2.942829 -0.263256 -1
-0.550709 2.932391 -1
2.345072 -0.738737 1
-2.812098 0.556459 -1
-0.517398 0.162645 -1
-2.462396 0.010699 -1
2.560602 -0.591844 1
-2.232060 -1.372427 -1
-0.228876 -3.268298 1
3.941297 2.489183 1
-2.858850 -1.349790 -1
2.421014 -0.355223 1
-1.112512 1.194459 -1
-2.596897 -1.137791 -1
2.238589 1.900233 1
2.180268 1.177119 1
-2.674983 -0.522555 -1
-1.070534 -0.269203 -1
0.634596 -1.968924 1
-3.056496 -2.411444 -1
-3.125469 -2.560011 -1
-2.015606 0.258282 -1
-1.742318 0.888477 -1
1.321158 -0.087550 1
0.931512 -1.726051 1
-0.215167 1.522793 -1
2.346521 0.316568 1
2.138992 1.315335 1
-3.631578 -1.493405 -1
-0.713435 1.015818 -1
-2.963170 -0.128725 -1
-0.911295 1.120257 -1
1.823362 1.383358 1
3.912515 1.761468 1
-3.142532 -1.332066 -1
4.106318 2.468945 1
2.208287 -0.357459 1
-3.223791 -0.832623 -1
-2.285363 -0.520775 -1
2.565906 -0.456137 1
-0.979234 1.913094 -1
-2.389694 -2.358041 -1
-2.652054 -1.866190 -1
0.683886 -1.883523 1
1.154997 -1.465108 1
3.348935 0.365574 1
2.987531 0.346268 1
1.700014 -0.555228 1
1.980124 0.139488 1
0.978690 -1.633039 1
2.593800 0.862643 1
-2.251246 -0.353172 -1
1.557428 -1.383201 1
-2.597244 -1.826710 -1
-2.886051 -1.337213 -1
1.325410 0.845017 1
1.837022 -0.151031 1
-3.667084 -2.656341 -1
-1.096365 0.149693 -1
-2.971056 -2.411501 -1
-2.465852 -0.235159 -1
-2.394111 0.351272 -1
1.515098 -0.965912 1
2.158202 -0.966015 1
-1.713482 -0.251601 -1
-2.913806 -2.850934 -1
1.705200 -0.789277 1
3.421766 0.864792 1
-1.762714 1.500557 -1
-2.955547 0.049390 -1
2.717396 1.466253 1
-2.359607 -1.360212 -1
2.573551 0.246011 1
-2.515645 -1.120265 -1
0.678309 -3.889064 1
1.629286 -0.451862 1
-1.484039 -0.211054 -1
-3.791016 -0.954143 -1
-2.843098 -0.847371 -1
-2.170293 1.091531 -1
-2.422544 -2.382615 -1
-3.703473 -3.821757 -1
-2.392575 2.190457 -1
-1.311822 -1.069374 -1
2.844847 1.022544 1
1.123290 -0.470348 1
0.459137 -2.125968 1
4.034205 1.542917 1
-0.934692 0.334676 -1
-0.531720 2.098752 -1
1.579150 -1.497762 1
-3.052029 0.297103 -1
0.259368 -0.931559 1
2.223190 0.019637 1
1.695683 -0.067089 1
3.783554 2.380405 1
-0.742719 1.599089 -1
-3.034314 -1.068352 -1
-2.603808 -0.125287 -1
-3.444958 -3.611816 -1
2.045444 -0.443405 1
3.128574 0.859356 1
0.690041 -0.852001 1
2.055697 0.696273 1
-2.772761 -1.353757 -1
-2.989774 -1.698669 -1
-2.376270 -1.554052 -1
2.696921 1.840741 1
1.808514 0.574293 1
0.758408 0.621123 -1
0.087100 -2.424081 1
-1.965351 0.714902 -1
-2.455455 -0.864560 -1
2.242510 2.271935 1
3.768713 1.966209 1
1.781191 -1.035869 1
3.428376 4.010583 1
1.126828 0.854183 1
-3.438612 -2.229961 -1
-1.677236 1.302989 -1
-0.457661 2.454553 -1
-1.253217 0.094550 -1
3.631693 -0.584668 1
1.325739 -1.474299 1
-2.468865 -0.954717 -1
0.373049 -0.744924 1
-2.724934 -1.931014 -1
2.315489 1.487273 1
-1.004495 0.396042 -1
-2.633016 -2.421408 -1
0.892135 -3.181581 1
-2.142382 -1.194070 -1
1.429072 4.755911 -1
-1.470911 -0.587141 -1
2.857367 0.926472 1
2.209276 -0.856140 1
0.636235 -1.853421 1
-1.609996 1.717916 -1
1.825889 -0.367680 1
-1.300348 0.535824 -1
1.234706 1.175943 1
-2.958675 -2.503623 -1
-3.104957 -0.401067 -1
-3.257189 0.883429 -1
1.748296 -2.783532 1
-2.858730 -1.187591 -1
2.776790 1.009201 1
-3.020057 -1.590170 -1
-2.758262 -0.589067 -1
2.254778 -0.419287 1
3.959366 2.400563 1
0.042104 1.919803 -1
-2.036118 0.639606 -1
0.879784 -0.726036 1
-2.004450 -0.741610 -1
1.695901 -1.279977 1
1.083409 -1.833836 1
-0.910787 -0.004560 -1
1.781328 -1.148702 1
-1.977490 0.922950 -1
-3.231551 -2.366104 -1
-1.613525 0.913540 -1
3.775281 3.594941 1
-2.147825 2.515202 -1
2.357556 -0.453303 1
2.101682 1.621048 1
2.583247 1.999725 1
-0.701349 3.523552 -1
-2.996146 -1.187950 -1
2.993353 1.271228 1
-1.773598 1.032358 -1
-1.806425 0.713270 -1
4.134091 2.962575 1
-0.379995 0.272405 -1
2.601370 1.032435 1

View File

@@ -0,0 +1,200 @@
2.566588 -0.566564 1
3.813758 2.148214 1
3.803649 2.297096 1
2.996947 -1.156863 1
2.018915 -0.905604 1
2.722914 2.050793 1
2.992540 0.604431 1
1.973198 -0.416027 1
4.231757 2.197621 1
-3.423482 -1.666829 -1
3.017583 -0.852549 1
2.378933 -0.068925 1
2.827171 0.112122 1
3.099968 -0.314056 1
-1.237312 2.041868 -1
5.192917 2.756125 1
-2.572959 -1.407749 -1
-1.972541 0.113997 -1
3.410411 -1.471934 1
3.635269 -1.067406 1
-5.139639 -2.996639 -1
-1.880483 -0.648054 -1
-2.168873 0.526882 -1
5.642283 1.221138 1
4.229408 1.263818 1
-2.563922 -0.132134 -1
-3.001167 -0.958829 -1
-5.180670 -0.967162 -1
3.264381 0.843975 1
2.925061 0.211085 1
3.208235 0.049203 1
2.109814 1.020155 1
4.043111 0.038868 1
-2.993809 -0.153942 -1
-4.343854 0.002387 -1
2.770473 0.027766 1
-2.071658 1.145849 -1
-3.521452 0.245865 -1
-3.271004 0.002030 -1
-1.343470 4.378228 -1
2.276676 0.155982 1
-4.068011 -0.647258 -1
-1.850638 2.210614 -1
-4.639977 -1.031178 -1
-4.684251 -3.087190 -1
2.940128 0.940271 1
1.863125 -0.838375 1
2.568502 0.070915 1
2.899899 -1.277806 1
3.352340 -0.713969 1
-4.317466 0.852795 -1
3.201230 0.976139 1
3.822834 0.069645 1
2.692972 -0.176728 1
-1.146605 2.081193 -1
2.998234 1.141442 1
2.312164 -1.269429 1
3.396265 0.862029 1
3.274000 -0.696190 1
-2.595839 -0.263462 -1
-1.812287 1.673161 -1
0.969156 -1.931523 1
-2.221344 0.203244 -1
0.501463 -2.583951 1
-3.150028 1.235862 -1
-4.268858 0.071051 -1
-3.349838 0.678968 -1
-3.126228 -0.393941 -1
-2.573798 0.267638 -1
4.109014 1.710147 1
-2.843759 0.484696 -1
3.707519 -0.370216 1
-4.195957 -0.277812 -1
2.675081 -0.573838 1
-3.125774 0.081851 -1
1.971943 -0.468073 1
3.407029 0.515338 1
-2.104839 2.804795 -1
0.874914 -1.404919 1
3.112299 1.175667 1
-2.829713 0.662682 -1
3.568705 4.168130 1
4.616527 2.518176 1
1.795161 -1.250346 1
4.008731 2.757045 1
-4.508237 -3.536722 -1
-2.456205 1.371719 -1
2.002132 -1.389533 1
2.837388 0.193087 1
3.332083 -1.083519 1
3.116535 -0.303645 1
3.586091 1.202891 1
4.075176 -1.392830 1
-2.686817 -0.295541 -1
-4.347040 -0.238252 -1
-2.216701 0.192294 -1
-3.698974 -1.535749 -1
-2.550443 -1.304260 -1
-3.184541 -0.694387 -1
3.541460 1.293369 1
2.861718 -1.539216 1
-3.297277 0.120904 -1
-2.877627 2.168402 -1
1.971946 -1.934373 1
1.691137 -0.128856 1
-2.894363 -1.081141 -1
3.737381 -0.295484 1
-2.915021 0.450760 -1
3.166039 -0.984355 1
-2.232850 2.234037 -1
-2.339145 -0.623513 -1
-2.333595 0.962038 -1
3.786374 0.586053 1
1.782042 -2.219559 1
3.739798 0.344508 1
2.145958 -1.419122 1
3.664095 -0.196319 1
-3.043546 -0.507600 -1
-0.928765 2.070607 -1
-3.124872 1.695632 -1
-3.020885 0.577177 -1
2.590275 0.779679 1
-2.523241 -0.919172 -1
4.082839 0.662608 1
-4.190252 -3.116115 -1
3.360103 1.046061 1
-2.793587 0.366979 -1
3.400676 1.675726 1
-2.612133 -1.848598 -1
2.564818 -1.149425 1
-4.625269 -1.246603 -1
-2.158414 0.905748 -1
3.190204 1.617466 1
5.670475 2.859713 1
-3.140959 -1.565962 -1
3.275399 -0.385732 1
-2.882785 0.764198 -1
2.444832 -1.744333 1
3.494718 -0.185378 1
2.971542 0.185532 1
3.683797 -0.827936 1
-2.073568 2.713617 -1
5.229803 2.581358 1
-3.097377 1.369309 -1
-3.340725 1.226798 -1
0.804569 -1.763511 1
2.002499 -1.253770 1
-4.441054 -1.504076 -1
4.840372 1.159494 1
-2.074033 1.334349 -1
2.739732 -1.093691 1
1.093710 -1.804169 1
-1.815973 1.270033 -1
-1.535024 1.307626 -1
-2.609744 -1.331401 -1
2.213643 -0.386181 1
-0.193909 -3.182715 1
3.981292 1.726516 1
-2.199386 0.939470 -1
-4.044809 -0.093401 -1
-3.633603 -0.601417 -1
4.289107 -0.685719 1
-3.743011 -2.264532 -1
-4.045259 -0.425302 -1
1.623011 -1.831822 1
3.056557 0.096257 1
1.922710 -1.220852 1
1.809512 -1.326957 1
1.835936 -0.825311 1
-3.798285 -0.592936 -1
-2.425223 1.389336 -1
2.377227 -1.696811 1
1.478822 -2.004391 1
3.126443 0.449490 1
-4.576405 -1.053316 -1
-3.061546 1.008689 -1
-2.861879 0.191511 -1
-2.264559 1.292387 -1
3.804691 -0.408870 1
-5.390695 -4.685284 -1
-4.015686 -1.698655 -1
-1.811922 2.826242 -1
-0.977725 2.446878 -1
-3.722234 -2.148840 -1
-2.336758 -0.426078 -1
2.881292 0.538803 1
-2.603340 1.172457 -1
3.420185 1.261315 1
3.122753 -1.022180 1
-2.160948 -0.760109 -1
3.147356 -0.138635 1
3.321314 0.799222 1
3.358796 1.791473 1
2.645603 0.644191 1
1.140846 -1.296675 1
2.645462 0.289605 1
2.876090 1.010588 1
2.514470 -1.731317 1
2.588991 0.687835 1
-2.404388 0.563167 -1

View File

@@ -0,0 +1,43 @@
'''
Created on 2017-04-07
@author: Peter/ApacheCN-xy
'''
from mrjob.job import MRJob
class MRmean(MRJob):
def __init__(self, *args, **kwargs): # 对数据初始化
super(MRmean, self).__init__(*args, **kwargs)
self.inCount = 0
self.inSum = 0
self.inSqSum = 0
def map(self, key, val): # 需要 2 个参数,求数据的和与平方和
if False: yield
inVal = float(val)
self.inCount += 1
self.inSum += inVal
self.inSqSum += inVal*inVal
def map_final(self): # 计算数据的平均值,平方的均值,并返回
mn = self.inSum/self.inCount
mnSq = self.inSqSum/self.inCount
yield (1, [self.inCount, mn, mnSq])
def reduce(self, key, packedValues): #
cumVal=0.0; cumSumSq=0.0; cumN=0.0
for valArr in packedValues: # 从输入流中获取值
nj = float(valArr[0])
cumN += nj
cumVal += nj*float(valArr[1])
cumSumSq += nj*float(valArr[2])
mean = cumVal/cumN
var = (cumSumSq - 2*mean*cumVal + cumN*mean*mean)/cumN
yield (mean, var) # 发出平均值和方差
def steps(self):
return ([self.mr(mapper=self.map, mapper_final=self.map_final,\
reducer=self.reduce,)])
if __name__ == '__main__':
MRmean.run()

View File

@@ -0,0 +1,78 @@
'''
Created on 2017-04-07
MapReduce version of Pegasos SVM
Using mrjob to automate job flow
@author: Peter/ApacheCN-xy
'''
from mrjob.job import MRJob
import pickle
from numpy import *
class MRsvm(MRJob):
DEFAULT_INPUT_PROTOCOL = 'json_value'
def __init__(self, *args, **kwargs):
super(MRsvm, self).__init__(*args, **kwargs)
self.data = pickle.load(open('C:\Users\Peter\machinelearninginaction\Ch15\svmDat27'))
self.w = 0
self.eta = 0.69
self.dataList = []
self.k = self.options.batchsize
self.numMappers = 1
self.t = 1 #iteration number
def configure_options(self):
super(MRsvm, self).configure_options()
self.add_passthrough_option(
'--iterations', dest='iterations', default=2, type='int',
help='T: number of iterations to run')
self.add_passthrough_option(
'--batchsize', dest='batchsize', default=100, type='int',
help='k: number of data points in a batch')
def map(self, mapperId, inVals): # 需要 2 个参数
#input: nodeId, ('w', w-vector) OR nodeId, ('x', int)
if False: yield
if inVals[0]=='w': # 积累 w向量
self.w = inVals[1]
elif inVals[0]=='x':
self.dataList.append(inVals[1])# 累积数据点计算
elif inVals[0]=='t': self.t = inVals[1]
else: self.eta=inVals # 这用于 debug eta未在map中使用
def map_fin(self):
labels = self.data[:,-1]; X=self.data[:,0:-1]# 将数据重新形成 X 和 Y
if self.w == 0: self.w = [0.001]*shape(X)[1] # 在第一次迭代时,初始化 w
for index in self.dataList:
p = mat(self.w)*X[index,:].T #calc p=w*dataSet[key].T
if labels[index]*p < 1.0:
yield (1, ['u', index])# 确保一切数据包含相同的key
yield (1, ['w', self.w]) # 它们将在同一个 reducer
yield (1, ['t', self.t])
def reduce(self, _, packedVals):
for valArr in packedVals: # 从流输入获取值
if valArr[0]=='u': self.dataList.append(valArr[1])
elif valArr[0]=='w': self.w = valArr[1]
elif valArr[0]=='t': self.t = valArr[1]
labels = self.data[:,-1]; X=self.data[:,0:-1]
wMat = mat(self.w); wDelta = mat(zeros(len(self.w)))
for index in self.dataList:
wDelta += float(labels[index])*X[index,:] #wDelta += label*dataSet
eta = 1.0/(2.0*self.t) #calc new: eta
#calc new: w = (1.0 - 1/t)*w + (eta/k)*wDelta
wMat = (1.0 - 1.0/self.t)*wMat + (eta/self.k)*wDelta
for mapperNum in range(1,self.numMappers+1):
yield (mapperNum, ['w', wMat.tolist()[0] ]) #发出 w
if self.t < self.options.iterations:
yield (mapperNum, ['t', self.t+1])# 增量 T
for j in range(self.k/self.numMappers):#emit random ints for mappers iid
yield (mapperNum, ['x', random.randint(shape(self.data)[0]) ])
def steps(self):
return ([self.mr(mapper=self.map, reducer=self.reduce,
mapper_final=self.map_fin)]*self.options.iterations)
if __name__ == '__main__':
MRsvm.run()

View File

@@ -0,0 +1,13 @@
'''
Created on Feb 27, 2011
@author: Peter
'''
from mrjob.protocol import JSONProtocol
from numpy import *
fw=open('kickStart2.txt', 'w')
for i in [1]:
for j in range(100):
fw.write('["x", %d]\n' % random.randint(200))
fw.close()

View File

@@ -0,0 +1,77 @@
'''
Created on 2017-04-07
Sequential Pegasos
the input T is k*T in Batch Pegasos
@author: Peter/ApacheCN-xy
'''
from numpy import *
def loadDataSet(fileName):
dataMat = []; labelMat = []
fr = open(fileName)
for line in fr.readlines():
lineArr = line.strip().split('\t')
#dataMat.append([float(lineArr[0]), float(lineArr[1]), float(lineArr[2])])
dataMat.append([float(lineArr[0]), float(lineArr[1])])
labelMat.append(float(lineArr[2]))
return dataMat,labelMat
def seqPegasos(dataSet, labels, lam, T):
m,n = shape(dataSet); w = zeros(n)
for t in range(1, T+1):
i = random.randint(m)
eta = 1.0/(lam*t)
p = predict(w, dataSet[i,:])
if labels[i]*p < 1:
w = (1.0 - 1/t)*w + eta*labels[i]*dataSet[i,:]
else:
w = (1.0 - 1/t)*w
print w
return w
def predict(w, x):
return w*x.T
def batchPegasos(dataSet, labels, lam, T, k):
m,n = shape(dataSet); w = zeros(n);
dataIndex = range(m)
for t in range(1, T+1):
wDelta = mat(zeros(n)) # 重置 wDelta
eta = 1.0/(lam*t)
random.shuffle(dataIndex)
for j in range(k):# 全部的训练集
i = dataIndex[j]
p = predict(w, dataSet[i,:]) # mapper 代码
if labels[i]*p < 1: # mapper 代码
wDelta += labels[i]*dataSet[i,:].A # 累积变化
w = (1.0 - 1/t)*w + (eta/k)*wDelta # 在每个 T上应用更改
return w
datArr,labelList = loadDataSet('testSet.txt')
datMat = mat(datArr)
#finalWs = seqPegasos(datMat, labelList, 2, 5000)
finalWs = batchPegasos(datMat, labelList, 2, 50, 100)
print finalWs
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
x1=[]; y1=[]; xm1=[]; ym1=[]
for i in range(len(labelList)):
if labelList[i] == 1.0:
x1.append(datMat[i,0]); y1.append(datMat[i,1])
else:
xm1.append(datMat[i,0]); ym1.append(datMat[i,1])
ax.scatter(x1, y1, marker='s', s=90)
ax.scatter(xm1, ym1, marker='o', s=50, c='red')
x = arange(-6.0, 8.0, 0.1)
y = (-finalWs[0,0]*x - 0)/finalWs[0,1]
#y2 = (0.43799*x)/0.12316
y2 = (0.498442*x)/0.092387 #2 iterations
ax.plot(x,y)
ax.plot(x,y2,'g-.')
ax.axis([-6,8,-4,5])
ax.legend(('50 Iterations', '2 Iterations') )
plt.show()

View File

@@ -0,0 +1,52 @@
'''
Created on Feb 25, 2011
@author: Peter
'''
import numpy
def map(key, value):
# input key= class for one training example, e.g. "-1.0"
classes = [float(item) for item in key.split(",")] # e.g. [-1.0]
D = numpy.diag(classes)
# input value = feature vector for one training example, e.g. "3.0, 7.0, 2.0"
featurematrix = [float(item) for item in value.split(",")]
A = numpy.matrix(featurematrix)
# create matrix E and vector e
e = numpy.matrix(numpy.ones(len(A)).reshape(len(A),1))
E = numpy.matrix(numpy.append(A,-e,axis=1))
# create a tuple with the values to be used by reducer
# and encode it with base64 to avoid potential trouble with '\t' and '\n' used
# as default separators in Hadoop Streaming
producedvalue = base64.b64encode(pickle.dumps( (E.T*E, E.T*D*e) )
# note: a single constant key "producedkey" sends to only one reducer
# somewhat "atypical" due to low degree of parallism on reducer side
print "producedkey\t%s" % (producedvalue)
def reduce(key, values, mu=0.1):
sumETE = None
sumETDe = None
# key isn't used, so ignoring it with _ (underscore).
for _, value in values:
# unpickle values
ETE, ETDe = pickle.loads(base64.b64decode(value))
if sumETE == None:
# create the I/mu with correct dimensions
sumETE = numpy.matrix(numpy.eye(ETE.shape[1])/mu)
sumETE += ETE
if sumETDe == None:
# create sumETDe with correct dimensions
sumETDe = ETDe
else:
sumETDe += ETDe
# note: omega = result[:-1] and gamma = result[-1]
# but printing entire vector as output
result = sumETE.I*sumETDe
print "%s\t%s" % (key, str(result.tolist()))

View File

@@ -0,0 +1,25 @@
'''
Created on Feb 27, 2011
MapReduce version of Pegasos SVM
Using mrjob to automate job flow
@author: Peter
'''
from mrjob.job import MRJob
import pickle
from numpy import *
class MRsvm(MRJob):
def map(self, mapperId, inVals): #needs exactly 2 arguments
if False: yield
yield (1, 22)
def reduce(self, _, packedVals):
yield "fuck ass"
def steps(self):
return ([self.mr(mapper=self.map, reducer=self.reduce)])
if __name__ == '__main__':
MRsvm.run()

View File

@@ -0,0 +1,31 @@
from mrjob.job import MRJob
import json
class MRWordCountUtility(MRJob):
def __init__(self, *args, **kwargs):
super(MRWordCountUtility, self).__init__(*args, **kwargs)
self.chars = 0
self.words = 0
self.lines = 0
def mapper(self, _, line):
if False:
yield # I'm a generator!
self.chars += len(line) + 1 # +1 for newline
self.words += sum(1 for word in line.split() if word.strip())
self.lines += 1
def mapper_final(self):
yield('chars', self.chars)
yield('words', self.words)
yield('lines', self.lines)
def reducer(self, key, values):
yield(key, sum(values))
if __name__ == '__main__':
MRWordCountUtility.run()