summaryrefslogtreecommitdiff
path: root/bordeaux/learning/stochastic_linear_ranker/jni/jni_stochastic_linear_ranker.h
blob: 09a7047bcc6f7ecddb1b2582e203bb548aac25e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LEARNING_JNI_STOCHASTIC_LINEAR_RANKER_H
#define LEAENING_JNI_STOCHASTIC_LINEAR_RANKER_H

#include <jni.h>

#ifdef __cplusplus
extern "C" {
#endif

/*  Counts the number of learning iterations. */
const char * ITR_NUM = "IterationNumber";

/*  The maximum norm of the weight vector. If norm of weights are larger than NormConstraint
    they will be reprojected using RegularizationType to satisfy this constraint. */
const char * NORM_CONSTRAINT = "NormConstraint";

/*  Ddetermines type of the regularization used in learning.
    This regularization can be based on different norms.
    Options: "L0", "L1", "L2", "L1L2", "L1LInf".
    Default : LINEAR */
const char * REG_TYPE = "RegularizationType";

/*  Lambda is a factor that is multiplied with the step size in learning. This can be used
    to change the step size.
    Default : 1.0 */
const char * LAMBDA = "Lambda";

/*  This parameter determines the update type in learning process.
    Options: "FULL_CS" , "CLIP_CS", "REG_CS", "SL", "ADAPTIVE_REG"
    Default : "SL" */
const char * UPDATE_TYPE = "UpdateType";

/*  Options: "CONST", "INV_LINEAR", "INV_QUADRATIC", "INV_SQRT"
    Default: "INV_LINEAR". */
const char * ADAPT_MODE = "AdaptationMode";

/*  Three differnt kernels are supported: Linear "LINEAR", Polynomial "POLY", and RBF "RBF"
    Default : "LINEAR" */
const char * KERNEL_TYPE = "KernelType";

/*  Kernel param is kernel-specific. In case of polynomial kernel, it is the degree of the
    polynomial. In case of RBF kernel, it implies the sigma parameter. In case of linear
    kernel, it is not used. */
const char * KERNEL_PARAM = "KernelParameter";

/*  Kernel gain is typically a multiplicative factor to the dot product while calculating
    the kernel function. In most use cases, gain should be set to 1.0. */
const char * KERNEL_GAIN = "KernelGain";

/*  Kernel bias is typically an additive factors to the dot product while calculating
    the kernel function. In most use cases, bias should be set to 0.0. */
const char * KERNEL_BIAS = "KernelBias";

/*  This parameter determines the type of loss function to minimize.
    Options : "PAIRWISE", "RECIPROCAL_RANK"
    Default : "PAIRWISE" */
const char * LOSS_TYPE = "LossType";

/*  The minimum percent of training pairs that are used in training.
    Default : "0.1" */
const char * ACC_PROB = "AcceptaceProbability";

/*  The code averages out gradient updates for MinimumBatchSize samples
    before performing an iteration of the algorithm. */
const char * MIN_BATCH_SIZE = "MinimumBatchSize";

/*  Specifies the number of non-zero entries allowed in a gradient.
    Default is -1 which means we take the gradient as given by data without
    adding any new constraints. positive number is treated as an L0 constraint */
const char * GRAD_L0_NORM = "GradientL0Nrom";

const char * REG_TYPE_L0 = "L0";
const char * REG_TYPE_L1 = "L1";
const char * REG_TYPE_L2 = "L2";
const char * REG_TYPE_L1L2 = "L1L2";
const char * REG_TYPE_L1LInf = "L1LInf";
const char * UPDATE_TYPE_FULL_CS = "FULL_CS";
const char * UPDATE_TYPE_CLIP_CS = "CLIP_CS";
const char * UPDATE_TYPE_REG_CS = "REG_CS";
const char * UPDATE_TYPE_SL = "SL";
const char * UPDATE_TYPE_ADAPTIVE_REG = "ADAPTIVE_REG";
const char * ADAPT_MODE_CONST = "CONST";
const char * ADAPT_MODE_INV_LINEAR = "INV_LINEAR";
const char * ADAPT_MODE_INV_QUADRATIC = "INV_QUADRATIC";
const char * ADAPT_MODE_INV_SQRT = "INV_SQRT";
const char * KERNEL_TYPE_LINEAR = "LINEAR";
const char * KERNEL_TYPE_POLY = "POLY";
const char * KERNEL_TYPE_RBF = "RBF";
const char * LOSS_TYPE_PAIRWISE = "PAIRWISE";
const char * LOSS_TYPE_RECIPROCAL_RANK = "RECIPROCAL_RANK";

JNIEXPORT jlong JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_initNativeClassifier(
    JNIEnv* env,
    jobject thiz);


JNIEXPORT jboolean JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_deleteNativeClassifier(
    JNIEnv* env,
    jobject thiz,
    jlong paPtr);

JNIEXPORT jboolean JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_nativeUpdateClassifier(
    JNIEnv* env,
    jobject thiz,
    jobjectArray key_array_positive,
    jfloatArray value_array_positive,
    jobjectArray key_array_negative,
    jfloatArray value_array_negative,
    jlong paPtr);

JNIEXPORT jfloat JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_nativeScoreSample(
    JNIEnv* env,
    jobject thiz,
    jobjectArray key_array,
    jfloatArray value_array,
    jlong paPtr);

JNIEXPORT void JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_nativeGetWeightClassifier(
    JNIEnv* env,
    jobject thiz,
    jobjectArray key_array_weight,
    jfloatArray value_array_weight,
    jfloat normalizer,
    jlong paPtr);

JNIEXPORT void JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_nativeGetParameterClassifier(
    JNIEnv* env,
    jobject thiz,
    jobjectArray key_array_param,
    jobjectArray value_array_param,
    jlong paPtr);

JNIEXPORT jint JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_nativeGetLengthClassifier(
    JNIEnv* env,
    jobject thiz,
    jlong paPtr);

JNIEXPORT jboolean JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_nativeSetWeightClassifier(
    JNIEnv* env,
    jobject thiz,
    jobjectArray key_array_model,
    jfloatArray value_array_model,
    jfloat normalizer_model,
    jlong paPtr);

JNIEXPORT jboolean JNICALL
Java_android_bordeaux_learning_StochasticLinearRanker_nativeSetParameterClassifier(
    JNIEnv* env,
    jobject thiz,
    jstring key,
    jstring value,
    jlong paPtr);

#ifdef __cplusplus
}
#endif

#endif /* ANDROID_LERNING_JNI_STOCHASTIC_LINEAR_RANKER_H */