-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlots_Mathematica_SVM.nb
6551 lines (6464 loc) · 326 KB
/
Plots_Mathematica_SVM.nb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 10.2' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 158, 7]
NotebookDataLength[ 327242, 6542]
NotebookOptionsPosition[ 324073, 6444]
NotebookOutlinePosition[ 324414, 6459]
CellTagsIndexPosition[ 324371, 6456]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{"points1Seperable", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{"0.6", "*", "i"}], "-", "0.2"}], ",", "0"}], "}"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "5"}], "}"}]}], "]"}]}], ";"}], " ",
RowBox[{"(*",
RowBox[{"belongs", " ", "on", " ", "the", " ", "right", " ", "side"}], " ",
"*)"}]}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"points2Seperable", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"-", "0.6"}], "*", "i"}], "+", "0.2"}], ",", "0"}], "}"}],
",",
RowBox[{"{",
RowBox[{"i", ",", "5"}], "}"}]}], "]"}]}], ";"}], " ",
RowBox[{"(*",
RowBox[{"belongs", " ", "on", " ", "the", " ", "left", " ", "side"}], " ",
"*)"}]}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"points1", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{"0.6", "*", "i"}], "-", "0.7"}], ",", "0"}], "}"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "5"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"points2", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"-", "0.7"}], "*", "i"}], "+", "1.0"}], ",", "0"}], "}"}],
",",
RowBox[{"{",
RowBox[{"i", ",", "5"}], "}"}]}], "]"}]}], ";"}],
" "}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"points1Quad", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"0.2", "*", "i"}], "-", "0.7"}], ")"}], ",",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"0.2", "*", "i"}], "-", "0.7"}], ")"}], "^", "2"}]}], "}"}],
",",
RowBox[{"{",
RowBox[{"i", ",", "5"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"points1NonQuad", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"0.2", "*", "i"}], "-", "0.7"}], ")"}], ",", "0"}], "}"}],
",",
RowBox[{"{",
RowBox[{"i", ",", "5"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"points2Quad", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"-", "1.3"}], "*", "i"}], "+", "4.4"}], ")"}], ",",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"-", "1.3"}], "*", "i"}], "+", "4.4"}], ")"}], "^",
"2"}]}], "}"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "5"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"points2NonQuad", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"-", "1.3"}], "*", "i"}], "+", "4.4"}], ")"}], ",", "0"}],
"}"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "5"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{"ListPlot", "[",
RowBox[{"{",
RowBox[{"points1", ",", " ", "points2"}], "}"}],
"]"}], "\[IndentingNewLine]",
RowBox[{"ListPlot", "[",
RowBox[{
RowBox[{"{",
RowBox[{"points1NonQuad", ",", " ", "points2NonQuad"}], "}"}], ",",
RowBox[{"PlotStyle", "\[Rule]",
RowBox[{"PointSize", "[", "0.02", "]"}]}], ",",
RowBox[{
"PlotLabel", "\[Rule]", "\"\<Example for non separable data\>\""}]}],
"]"}], "\[IndentingNewLine]",
RowBox[{"Show", "[",
RowBox[{
RowBox[{"ListPlot", "[",
RowBox[{
RowBox[{"{",
RowBox[{"points1Quad", ",", " ", "points2Quad"}], "}"}], ",",
RowBox[{"PlotStyle", "\[Rule]",
RowBox[{"PointSize", "[", "0.02", "]"}]}], ",",
RowBox[{
"PlotLabel", "\[Rule]", "\"\<Example for non separable data\>\""}]}],
"]"}], ",",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"-", "0.28"}], "*", "x"}], "+", "0.28"}], ",",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"-", "5"}], ",", "5"}], "}"}]}], "]"}]}], "]"}]}], "Input",
CellChangeTimes->CompressedData["
1:eJwdyDlIQgEAh3GxQyQMKykKIQIxI5BofOKgFAkRoZJEQaBQRJSBHVBUipul
opSL5NGB2bWUiS0ZhJI2FdGBUk0heYRCB0LS+7/h4wdfi2ZaMUqn0WhcMtip
7Sqt6tOS719txRopUzvIgY/i10Y4Eta0QnbVdRtczCmFcLuSJYGFYlk3HBd5
eqB5bLcPLq//URJzb5twqH/BC5t0zfuQJ1IfwUxCKTeTcjO9CqgT/hhgQNBh
ghx3tQXO1rCsUFVeG4B8/wRlKHTxAHOKxBM8zNpTsFTcomTnYp/wPU8vUn8y
bfGQKoZVNhjcCUehVui6hXK7MwkbCgMvUDol43tJ40ZnO3yOaQioZkYoUzT/
KbTqxSHoc9ii1D9h3MGszZWAgRkiCfP1BytSQ1oiY9yYoF9gtcLg/McG5Bm/
3PCME/JBc/zqGBJ74XN4WeeKQMf9Uhb+AwiY8QE=
"]],
Cell[BoxData[
GraphicsBox[{{}, {{},
{RGBColor[0.368417, 0.506779, 0.709798], PointSize[0.012833333333333334`],
AbsoluteThickness[1.6],
PointBox[{{-0.09999999999999998, 0.}, {0.5, 0.}, {1.0999999999999999`,
0.}, {1.7, 0.}, {2.3, 0.}}]},
{RGBColor[0.880722, 0.611041, 0.142051], PointSize[0.012833333333333334`],
AbsoluteThickness[1.6],
PointBox[{{0.30000000000000004`, 0.}, {-0.3999999999999999,
0.}, {-1.0999999999999996`, 0.}, {-1.7999999999999998`, 0.}, {-2.5,
0.}}]}, {}}, {}},
AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
Axes->{True, True},
AxesLabel->{None, None},
AxesOrigin->{0, 0},
DisplayFunction->Identity,
Frame->{{False, False}, {False, False}},
FrameLabel->{{None, None}, {None, None}},
FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
GridLines->{None, None},
GridLinesStyle->Directive[
GrayLevel[0.5, 0.4]],
Method->{},
PlotRange->{{-2.5, 2.3}, {-1., 1.}},
PlotRangeClipping->True,
PlotRangePadding->{{
Scaled[0.02],
Scaled[0.02]}, {
Scaled[0.05],
Scaled[0.05]}},
Ticks->{Automatic, Automatic}]], "Output",
CellChangeTimes->{
3.691124174616165*^9, {3.6911242719809437`*^9, 3.6911243898187475`*^9}, {
3.6911244810232077`*^9, 3.691124508010807*^9}, 3.691124538247376*^9,
3.69112458874116*^9, 3.6911501996323805`*^9, 3.6911780113046966`*^9}],
Cell[BoxData[
GraphicsBox[{{}, {{},
{RGBColor[0.368417, 0.506779, 0.709798], PointSize[0.02],
AbsoluteThickness[1.6],
PointBox[{{-0.49999999999999994`, 0.}, {-0.29999999999999993`,
0.}, {-0.09999999999999987, 0.}, {0.10000000000000009`, 0.}, {
0.30000000000000004`, 0.}}]},
{RGBColor[0.880722, 0.611041, 0.142051], PointSize[0.02],
AbsoluteThickness[1.6],
PointBox[{{3.1000000000000005`, 0.}, {1.8000000000000003`, 0.}, {0.5,
0.}, {-0.7999999999999998, 0.}, {-2.0999999999999996`, 0.}}]}, {}}, {}},
AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
Axes->{True, True},
AxesLabel->{None, None},
AxesOrigin->{0, 0},
DisplayFunction->Identity,
Frame->{{False, False}, {False, False}},
FrameLabel->{{None, None}, {None, None}},
FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
GridLines->{None, None},
GridLinesStyle->Directive[
GrayLevel[0.5, 0.4]],
Method->{},
PlotLabel->FormBox["\"Example for non separable data\"", TraditionalForm],
PlotRange->{{-2.0999999999999996`, 3.1000000000000005`}, {-1., 1.}},
PlotRangeClipping->True,
PlotRangePadding->{{
Scaled[0.02],
Scaled[0.02]}, {
Scaled[0.05],
Scaled[0.05]}},
Ticks->{Automatic, Automatic}]], "Output",
CellChangeTimes->{
3.691124174616165*^9, {3.6911242719809437`*^9, 3.6911243898187475`*^9}, {
3.6911244810232077`*^9, 3.691124508010807*^9}, 3.691124538247376*^9,
3.69112458874116*^9, 3.6911501996323805`*^9, 3.6911780113697214`*^9}],
Cell[BoxData[
GraphicsBox[{{{}, {{},
{RGBColor[0.368417, 0.506779, 0.709798], PointSize[0.02],
AbsoluteThickness[1.6],
PointBox[{{-0.49999999999999994`,
0.24999999999999994`}, {-0.29999999999999993`,
0.08999999999999996}, {-0.09999999999999987, 0.009999999999999974}, {
0.10000000000000009`, 0.010000000000000018`}, {0.30000000000000004`,
0.09000000000000002}}]},
{RGBColor[0.880722, 0.611041, 0.142051], PointSize[0.02],
AbsoluteThickness[1.6],
PointBox[{{3.1000000000000005`, 9.610000000000003}, {
1.8000000000000003`, 3.240000000000001}, {0.5,
0.25}, {-0.7999999999999998,
0.6399999999999997}, {-2.0999999999999996`,
4.409999999999998}}]}, {}}, {}}, {{}, {},
{RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], Opacity[
1.], LineBox[CompressedData["
1:eJwB4QQe+yFib1JlAgAAAE0AAAACAAAAfedN8v//E8Acp72eR+H6P3SiGPXb
/BPA6d78JsPd+j9sXeP3t/kTwLcWPK8+2vo/XNN4/W/zE8BThrq/NdP6Pzy/
owjg5hPAjGW34CPF+j/6lvkewM0TwPojsSIAqfo/eEalS4CbE8DZoKSmuHD6
P3Sl/KQANxPAl5qLrikA+j9vQGYzGV0SwO49kTkcDPk/sQdwbqKREcBr1QwL
Oyj4P3mLzWUpyhDAS0qUNNJI9z+K2MtxkOMPwAZvU9l5VvY/sPI8ca9PDsDo
h4jETXT1P97GIyj+mQzAplD1KjJ/9D8ZFLJXSOwKwMf2bemOjvM/4rmA4HNb
CcAOkVzuF67yP7MZxSDPqAfAMtuCbrG68T8S0km6CxMGwHsZHzV31/A/fQN2
zEOFBMBPao6navHvP/DuF5ar1QLAYAFO2wcO7j/xMvq49EIBwL2A+Zv9Suw/
9WGkJtsc/7/SXxRTFGLqPyBQo8zDw/u/rPlGuhuC6D9n7yIlb6T4v9R7Za57
wuY/vgKO7HlB9b+yXfOY/NzkPzLHeWZHGPK/3ydtENYX4z9r/6Ge6Fbtv8JR
Vn7QLOE/olTuUjCd5r/WbK44d5XePxIMPGz9VuC/wwaIjv4R2z9DV8HGEhPT
vx5gQNHHQtc/TGs1/NV8ub8TitAtQrTTP/Fkqw0wU7g/kymQ6p030D8MPTXK
T5fTPwQRXSh33sg/NW5+Y2QZ4D8XcEmvFM/BP8RVCwRi7uY/DJzmH2xQtD8j
WfrBcaPtP2C44IfRKJU/Jf1zDX7y8T/o+i3pfXKhv6hZ/8rjVvU/RCurl6rr
t78PBQrWhoH4P1YLsOmoDcO/Xr7F7zKc+z/ylSvHuQHKv50Dlpp/+v4/2tB0
ZaPG0L/gy3LJhA8BQCAGfM24S9S/6tskDprDAkD4e6RIjBzYv2aTlvnNWgRA
OCH1qa6s27/W0WBsBuoFQOpQFqvvKt+/Pla1Jw+bB0CYYKxfd3rhvxeCyYk2
LwlAbLDhXB4/47/p82c0LuUKQIugp2OkKeW/ruxeZiqTDEDi1VW6OQvnv+WM
FT9FJA5A7CIYhHbM6L8Uc1ZgMNcPQEAQa1eSs+q/W4ArFJ22EEBIFdKdVXrs
v6YK2DukfRFAil8hNCg47r/tt8mHk1USQAqlAOrsDfC/7DgbJxIfE0Anpnpz
me/wv6YDSN6VIhNAh0HqIYnz8L9gznSVGSYTQOfcWdB49/C/1WPOAyEtE0Cn
EzktWP/wv76OgeAvOxNAJ4H35hYP8b+Q5OeZTVcTQCdcdFqULvG/NJC0DImP
E0AmEm5Bj23xv+5a4cMMkxNAhq3d735x8b+oJQ57kJYTQOZITZ5udfG/Hbtn
6ZedE0Cmfyz7TX3xvwbmGsamqxNAJu3qtAyN8b/YO4F/xMcTQCbIZyiKrPG/
kgauNkjLE0CFY9fWebDxv0zR2u3LzhNA5f5GhWm08b/BZjRc09UTQKU1JuJI
vPG/qpHnOOLjE0Alo+SbB8zxv2RcFPBl5xNAhT5USvfP8b8fJ0Gn6eoTQObZ
w/jm0/G/lLyaFfHxE0CmEKNVxtvxv06Hx8x09RNABqwSBLbf8b8IUvSD+PgT
QGZHgrKl4/G/whwhO3z8E0DF4vFglefxv33nTfL//xNAJn5hD4Xr8b9Y+IBi
"]]}}},
AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
Axes->{True, True},
AxesLabel->{None, None},
AxesOrigin->{0, 0},
DisplayFunction->Identity,
Frame->{{False, False}, {False, False}},
FrameLabel->{{None, None}, {None, None}},
FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
GridLines->{None, None},
GridLinesStyle->Directive[
GrayLevel[0.5, 0.4]],
Method->{},
PlotLabel->FormBox["\"Example for non separable data\"", TraditionalForm],
PlotRange->{{-2.0999999999999996`, 3.1000000000000005`}, {
0, 9.610000000000003}},
PlotRangeClipping->True,
PlotRangePadding->{{
Scaled[0.02],
Scaled[0.02]}, {
Scaled[0.02],
Scaled[0.05]}},
Ticks->{Automatic, Automatic}]], "Output",
CellChangeTimes->{
3.691124174616165*^9, {3.6911242719809437`*^9, 3.6911243898187475`*^9}, {
3.6911244810232077`*^9, 3.691124508010807*^9}, 3.691124538247376*^9,
3.69112458874116*^9, 3.6911501996323805`*^9, 3.691178011440737*^9}]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{"lossName", "=", "\"\<Binary Loss\>\""}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"binLoss", "[",
RowBox[{"x_", ",", "p_", ",", "class_"}], "]"}], ":=",
RowBox[{"If", "[",
RowBox[{
RowBox[{"class", "\[Equal]", "1"}], ",",
RowBox[{"If", "[",
RowBox[{
RowBox[{"p", ">", "x"}], ",", "0", ",", "1"}], "]"}], ",",
RowBox[{"If", "[",
RowBox[{
RowBox[{"p", "<", "x"}], ",", "0", ",", "1"}], "]"}]}], "]"}]}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"applyLossForPlt", "[",
RowBox[{"x_", ",", "points_", ",", "class_", ",", "lossFKT_"}], "]"}], ":=",
RowBox[{"Total", "[",
RowBox[{"Map", "[",
RowBox[{
RowBox[{"Function", "[",
RowBox[{"p", ",",
RowBox[{"lossFKT", "[",
RowBox[{"x", ",",
RowBox[{"p", "[",
RowBox[{"[", "1", "]"}], "]"}], ",", "class"}], "]"}]}], "]"}],
",", "points"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{"Show", "[",
RowBox[{
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{"applyLossForPlt", "[",
RowBox[{"x", ",", "points1", ",", "1", ",", "binLoss"}], "]"}], "+",
RowBox[{"applyLossForPlt", "[",
RowBox[{"x", ",", "points2", ",", "2", ",", "binLoss"}], "]"}]}],
",", "0"}], "}"}], ",",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"-", "3"}], ",", "3"}], "}"}], ",",
RowBox[{"PlotStyle", "\[Rule]",
RowBox[{"{",
RowBox[{"Blue", ",", "White"}], "}"}]}], ",", " ",
RowBox[{"Exclusions", "\[Rule]", "None"}], ",", " ",
RowBox[{"PlotLabel", "\[Rule]",
RowBox[{"lossName", "<>", "\"\< example\>\""}]}], ",",
RowBox[{"AxesLabel", "\[Rule]",
RowBox[{"{",
RowBox[{"x", ",", "Loss"}], "}"}]}]}], "]"}], ",",
RowBox[{"ListPlot", "[",
RowBox[{"{",
RowBox[{"points1", ",", " ", "points2"}], "}"}], "]"}]}],
"]"}], "\[IndentingNewLine]",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"binLoss", "[",
RowBox[{"x", ",", "0", ",", "1"}], "]"}], ",",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"-", "2"}], ",", "2"}], "}"}], ",",
RowBox[{"PlotLabel", "\[Rule]", "lossName"}], ",",
RowBox[{"AxesLabel", "\[Rule]",
RowBox[{"{",
RowBox[{"\"\<Distance to Point\>\"", ",", "Loss"}], "}"}]}]}],
"]"}]}], "Input",
CellChangeTimes->{{3.6907489307606096`*^9, 3.6907489944266195`*^9}, {
3.690749045754924*^9, 3.6907490484249945`*^9}, {3.6907493341199703`*^9,
3.690749366942527*^9}, {3.690749480372759*^9, 3.69074949968463*^9}, {
3.6907495357964363`*^9, 3.6907495705174*^9}, {3.690749641213644*^9,
3.6907496709347196`*^9}, {3.6907499027385945`*^9, 3.690749934699002*^9}, {
3.690749990558827*^9, 3.690750021295371*^9}, {3.6907500603568745`*^9,
3.690750066274431*^9}, {3.6907501184542313`*^9, 3.690750149582407*^9}, {
3.6907503566829057`*^9, 3.690750396731433*^9}, {3.690750451831112*^9,
3.6907504554486265`*^9}, {3.6907504928224363`*^9, 3.690750558754436*^9},
3.6907518592373323`*^9, {3.6907519614829416`*^9, 3.690751963231429*^9}, {
3.690790033175798*^9, 3.6907900636758904`*^9}, {3.6907901536131506`*^9,
3.6907902279128113`*^9}, {3.6907902625362697`*^9, 3.690790282745385*^9}, {
3.6907903507278233`*^9, 3.690790397455453*^9}, {3.690790549493122*^9,
3.6907905511244946`*^9}, {3.6907918734701023`*^9, 3.690791907471366*^9}, {
3.6907919391912503`*^9, 3.69079194243943*^9}, {3.690791978066392*^9,
3.6907920441180115`*^9}, 3.6907920967171307`*^9, {3.690792714254243*^9,
3.690792751662723*^9}, {3.690792783037078*^9, 3.690792801350355*^9}, {
3.6907928865106077`*^9, 3.6907928977962823`*^9}, {3.6907929610555344`*^9,
3.69079299641113*^9}, {3.6907930546081085`*^9, 3.6907930623737373`*^9}}],
Cell[BoxData[
GraphicsBox[{{{}, {},
{RGBColor[0, 0, 1], AbsoluteThickness[1.6], Opacity[1.],
LineBox[CompressedData["
1:eJxF1ns0FHgUB/DxjG3ziJFV5BmGVq/d0KyZqLxFNg7FKBISI1pJbB6ZTU4x
1JbxjNZrk93kHZPXcpBE8swrImQ8Eo3Htnuae+85v/M7n3N+f3x/9497rtJp
32Nn+AkEQuGX89/t+ih2Zn19A5vwf0lTl8q0n7kz0DH1DcwWMbSi3BDdRlQY
TCfb2mgShcDjs6oWl5MFwS5Zi0ea1NCdQ2uNsUS0xbYNlnZC6PekxofGfGiG
3g0xvVWBr5agqppY+pKW0dV24i+2fkSv+MfHrU2h98dtsR16i1YW1nDwrkWL
BevSPmWgR90czm1yRVdYXQ5UUUY3iE7ELmfzg9tr7XNbddDHA4myezT5wJcu
CLKc1Qng1nyb8p+c16t4zr+USK08vwZu5+anOUyugpdCawgfPdDR7JaCanW0
PH+XS+zYCtjarFvG6w06nNnTbNSJLuzpDZd/jh5T7tf9VMezCNX88UBm7hN0
gdGwhPMDdJDbu/HaSLThtSm2lhvaxNE3oojOBVvpzB0+GPIZzPJy/Pg+dQlc
pRAhx5e4CHak0w5VFS2Ama92JnQUzIOb9FdGJn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fUyRgUfdK/S0IzIdWcY9xPMyM5pSu/KTWSb3JJv
IjuB5zh5+3UeyB1FcUmi08hRcy7f9hYj91JlFexS5OAgTpBAiEwXPCnTVyNT
PQ1+Ggnyl0ufsysVyHEF+a4fVMjD9dR+k/q/PeK8c9YEsqSkR86eRfZovcIT
zCPXapZsr38gl9H8EuiryJZIxUbyOjKekdwksiAvPzNd1NiQd/4X+A/w8ilf
"]]}}, {{}, {{},
{RGBColor[0.368417, 0.506779, 0.709798], PointSize[
0.012833333333333334`], AbsoluteThickness[1.6],
PointBox[{{-0.09999999999999998, 0.}, {0.5, 0.}, {1.0999999999999999`,
0.}, {1.7, 0.}, {2.3, 0.}}]},
{RGBColor[0.880722, 0.611041, 0.142051], PointSize[
0.012833333333333334`], AbsoluteThickness[1.6],
PointBox[{{0.30000000000000004`, 0.}, {-0.3999999999999999,
0.}, {-1.0999999999999996`, 0.}, {-1.7999999999999998`, 0.}, {-2.5,
0.}}]}, {}}, {}}},
AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
Axes->{True, True},
AxesLabel->{
FormBox["x", TraditionalForm],
FormBox["Loss", TraditionalForm]},
AxesOrigin->{0, 0},
DisplayFunction->Identity,
Frame->{{False, False}, {False, False}},
FrameLabel->{{None, None}, {None, None}},
FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
GridLines->{None, None},
GridLinesStyle->Directive[
GrayLevel[0.5, 0.4]],
Method->{
"DefaultBoundaryStyle" -> Automatic, "DefaultMeshStyle" ->
AbsolutePointSize[6], "ScalingFunctions" -> None},
PlotLabel->FormBox["\"Binary Loss example\"", TraditionalForm],
PlotRange->{{-3, 3}, {0., 5.}},
PlotRangeClipping->True,
PlotRangePadding->{{
Scaled[0.02],
Scaled[0.02]}, {
Scaled[0.05],
Scaled[0.05]}},
Ticks->{Automatic, Automatic}]], "Output",
CellChangeTimes->{{3.6907495547946815`*^9, 3.6907495712179027`*^9},
3.6907499043124475`*^9, 3.690750022264778*^9, 3.6907500671058598`*^9,
3.6907501561040044`*^9, 3.6907503617642083`*^9, 3.690750398116852*^9,
3.6907504571655645`*^9, {3.690750510180978*^9, 3.690750527244833*^9},
3.6907505594926987`*^9, 3.690750614428006*^9, {3.6907509936687903`*^9,
3.690751003674634*^9}, 3.690751091031486*^9, {3.6907518318524265`*^9,
3.6907519648551493`*^9}, 3.6907528920602875`*^9, {3.6907900056212883`*^9,
3.690790063992404*^9}, {3.690790212235051*^9, 3.6907902286283207`*^9}, {
3.690790263536805*^9, 3.6907902838839636`*^9}, {3.6907903771601253`*^9,
3.690790398440643*^9}, 3.6907904573742123`*^9, {3.6907905440261455`*^9,
3.6907905518398952`*^9}, {3.690790636282919*^9, 3.6907906468191357`*^9}, {
3.690791223996689*^9, 3.690791263530269*^9}, 3.690791384606457*^9,
3.690791908002761*^9, {3.690791943039793*^9, 3.6907919497610493`*^9}, {
3.690791991457588*^9, 3.690792002917714*^9}, 3.6907920470883093`*^9,
3.6907920992030487`*^9, 3.690792355284444*^9, 3.690792646029167*^9,
3.6907926771291637`*^9, 3.6907927520629625`*^9, {3.690792796363101*^9,
3.6907928069396515`*^9}, {3.6907928920291204`*^9, 3.69079289887471*^9}, {
3.690792963919326*^9, 3.690792997411786*^9}, 3.690793064576003*^9,
3.691079640306384*^9, 3.691150205996889*^9, 3.691178014130017*^9}],
Cell[BoxData[
GraphicsBox[{{}, {},
{RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], Opacity[
1.], LineBox[CompressedData["
1:eJxF1H0s1AEYB/AT0pv0elTkXaKspYnSbqvLXISFdlwqZykk11VTt8oVWS/s
FrHDYdwp72qpRPp5qbylF+JUyMsSfkuHO+WKq1b7/p7t2bPPf99nz/aYc6P2
HZlDo9EO/um/04FBH9VoNATtf/mFr7s6raYsSHG2mVRRbiADuUMk5cPi7A8v
5ZRvjtu2pJVRVkq3Fzseolw5L/jE0aezcExrJ1kbPAOP5K0y3Gr8C7b75D7f
oEcNy5ZLle8vT8P1nOZEgvEDNs42NhP3T8Eeuzjn2q+pYNOfocL1LCW8sTRT
yP86AfedznHozB+HwyQ3pZJwBcy+GGBZbDEG25LrOX5ZJBzh5XNlYHAYDjzl
vcPJaQhOJoZ9iIeDMGNO134HrX44vKuOlzfZDbumXTKqPCuHj/WMfwwwbIO9
+zaUNFo1w05Ehnw07im8epHOSJYj5Rn2cfW+gWr42YSrSRWDsq9NL/eGugrm
JZqN2fMewwWcPJ1ITjmckK9PN19Amac6s66j4j7sLHLbs4NO+UXdF5H+23uU
ff2cDiSWwi6KoJDeEBl8vFI2Ev1MCmfFkVFLrSlrrzp3njmUA6fF2tr7v82C
a2xSRF8/3IKtqywkZpJk+Lr33XzfoCT4jiI19hQhgl8law8vbLoCi5+s1eJ7
xMLczy6ru1qF8Ghkn9g9Lxq+SNBbVhTyYQuLdHVtUATMej73UODRYCpvTqt+
S/1e2F2qqbltv4XxTwpGXG7ol4rvbHhNqZsBkx8KC3QjO/y38GBfLu1ktZ0A
Tv3Eik9achmOcu0xV89NgGWeFb13Z5PgCwUeAiOVBLaP/bag5owUzmXel5dd
K4fLGsYKYtgEXM1qdt5W1wSThblhXuw2OLPEIUP5QA4/CY5fuelRN7XPirQO
72X98Ms375ht6YPwyZatNiL6EJX/NXNlaOMwnFD8KF/Pk4S1kt+x6nXHYMOC
ogaZuwLuvCO01L06DnOK7OL5AxOwa4be9ufWSnhQ9HjKKk4Fl1vGkObdU3Cf
NHqzjskPuM12t3Dy7DRsmr7brLFaTd2nMGDa5ddPuJ3Y+b7CfwaOqD240EQ8
C3sKKwWLPTXw/38O/wY7ysYX
"]]}},
AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
Axes->{True, True},
AxesLabel->{
FormBox["\"Distance to Point\"", TraditionalForm],
FormBox["Loss", TraditionalForm]},
AxesOrigin->{0, 0},
DisplayFunction->Identity,
Frame->{{False, False}, {False, False}},
FrameLabel->{{None, None}, {None, None}},
FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
GridLines->{None, None},
GridLinesStyle->Directive[
GrayLevel[0.5, 0.4]],
Method->{
"DefaultBoundaryStyle" -> Automatic, "DefaultMeshStyle" ->
AbsolutePointSize[6], "ScalingFunctions" -> None},
PlotLabel->FormBox["\"Binary Loss\"", TraditionalForm],
PlotRange->{{-2, 2}, {0., 1.}},
PlotRangeClipping->True,
PlotRangePadding->{{
Scaled[0.02],
Scaled[0.02]}, {
Scaled[0.05],
Scaled[0.05]}},
Ticks->{Automatic, Automatic}]], "Output",
CellChangeTimes->{{3.6907495547946815`*^9, 3.6907495712179027`*^9},
3.6907499043124475`*^9, 3.690750022264778*^9, 3.6907500671058598`*^9,
3.6907501561040044`*^9, 3.6907503617642083`*^9, 3.690750398116852*^9,
3.6907504571655645`*^9, {3.690750510180978*^9, 3.690750527244833*^9},
3.6907505594926987`*^9, 3.690750614428006*^9, {3.6907509936687903`*^9,
3.690751003674634*^9}, 3.690751091031486*^9, {3.6907518318524265`*^9,
3.6907519648551493`*^9}, 3.6907528920602875`*^9, {3.6907900056212883`*^9,
3.690790063992404*^9}, {3.690790212235051*^9, 3.6907902286283207`*^9}, {
3.690790263536805*^9, 3.6907902838839636`*^9}, {3.6907903771601253`*^9,
3.690790398440643*^9}, 3.6907904573742123`*^9, {3.6907905440261455`*^9,
3.6907905518398952`*^9}, {3.690790636282919*^9, 3.6907906468191357`*^9}, {
3.690791223996689*^9, 3.690791263530269*^9}, 3.690791384606457*^9,
3.690791908002761*^9, {3.690791943039793*^9, 3.6907919497610493`*^9}, {
3.690791991457588*^9, 3.690792002917714*^9}, 3.6907920470883093`*^9,
3.6907920992030487`*^9, 3.690792355284444*^9, 3.690792646029167*^9,
3.6907926771291637`*^9, 3.6907927520629625`*^9, {3.690792796363101*^9,
3.6907928069396515`*^9}, {3.6907928920291204`*^9, 3.69079289887471*^9}, {
3.690792963919326*^9, 3.690792997411786*^9}, 3.690793064576003*^9,
3.691079640306384*^9, 3.691150205996889*^9, 3.691178014177944*^9}]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{"hingeLoss", "[",
RowBox[{"x_", ",", "p_", ",", "class_"}], "]"}], ":=",
RowBox[{"If", "[",
RowBox[{
RowBox[{"class", "\[Equal]", "1"}], ",",
RowBox[{"Max", "[",
RowBox[{"0", ",",
RowBox[{"x", "-", "p"}]}], "]"}], ",",
RowBox[{"Max", "[",
RowBox[{"0", ",",
RowBox[{"p", "-", "x"}]}], "]"}]}], "]"}]}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"lossName", "=", "\"\<Hinge Loss\>\""}],
";"}], "\[IndentingNewLine]",
RowBox[{"Show", "[",
RowBox[{
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{"applyLossForPlt", "[",
RowBox[{"x", ",", "points1", ",", "1", ",", "hingeLoss"}], "]"}],
"+",
RowBox[{"applyLossForPlt", "[",
RowBox[{"x", ",", "points2", ",", "2", ",", "hingeLoss"}], "]"}]}],
",", "0"}], "}"}], ",",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"-", "3"}], ",", "3"}], "}"}], ",",
RowBox[{"PlotStyle", "\[Rule]",
RowBox[{"{",
RowBox[{"Blue", ",", "White"}], "}"}]}], ",", " ",
RowBox[{"Exclusions", "\[Rule]", "None"}], ",", " ",
RowBox[{"PlotLabel", "\[Rule]",
RowBox[{"lossName", "<>", "\"\< example\>\""}]}], ",",
RowBox[{"AxesLabel", "\[Rule]",
RowBox[{"{",
RowBox[{"x", ",", "Loss"}], "}"}]}]}], "]"}], ",",
RowBox[{"ListPlot", "[",
RowBox[{"{",
RowBox[{"points1", ",", " ", "points2"}], "}"}], "]"}]}],
"]"}], "\[IndentingNewLine]",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"hingeLoss", "[",
RowBox[{"x", ",", "0", ",", "1"}], "]"}], ",",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"-", "2"}], ",", "2"}], "}"}], ",",
RowBox[{"PlotLabel", "\[Rule]", "lossName"}], ",",
RowBox[{"AxesLabel", "\[Rule]",
RowBox[{"{",
RowBox[{"\"\<Distance to Point\>\"", ",", "Loss"}], "}"}]}]}],
"]"}]}], "Input",
CellChangeTimes->{{3.6907506203929105`*^9, 3.690750624115899*^9}, {
3.6907508706211247`*^9, 3.6907509553422623`*^9}, 3.6907511202654576`*^9, {
3.6907511697877855`*^9, 3.690751197002852*^9}, {3.6907513126483808`*^9,
3.6907513234071407`*^9}, {3.6907515344767947`*^9,
3.6907515848767633`*^9}, {3.6907516337000103`*^9,
3.6907516350004854`*^9}, {3.6907517166581097`*^9, 3.690751721876223*^9}, {
3.690751780769692*^9, 3.6907517812703457`*^9}, {3.6907519698618145`*^9,
3.690751971859923*^9}, {3.6907521961570187`*^9, 3.6907522478760986`*^9}, {
3.6907522982508855`*^9, 3.6907523925218244`*^9}, {3.69075247761784*^9,
3.690752478170944*^9}, {3.6907904131997814`*^9, 3.6907904188647995`*^9}, {
3.6907905078320503`*^9, 3.6907905084166417`*^9}, {3.690790555595781*^9,
3.6907905567589197`*^9}, {3.690792217307109*^9, 3.690792242106127*^9}, {
3.6907930318132515`*^9, 3.6907930371132708`*^9}, 3.690793073547558*^9}],
Cell[BoxData[
GraphicsBox[{{{}, {},
{RGBColor[0, 0, 1], AbsoluteThickness[1.6], Opacity[1.],
LineBox[CompressedData["
1:eJxFmHk0FNz/xwfDkHWEZItRFO1aiHxutNjqkUop4WmRPCUiu0KopJI2a5Il
S2mxJtxJiCfJkmXsM8PYkhnZYpifb/2+fe8/r/M673vO/Zx7zj333o/aiQtW
p/kJBII+H4HwH558GTnK45GoBu0ewzweBVHvKGvoc0nUVz9SRk1nKUjJNdPW
c5pEXS7W9OPeJAU1ry+v/sYmUcW2b+ZqjlCQyZupZBqdRG17PCFm2UZBa/Ps
juR8IFF9T3iufZJLQdNFq987XiNR8we93NBZCoqorIr6LEGirp/2nQpsUEOq
CnTX/SJC1HSHpZ9Tb6oiV4MD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G7iySswbtbyl2z
K1dUzCw7ODHEGHOhdBMszU/ZWG62gpW+T31IEjM4BU/nKPtM4LFz9gW93Agu
a7R1yWRrYO7Rm798xQYwj8Ip/yjUgzn+Yk9F3yKYCLstrpEQYMr4spbKmAEz
ZISwUaoDR0y+o79aGAXXL+1rmGjoBpfH5Lq1hHZF79pEe6hML/8Ezul/Lu/k
6sDFWGHTo4oZMJucWcjXEOAb2mNuWdWLYHVTtoov1YNZZ6NzI/MM4BdTHak/
RWvgYel6XXyjEYwPVQ86FpvAsQXp/KQKM7ijVMi03LGCNTZWr1P8JtidxNJ2
8uzg+byaqfaILfAq0+X9IQbG2vV4SjPuHUACGwamA0ZoZHDbbHhLnw8F/DL8
lNc1VwewOZpSwvyN/P2AsfUyRgUfdK/S0IzIdWcY9xPMyM5pSu/KTWSb3JJv
IjuB5zh5+3UeyB1FcUmi08hRcy7f9hYj91JlFexS5OAgTpBAiEwXPCnTVyNT
PQ1+Ggnyl0ufsysVyHEF+a4fVMjD9dR+k/q/PeK8c9YEsqSkR86eRfZovcIT
zCPXapZsr38gl9H8EuiryJZIxUbyOjKekdwksiAvPzNd1NiQd/4X+A/w8ilf
"]]}}, {{}, {{},
{RGBColor[0.368417, 0.506779, 0.709798], PointSize[
0.012833333333333334`], AbsoluteThickness[1.6],
PointBox[{{-0.09999999999999998, 0.}, {0.5, 0.}, {1.0999999999999999`,
0.}, {1.7, 0.}, {2.3, 0.}}]},
{RGBColor[0.880722, 0.611041, 0.142051], PointSize[
0.012833333333333334`], AbsoluteThickness[1.6],
PointBox[{{0.30000000000000004`, 0.}, {-0.3999999999999999,
0.}, {-1.0999999999999996`, 0.}, {-1.7999999999999998`, 0.}, {-2.5,
0.}}]}, {}}, {}}},
AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
Axes->{True, True},
AxesLabel->{
FormBox["x", TraditionalForm],
FormBox["Loss", TraditionalForm]},
AxesOrigin->{0, 0},
DisplayFunction->Identity,
Frame->{{False, False}, {False, False}},
FrameLabel->{{None, None}, {None, None}},
FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
GridLines->{None, None},
GridLinesStyle->Directive[
GrayLevel[0.5, 0.4]],
Method->{
"DefaultBoundaryStyle" -> Automatic, "DefaultMeshStyle" ->
AbsolutePointSize[6], "ScalingFunctions" -> None},
PlotLabel->FormBox["\"Hinge Loss example\"", TraditionalForm],
PlotRange->{{-3, 3}, {0., 9.499999387755103}},
PlotRangeClipping->True,
PlotRangePadding->{{
Scaled[0.02],
Scaled[0.02]}, {
Scaled[0.05],
Scaled[0.05]}},
Ticks->{Automatic, Automatic}]], "Output",
CellChangeTimes->{
3.6907515418301935`*^9, 3.690751585724371*^9, {3.690751635663901*^9,
3.690751689470607*^9}, 3.690751722508381*^9, 3.6907517826713133`*^9,
3.69075197239196*^9, 3.690752393869375*^9, 3.69075272010596*^9,
3.6907528946732664`*^9, {3.6907904106779947`*^9, 3.6907904201808643`*^9},
3.6907904985807133`*^9, 3.690790557281128*^9, 3.6907906516436677`*^9,
3.6907912799422746`*^9, 3.690791386456688*^9, {3.6907922152596855`*^9,
3.6907922432758446`*^9}, 3.6907924034496574`*^9, 3.6907926864353437`*^9, {
3.6907930296264763`*^9, 3.6907930380823455`*^9}, 3.690793077434612*^9,
3.6910796427546167`*^9, 3.691150208266796*^9, 3.6911780179016685`*^9}],
Cell[BoxData[
GraphicsBox[{{{}, {},
{RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6], Opacity[
1.], LineBox[CompressedData["
1:eJxTTMoPSmViYGBQA2IQrWcv9ur////7GaAgJEu94+cvBL9qqoXa568I/vHX
UUnPXiP4CTPm3zpzHcGf+FHj9Mz1CP6XxdZrjOMR/F0ciXnp+/7B+fVnr70+
mPgXzn+5VFLcXOYPnK9134OT/+4vOH+J8OIvN5t+wvmHo0/17rf/AefLzJdR
mPHwG5zv7RxdebnzK5wv/zutQdPzC5yvu25uQ9HbT3D+g5KFetdWfITzM+dM
XDwn6wOcH1EXqbxG6R2cr/FaMzpk3ms4P9svoPXR4xdwflSxv62Z2TM4f/L+
FwH7tz2G8+2ZboTpMT6E87NuHCpY+vkOnG8zs1FiV8V1OD/j7sfbkeKX4Hz/
BzprT6icgvPN9s++/qplH5xv+SE2+V7yEjg/Z9eSl+VHFsP581pe5wuqIvjM
kpU1Ls8WwvkzmzW0Qy/Og/MPqE3tf3trCoK/8Czv6cO+OPkACje2Sg==
"]], LineBox[CompressedData["
1:eJxFxVtIUwEYAOBVzoV2o5ohIjm1skkW0tQ5Y2FH88RU0qRVsnTVKkJSwy6D
cqWNhNHQYNSGFDvbmk6n5sIlO2iJzC5gbOoSpl0GdhnM0mVq5aqH/v/h4+NI
zxedWs5gMAR//bteL/to/yEW/j/GmruWqJbBcmbFaMnuSniqO41q2FkDF0sZ
VTRXDmveksqmdTdgg8g+2bnUBCfXTUf011BwqWDDyvZ4A6yaTWNqh/HAiWuh
C9tN8CNidXDbhBnOCE+eUBNWWE90ezoabHCHM9BSK+6DafJFRuaz57C/VX+2
QOyCm9tTdMHHHthRrmTv6vHC8o33RgvXv4dfvR4hXFofXPUyfas6ago2DBNs
2dAnWNXWY2aJ/PCyOyPkADMAb2qxOA15X+Gxh4oE5q1v8DELV1n9YQbO0rEE
g1uCsE/9ZC6x/jtsS6j1c7xz8DvqUmpY7DzsSspRzF5egDdrc+KG6EVY03pk
gf/rJ+zuyx63l/yGzz2VRMbeXYKl98c1jmb86NVD8aUUnsc/wNdZ8cQu3uno
Qdz7YNUAewYXKXrla0QheJ+EF249iGdmdTbmH8aT5o1mlRQPq2wci7iC08fP
pLJMuG2PjzZZ8LYYCZnbhWs9xWU3HfjFQuHtFW68YkdvNPUGPxnJM2ZP4kVO
ruP6Z5w0GvdzpvG9dXHu/iCeXq6TlC3iKcKoL6EQ/gdyrtwA
"]]}, {}}, {{}, {}, {}}},
AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
Axes->{True, True},
AxesLabel->{
FormBox["\"Distance to Point\"", TraditionalForm],
FormBox["Loss", TraditionalForm]},
AxesOrigin->{0, 0},
DisplayFunction->Identity,
Frame->{{False, False}, {False, False}},
FrameLabel->{{None, None}, {None, None}},
FrameTicks->{{Automatic, Automatic}, {Automatic, Automatic}},
GridLines->{None, None},
GridLinesStyle->Directive[
GrayLevel[0.5, 0.4]],
Method->{
"DefaultBoundaryStyle" -> Automatic, "DefaultMeshStyle" ->
AbsolutePointSize[6], "ScalingFunctions" -> None},
PlotLabel->FormBox["\"Hinge Loss\"", TraditionalForm],
PlotRange->{{-2, 2}, {0., 1.999999918367347}},
PlotRangeClipping->True,
PlotRangePadding->{{
Scaled[0.02],
Scaled[0.02]}, {
Scaled[0.05],
Scaled[0.05]}},
Ticks->{Automatic, Automatic}]], "Output",
CellChangeTimes->{
3.6907515418301935`*^9, 3.690751585724371*^9, {3.690751635663901*^9,
3.690751689470607*^9}, 3.690751722508381*^9, 3.6907517826713133`*^9,
3.69075197239196*^9, 3.690752393869375*^9, 3.69075272010596*^9,
3.6907528946732664`*^9, {3.6907904106779947`*^9, 3.6907904201808643`*^9},
3.6907904985807133`*^9, 3.690790557281128*^9, 3.6907906516436677`*^9,
3.6907912799422746`*^9, 3.690791386456688*^9, {3.6907922152596855`*^9,
3.6907922432758446`*^9}, 3.6907924034496574`*^9, 3.6907926864353437`*^9, {
3.6907930296264763`*^9, 3.6907930380823455`*^9}, 3.690793077434612*^9,
3.6910796427546167`*^9, 3.691150208266796*^9, 3.691178017989274*^9}]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{"hingeLossShift", "[", "shift_", "]"}], ":=",
RowBox[{"Function", "[",
RowBox[{
RowBox[{"{",
RowBox[{"x", ",", "p", ",", "class"}], "}"}], ",",
RowBox[{"If", "[",
RowBox[{
RowBox[{"class", "\[Equal]", "1"}], ",",
RowBox[{"Max", "[",
RowBox[{"0", ",",
RowBox[{"x", "-", "p", "+", "shift"}]}], "]"}], ",",
RowBox[{"Max", "[",
RowBox[{"0", ",",
RowBox[{"p", "-", "x", "+", "shift"}]}], "]"}]}], "]"}]}], "]"}]}],
";"}], "\[IndentingNewLine]",
RowBox[{"sft", "=", "0.4"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"lossName", "=",
RowBox[{"\"\<Hinge Loss with Shift: \>\"", " ", "<>",
RowBox[{"ToString", "[", "sft", "]"}]}]}], ";"}], "\[IndentingNewLine]",
RowBox[{"Show", "[",
RowBox[{
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{"applyLossForPlt", "[",
RowBox[{"x", ",", "points1", ",", "1", ",",
RowBox[{"hingeLossShift", "[", "sft", "]"}]}], "]"}], " ", "+", " ",
RowBox[{"applyLossForPlt", "[",
RowBox[{"x", ",", "points2", ",", "2", ",",
RowBox[{"hingeLossShift", "[", "sft", "]"}]}], "]"}]}], ",", "0"}],
"}"}], ",",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"-", "3"}], ",", "3"}], "}"}], ",",
RowBox[{"PlotStyle", "\[Rule]",
RowBox[{"{",
RowBox[{"Blue", ",", "White"}], "}"}]}], ",",
RowBox[{"Exclusions", "\[Rule]", "None"}], ",", " ",
RowBox[{"PlotLabel", "\[Rule]",
RowBox[{"lossName", "<>", "\"\< example\>\""}]}], ",",
RowBox[{"AxesLabel", "\[Rule]",
RowBox[{"{",
RowBox[{"x", ",", "Loss"}], "}"}]}]}], "]"}], ",",
RowBox[{"ListPlot", "[",
RowBox[{"{",
RowBox[{"points1", ",", " ", "points2"}], "}"}], "]"}]}],
"]"}], "\[IndentingNewLine]",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{
RowBox[{"hingeLossShift", "[", "sft", "]"}], "[",
RowBox[{"x", ",", "0", ",", "1"}], "]"}], ",",
RowBox[{"{",
RowBox[{"x", ",",
RowBox[{"-", "2"}], ",", "2"}], "}"}], ",",
RowBox[{"PlotLabel", "\[Rule]", "lossName"}], ",",
RowBox[{"AxesLabel", "\[Rule]",
RowBox[{"{",
RowBox[{"\"\<Distance to Point\>\"", ",", "Loss"}], "}"}]}]}],
"]"}], "\[IndentingNewLine]"}], "Input",
CellChangeTimes->{{3.690752473099066*^9, 3.690752561154684*^9}, {
3.6907525941426272`*^9, 3.6907527133022265`*^9}, {3.6907527972106333`*^9,
3.690752820205948*^9}, {3.690752881769766*^9, 3.690752886771574*^9}, {
3.6907905610831523`*^9, 3.690790586264638*^9}, {3.6907906204457846`*^9,
3.690790620508231*^9}, {3.6907906590788918`*^9, 3.6907906620954313`*^9}, {
3.6907912927025433`*^9, 3.6907913001241217`*^9}, 3.6907920735034447`*^9, {
3.690792104521962*^9, 3.6907921798060036`*^9}, {3.6907924229380713`*^9,
3.69079245003621*^9}, {3.690793086722348*^9, 3.6907931187724147`*^9}}],
Cell[BoxData["0.4`"], "Output",
CellChangeTimes->{{3.6907525271821485`*^9, 3.69075256157046*^9}, {
3.690752614671867*^9, 3.6907527138022346`*^9}, 3.6907528212069845`*^9,
3.690752896796974*^9, 3.690790590079266*^9, 3.6907906211930847`*^9, {
3.6907906552618103`*^9, 3.690790662611157*^9}, {3.690791287083647*^9,
3.6907913006557817`*^9}, 3.690791388758895*^9, 3.6907921182974277`*^9, {
3.6907921510020905`*^9, 3.6907921806009674`*^9}, {3.6907924185009804`*^9,