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