You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lbjava/doc/LBJLANGUAGE.md
+63-15Lines changed: 63 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,4 @@
1
-
---
2
-
title: LBJLANGUAGE
3
-
---
4
-
5
-
# 4 The LBJava Language
1
+
# 4 The LBJava Language
6
2
Now that we have defined the building blocks of classifier computation, we next describe LBJava’s
7
3
syntax and semantics for programming with these building blocks.
8
4
@@ -19,7 +15,7 @@ classifiers using special operators. As such, the syntax of classifier specifica
19
15
to treat classifiers as expressions and assign them to names. This section defines the
20
16
syntax of classifier specification more precisely, including the syntax of classifiers learned from
21
17
data. It also details the behavior of the LBJava compiler when classifiers are specified in terms of
22
-
training data and when changes are made to an LBJava source file.
18
+
training data and when changes are made to an LBJava source file.
23
19
24
20
### 4.1.1 Classifier Declarations
25
21
@@ -274,11 +270,11 @@ classifier expression in the `using` clause does all the feature extraction on e
274
270
both training and evaluation. It will often be a composite generator.
275
271
276
272
The instance creation expression in the `from` clause should create an object of a class that
277
-
implements the `LBJ2.parser.Parser` interface in the library (see Section 5.4.1). This clause
273
+
implements the `parser.Parser` interface in the library (see Section 5.4.1). This clause
278
274
is optional. If it appears, the LBJava compiler will automatically perform training on the learner
279
275
represented by this learning classifier expression at compile-time. Whether it appears or not, the
280
276
programmer may continue training the learner on-line in the application via methods defined in
281
-
`LBJ2.learn.Learner` in the library (see Section 5.2.1).
277
+
`learn.Learner` in the library (see Section 5.2.1).
282
278
283
279
When the `from` clause appears, the LBJava compiler retrieves objects from the specified parser
284
280
until it finally returns `null`. One at a time, the feature extraction classifier is applied to each
@@ -289,7 +285,7 @@ specifies a number of rounds, or the number of passes over the training data to
289
285
the classifier during training.
290
286
291
287
The instance creation expression in the `with` clause should create an object of a class derived
292
-
from the `LBJ2.learn.Learner` class in the library. This clause is also optional. If it appears, the
288
+
from the `learn.Learner` class in the library. This clause is also optional. If it appears, the
293
289
generated Java class implementing this learning classifier will be derived from the class named
294
290
in the `with` clause. Otherwise, the default learner for the declared return type of this learning
295
291
classifier will be substituted with default parameter settings.
@@ -333,16 +329,16 @@ subsets (folds). If the `split-strategy` argument is not provided, the default v
333
329
are as equally sized as possible.
334
330
335
331
-`manual` - The user may write their parser so that it returns the unique instance of the
336
-
`LBJ2.parse.FoldSeparator` class (see the `separator` field) wherever a fold boundary is
332
+
`parse.FoldSeparator` class (see the `separator` field) wherever a fold boundary is
337
333
desired. Each time this object appears, it represents a partition between two folds. Thus,
338
334
if the k-fold cross validation is desired, it should appear k − 1 times. The integer provided
339
335
after the `cval` keyword is ignored and may be omitted in this case.
340
336
341
337
The `testingMetric` and `alpha` clauses are sub-clauses of `cval`, and, consequently, have no
342
338
effect when the `cval` clause is not present. The `testingMetric` clause gives the user the opportunity
343
339
to provide a custom testing methodology. The object provided to the `testingMetric`
344
-
clause must implement the `LBJ2.learn.TestingMetric` interface. If this clause is not provided,
345
-
then it will default to the `LBJ2.learn.Accuracy` metric, which simply returns the ratio of correct
340
+
clause must implement the `learn.TestingMetric` interface. If this clause is not provided,
341
+
then it will default to the `learn.Accuracy` metric, which simply returns the ratio of correct
346
342
predictions made by the classifier on the testing fold to the total number of examples contained
347
343
within said fold.
348
344
@@ -483,7 +479,7 @@ resulting value will be converted to a `String`.
483
479
define a classifier using arbitrary Java. However, the current version of LBJava suffers from one
484
480
major limitation. All J2SE 1.4.2 statement and expression syntax is accepted, excluding class
485
481
and interface definitions. In particular, this means that anonymous classes currently cannot be
486
-
defined or instantiated inside an LBJava method body.
482
+
defined or instantiated inside an LBJava method body.
487
483
488
484
## 4.2 Constraints
489
485
Many modern applications involve the repeated application of one or more learning classifiers in
@@ -664,12 +660,12 @@ The `subjectto` clause may also contain arbitrary Java, just like any other cons
664
660
Finally, the `with` clause specifies which inference algorithm to use. It functions similarly to
665
661
the `with` clause of a learning classifier expression (see Section 4.1.2.6).
666
662
667
-
## 4.4 "Makefile" Behavior
663
+
## 4.4 “Makefile” Behavior
668
664
669
665
An LBJava source file also functions as a makefile in the following sense. First, code will only be
670
666
generated for a classifier definition when it is determined that a change has been made5
671
667
in the
672
-
LBJava source for that classifier since the last time the compiler was executed
668
+
LBJava source for that classifier since the last time the compiler was executed
673
669
(When the file(s) containing the translated code for a given classifier do not exist, this is, of course, also interpreted
674
670
as a change having been made).
675
671
Second, a learning
@@ -687,3 +683,55 @@ line parameters (see Section 6.2). For example, if the classifiers in an LBJava
687
683
to take classes from the programmer’s internal representation as input, the LBJava compiler will
688
684
automatically compile the Java source files containing those class’ implementations if their class
689
685
files don’t already exist or are out of date.
686
+
687
+
## 4.5 Parameter Tuning Syntax
688
+
689
+
Parameter turning is essential in machine learning, as it allows the programmers to find the best parameters in the learning algorithms to perform to their maximum extent. LBJava has intuitive syntax to tune parameters easily. Please see the subsections below to learn more.
690
+
691
+
### 4.5.1 Set of Parameters
692
+
693
+
We want to try a set of predefined parameters.
694
+
695
+
The syntax is:
696
+
```
697
+
{{value1, value2, value3}}
698
+
```
699
+
700
+
For example, we want the algorithm to try 5, 10, 20, 30, 40 iterations.
701
+
702
+
The `LBJava` code looks like:
703
+
```
704
+
{{5, 10, 20, 30, 40}} rounds
705
+
```
706
+
707
+
Another example, we want the algorithm to try different learning rates, such as 0.5, 0.1, 0.005.
708
+
709
+
The `LBJava` code looks like:
710
+
```
711
+
p.learningRate = {{0.5, 0.1, 0.005}};
712
+
```
713
+
714
+
### 4.5.2 Parameters in Steps
715
+
716
+
We want to try a set of parameters, within a range, with steps.
717
+
718
+
Let's denote the range from `start`, to `end`, with step size `step_size`.
719
+
720
+
The syntax is:
721
+
```
722
+
{{step_size -> start : end}}
723
+
```
724
+
725
+
For example, we want to try thickness in `SparseAvergedPerceptron`, from 3 to 0.5, with step size 1.
726
+
727
+
The `LBJava` code looks like:
728
+
```
729
+
p.thinkness = {{ 1 -> 3 : 0.5}};
730
+
```
731
+
732
+
### 4.5.3 Cross Validation
733
+
734
+
Cross validation is useful, and essential to avoid overfitting problem. For k-fold cross validation, the syntax is:
0 commit comments