1 package liblinear;
2
3 import java.io.File;
4 import java.io.IOException;
5
6
7 /**
8 * <p>Problem describes the problem</p>
9 *
10 * <p><pre>
11 * For example, if we have the following training data:
12 *
13 * LABEL ATTR1 ATTR2 ATTR3 ATTR4 ATTR5
14 * ----- ----- ----- ----- ----- -----
15 * 1 0 0.1 0.2 0 0
16 * 2 0 0.1 0.3 -1.2 0
17 * 1 0.4 0 0 0 0
18 * 2 0 0.1 0 1.4 0.5
19 * 3 -0.1 -0.2 0.1 1.1 0.1
20 *
21 * and bias = 1, then the components of problem are:
22 *
23 * l = 5
24 * n = 6
25 *
26 * y -> 1 2 1 2 3
27 *
28 * x -> [ ] -> (2,0.1) (3,0.2) (6,1) (-1,?)
29 * [ ] -> (2,0.1) (3,0.3) (4,-1.2) (6,1) (-1,?)
30 * [ ] -> (1,0.4) (6,1) (-1,?)
31 * [ ] -> (2,0.1) (4,1.4) (5,0.5) (6,1) (-1,?)
32 * [ ] -> (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (6,1) (-1,?)
33 * </pre></p>
34 */
35 public class Problem {
36
37 /** the number of training data */
38 public int l;
39
40 /** the number of features (including the bias feature if bias >= 0) */
41 public int n;
42
43 /** an array containing the target values */
44 public int[] y;
45
46 /** array of sparse feature nodes */
47 public FeatureNode[][] x;
48
49 /**
50 * If bias >= 0, we assume that one additional feature is added
51 * to the end of each data instance
52 */
53 public double bias;
54
55 /**
56 * see {@link Train#readProblem(File, double)}
57 */
58 public static Problem readFromFile(File file, double bias) throws IOException, InvalidInputDataException {
59 return Train.readProblem(file, bias);
60 }
61 }