pt.tumba.ngram.svm
Class Solver
java.lang.Object
pt.tumba.ngram.svm.Solver
- Direct Known Subclasses:
- SolverNU
public class Solver
- extends java.lang.Object
Generalized SMO+SVMlight algorithm
Solves:
min 0.5(\alpha^T Q \alpha) + b^T \alpha
y^T \alpha = \delta
y_i = +1 or -1
0 <= alpha_i <= Cp for y_i = 1
0 <= alpha_i <= Cn for y_i = -1
Given:
Q, b, y, Cp, Cn, and an initial feasible point \alpha
l is the size of vectors and matrices
eps is the stopping criterion
solution will be put in \alpha, objective value will be put in obj
Field Summary |
(package private) int[] |
activeSet
|
(package private) int |
activeSize
|
(package private) double[] |
alpha
|
(package private) byte[] |
alphaStatus
|
(package private) double[] |
b
|
(package private) double |
Cn
|
(package private) double |
Cp
|
(package private) double |
eps
|
(package private) static byte |
FREE
|
(package private) double[] |
G
|
(package private) double[] |
GBar
|
(package private) static double |
INF
|
(package private) int |
l
|
(package private) static byte |
LOWER_BOUND
|
(package private) Kernel |
Q
|
(package private) boolean |
unshrinked
|
(package private) static byte |
UPPER_BOUND
|
(package private) byte[] |
y
|
Method Summary |
(package private) double |
calculateRho()
|
(package private) void |
doShrinking()
|
(package private) double |
getC(int i)
|
(package private) boolean |
isFree(int i)
|
(package private) boolean |
isLowerBound(int i)
|
(package private) boolean |
isUpperBound(int i)
|
(package private) void |
reconstructGradient()
|
(package private) int |
selectWorkingSet(int[] working_set)
|
(package private) void |
Solve(int l,
Kernel Q,
double[] b_,
byte[] y_,
double[] alpha_,
double Cp,
double Cn,
double eps,
Solver.SolutionInfo si,
boolean shrinking)
|
(package private) void |
swapIndex(int i,
int j)
|
(package private) void |
updateAlphaStatus(int i)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
activeSize
int activeSize
y
byte[] y
G
double[] G
LOWER_BOUND
static final byte LOWER_BOUND
- See Also:
- Constant Field Values
UPPER_BOUND
static final byte UPPER_BOUND
- See Also:
- Constant Field Values
FREE
static final byte FREE
- See Also:
- Constant Field Values
alphaStatus
byte[] alphaStatus
alpha
double[] alpha
Q
Kernel Q
eps
double eps
Cp
double Cp
Cn
double Cn
b
double[] b
activeSet
int[] activeSet
GBar
double[] GBar
l
int l
unshrinked
boolean unshrinked
INF
static final double INF
- See Also:
- Constant Field Values
Solver
public Solver()
getC
double getC(int i)
updateAlphaStatus
void updateAlphaStatus(int i)
isUpperBound
boolean isUpperBound(int i)
isLowerBound
boolean isLowerBound(int i)
isFree
boolean isFree(int i)
swapIndex
void swapIndex(int i,
int j)
reconstructGradient
void reconstructGradient()
Solve
void Solve(int l,
Kernel Q,
double[] b_,
byte[] y_,
double[] alpha_,
double Cp,
double Cn,
double eps,
Solver.SolutionInfo si,
boolean shrinking)
selectWorkingSet
int selectWorkingSet(int[] working_set)
doShrinking
void doShrinking()
calculateRho
double calculateRho()