Skip to content

Commit bc0a7e5

Browse files
committed
updated LBJLANGUAGE
1 parent 5c17879 commit bc0a7e5

1 file changed

Lines changed: 63 additions & 15 deletions

File tree

lbjava/doc/LBJLANGUAGE.md

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
---
2-
title: LBJLANGUAGE
3-
---
4-
5-
# 4 The LBJava Language
1+
# 4 The LBJava Language
62
Now that we have defined the building blocks of classifier computation, we next describe LBJava’s
73
syntax and semantics for programming with these building blocks.
84

@@ -19,7 +15,7 @@ classifiers using special operators. As such, the syntax of classifier specifica
1915
to treat classifiers as expressions and assign them to names. This section defines the
2016
syntax of classifier specification more precisely, including the syntax of classifiers learned from
2117
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.
2319

2420
### 4.1.1 Classifier Declarations
2521

@@ -274,11 +270,11 @@ classifier expression in the `using` clause does all the feature extraction on e
274270
both training and evaluation. It will often be a composite generator.
275271

276272
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
278274
is optional. If it appears, the LBJava compiler will automatically perform training on the learner
279275
represented by this learning classifier expression at compile-time. Whether it appears or not, the
280276
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).
282278

283279
When the `from` clause appears, the LBJava compiler retrieves objects from the specified parser
284280
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
289285
the classifier during training.
290286

291287
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
293289
generated Java class implementing this learning classifier will be derived from the class named
294290
in the `with` clause. Otherwise, the default learner for the declared return type of this learning
295291
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
333329
are as equally sized as possible.
334330

335331
- `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
337333
desired. Each time this object appears, it represents a partition between two folds. Thus,
338334
if the k-fold cross validation is desired, it should appear k − 1 times. The integer provided
339335
after the `cval` keyword is ignored and may be omitted in this case.
340336

341337
The `testingMetric` and `alpha` clauses are sub-clauses of `cval`, and, consequently, have no
342338
effect when the `cval` clause is not present. The `testingMetric` clause gives the user the opportunity
343339
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
346342
predictions made by the classifier on the testing fold to the total number of examples contained
347343
within said fold.
348344

@@ -483,7 +479,7 @@ resulting value will be converted to a `String`.
483479
define a classifier using arbitrary Java. However, the current version of LBJava suffers from one
484480
major limitation. All J2SE 1.4.2 statement and expression syntax is accepted, excluding class
485481
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.
487483

488484
## 4.2 Constraints
489485
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
664660
Finally, the `with` clause specifies which inference algorithm to use. It functions similarly to
665661
the `with` clause of a learning classifier expression (see Section 4.1.2.6).
666662

667-
## 4.4 "Makefile" Behavior
663+
## 4.4 Makefile Behavior
668664

669665
An LBJava source file also functions as a makefile in the following sense. First, code will only be
670666
generated for a classifier definition when it is determined that a change has been made5
671667
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
673669
(When the file(s) containing the translated code for a given classifier do not exist, this is, of course, also interpreted
674670
as a change having been made).
675671
Second, a learning
@@ -687,3 +683,55 @@ line parameters (see Section 6.2). For example, if the classifiers in an LBJava
687683
to take classes from the programmer’s internal representation as input, the LBJava compiler will
688684
automatically compile the Java source files containing those class’ implementations if their class
689685
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:
735+
```
736+
cval k "random"
737+
```

0 commit comments

Comments
 (0)