public class CRF
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
CRF(smile.data.type.StructType schema,
RegressionTree[][] potentials,
double shrinkage)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static CRF |
fit(smile.data.Tuple[][] sequences,
int[][] labels)
Fits a CRF model.
|
static CRF |
fit(smile.data.Tuple[][] sequences,
int[][] labels,
int ntrees,
int maxDepth,
int maxNodes,
int nodeSize,
double shrinkage)
Fits a CRF model.
|
static CRF |
fit(smile.data.Tuple[][] sequences,
int[][] labels,
java.util.Properties prop)
Fits a CRF model.
|
int[] |
predict(smile.data.Tuple[] x)
Returns the most likely label sequence given the feature sequence by the
forward-backward algorithm.
|
int[] |
viterbi(smile.data.Tuple[] x)
Labels sequence with Viterbi algorithm.
|
public CRF(smile.data.type.StructType schema, RegressionTree[][] potentials, double shrinkage)
schema
- the schema of features.potentials
- the potential functions.shrinkage
- the learning rate.public int[] viterbi(smile.data.Tuple[] x)
public int[] predict(smile.data.Tuple[] x)
x
- a sequence.public static CRF fit(smile.data.Tuple[][] sequences, int[][] labels)
sequences
- the training data.labels
- the training sequence labels.public static CRF fit(smile.data.Tuple[][] sequences, int[][] labels, java.util.Properties prop)
sequences
- the training data.labels
- the training sequence labels.public static CRF fit(smile.data.Tuple[][] sequences, int[][] labels, int ntrees, int maxDepth, int maxNodes, int nodeSize, double shrinkage)
sequences
- the training data.labels
- the training sequence labels.ntrees
- the number of trees/iterations.maxDepth
- the maximum depth of the tree.maxNodes
- the maximum number of leaf nodes in the tree.nodeSize
- the number of instances in a node below which the tree will
not split, setting nodeSize = 5 generally gives good results.shrinkage
- the shrinkage parameter in (0, 1] controls the learning rate of procedure.