@@ -180,12 +180,28 @@ $model->train($ff,$tset,$optimizer);
180
180
```
181
181
182
182
After we have trained our model, in order to use it for classification
183
- we have to use it with a compatible classifier. In every possible
184
- parameter types and interfaces are explicitly declared in order to
185
- ensure that only compatible types will be used.
186
-
187
- Maxent is a linear model so we will use the FeatureBasedLinearClassifier.
188
- We also pass the feature factory to the classifier.
183
+ we have to use it with a compatible classifier. Wherever possible
184
+ parameter types are explicitly declared in order to ensure that only
185
+ compatible types will be used (Which means that if not sure one can
186
+ check what type of model does Maxent implement and then use any
187
+ classifier that accepts that model as a parameter).
188
+
189
+ Maxent creates a set of weights for each feature, the linear
190
+ combination of the features with those weights decides the class of
191
+ the document so we will use the FeatureBasedLinearClassifier. We also
192
+ pass the feature factory to the classifier so that it can recreate
193
+ which features would fire for a given class.
194
+
195
+ Let's define some stuff:
196
+
197
+ * _ ff(d,c)_ is the feature factory function and returns a vector with
198
+ either 0 or 1 for each feature
199
+ * _ w_ is our model which is a vector of real numbers and the same size
200
+ as the one returned by the _ ff(d,c)_ . It is calculated during
201
+ training.
202
+
203
+ So the classification comes down to _ argmax<sub >c</sub >(ff(d,c) • w)_
204
+ where • denotes the inner product of two vectors.
189
205
190
206
``` php
191
207
$cls = new NlpTools\FeatureBasedLinearClassifier($ff,$model);
0 commit comments