22I implement the soft margin of Support Vector Machines with Stochastic Gradient Descent.
33"
44Class {
5- #name : #AISupportVectorMachinesSoftSGD ,
5+ #name : #AISupportVectorMachines ,
66 #superclass : #Object ,
77 #instVars : [
88 ' weights' ,
@@ -14,7 +14,7 @@ Class {
1414}
1515
1616{ #category : #accessing }
17- AISupportVectorMachinesSoftSGD >> calculateCostGradientX: inputMatrix y: outputVector [
17+ AISupportVectorMachines >> calculateCostGradientX: inputMatrix y: outputVector [
1818
1919 | distance dw di numberOfRows output input |
2020 numberOfRows := inputMatrix size.
@@ -40,15 +40,15 @@ AISupportVectorMachinesSoftSGD >> calculateCostGradientX: inputMatrix y: outputV
4040]
4141
4242{ #category : #' as yet unclassified' }
43- AISupportVectorMachinesSoftSGD >> calculateDistancesForX: inputMatrix y: outputVector [
43+ AISupportVectorMachines >> calculateDistancesForX: inputMatrix y: outputVector [
4444
4545 | xDotWeights |
4646 xDotWeights := inputMatrix collect: [ :row | (row * weights) sum ].
4747 ^ 1 - (outputVector * xDotWeights)
4848]
4949
5050{ #category : #accessing }
51- AISupportVectorMachinesSoftSGD >> computeCostX: inputMatrix y: outputVector [
51+ AISupportVectorMachines >> computeCostX: inputMatrix y: outputVector [
5252
5353 | numberOfRows distances hingeLoss cost |
5454 numberOfRows := inputMatrix size.
@@ -64,7 +64,7 @@ AISupportVectorMachinesSoftSGD >> computeCostX: inputMatrix y: outputVector [
6464]
6565
6666{ #category : #' as yet unclassified' }
67- AISupportVectorMachinesSoftSGD >> fitX: inputMatrix y: outputVector [
67+ AISupportVectorMachines >> fitX: inputMatrix y: outputVector [
6868
6969 " Stochastic Gradient Descent With Stoppage Criterion"
7070
@@ -93,40 +93,40 @@ AISupportVectorMachinesSoftSGD >> fitX: inputMatrix y: outputVector [
9393]
9494
9595{ #category : #accessing }
96- AISupportVectorMachinesSoftSGD >> learningRate: aNumber [
96+ AISupportVectorMachines >> learningRate: aNumber [
9797 learningRate := aNumber
9898]
9999
100100{ #category : #accessing }
101- AISupportVectorMachinesSoftSGD >> maxEpochs: aNumber [
101+ AISupportVectorMachines >> maxEpochs: aNumber [
102102 maxEpochs := aNumber
103103]
104104
105105{ #category : #' as yet unclassified' }
106- AISupportVectorMachinesSoftSGD >> predict: inputMatrix [
106+ AISupportVectorMachines >> predict: inputMatrix [
107107
108108 ^ self signFunction: inputMatrix
109109
110110
111111]
112112
113113{ #category : #accessing }
114- AISupportVectorMachinesSoftSGD >> regularizationStrenght: aNumber [
114+ AISupportVectorMachines >> regularizationStrenght: aNumber [
115115 regularizationStrenght := aNumber
116116]
117117
118118{ #category : #' as yet unclassified' }
119- AISupportVectorMachinesSoftSGD >> signFunction: inputMatrix [
119+ AISupportVectorMachines >> signFunction: inputMatrix [
120120
121121 ^ inputMatrix collect: [ :row | ((row * weights) sum) sign ]
122122]
123123
124124{ #category : #accessing }
125- AISupportVectorMachinesSoftSGD >> weights [
125+ AISupportVectorMachines >> weights [
126126 ^ weights
127127]
128128
129129{ #category : #accessing }
130- AISupportVectorMachinesSoftSGD >> weights: aCollection [
130+ AISupportVectorMachines >> weights: aCollection [
131131 weights := aCollection
132132]
0 commit comments