@@ -43,7 +43,7 @@ public class FFMOnlinePredictor extends ContinuousOnlinePredictor<float[]> {
4343 private final Map <String , Integer > field2IndexMap = new HashMap <>();
4444 private int fieldSize ;
4545
46- private final ThreadLocal <double []> assistbuffer = new ThreadLocal <>();
46+ private final ThreadLocal <float []> assistbuffer = new ThreadLocal <>();
4747 private final ThreadLocal <int []> fieldbuffer = new ThreadLocal <>();
4848 private final ThreadLocal <float []> valbuffer = new ThreadLocal <>();
4949
@@ -55,9 +55,9 @@ public FFMOnlinePredictor(String configPath) throws Exception {
5555 List <Integer > klist = config .getIntList ("k" );
5656 K = klist .get (1 );
5757
58- fieldDelim = config .getString ("field_delim" );
58+ fieldDelim = config .getString ("data.delim. field_delim" );
5959 fieldDictPath = config .getString ("model.field_dict_path" );
60- maxFeatureNum = config .getInt ("max_line_feature_num" ) ;
60+ maxFeatureNum = config .getInt ("data.max_feature_dim" ) + 1 ;
6161
6262 loadModel ();
6363 }
@@ -68,9 +68,9 @@ public FFMOnlinePredictor(Reader configReader) throws Exception {
6868 List <Integer > klist = config .getIntList ("k" );
6969 K = klist .get (1 );
7070
71- fieldDelim = config .getString ("field_delim" );
71+ fieldDelim = config .getString ("data.delim. field_delim" );
7272 fieldDictPath = config .getString ("model.field_dict_path" );
73- maxFeatureNum = config .getInt ("max_line_feature_num" ) ;
73+ maxFeatureNum = config .getInt ("data.max_feature_dim" ) + 1 ;
7474
7575 loadModel ();
7676 }
@@ -104,24 +104,24 @@ protected OnlinePredictor loadModel() throws Exception {
104104 }
105105
106106 int cnt = 0 ;
107- iterators = fs .read (Arrays .asList (fieldDictPath ));
107+ iterators = fs .read (Arrays .asList (modelParams . data_path ));
108108 for (Iterator <String > it : iterators ) {
109109 while (it .hasNext ()) {
110110 String line = it .next ();
111111 if (line .trim ().length () == 0 ) {
112- LOG .error ("invalid model line:" + line );
112+ LOG .error ("invalid model line(length=0) :" + line );
113113 continue ;
114114 }
115115 String []info = line .trim ().split (modelParams .delim );
116- if (fieldSize != (info .length - 5 ) / K ) {
117- LOG .info ("invalid model line:" + line );
118- continue ;
119- }
116+ // if (fieldSize != (info.length - 5) / K) {
117+ // LOG.info("invalid model line:" + line);
118+ // continue;
119+ // }
120120
121- if (info .length < 2 ) {
122- LOG .error ("[invalid model line:" + line );
123- continue ;
124- }
121+ // if (info.length < 2) {
122+ // LOG.error("[invalid model line:" + line);
123+ // continue;
124+ // }
125125
126126
127127 float []w = modelMap .get (info [0 ]);
@@ -156,9 +156,9 @@ public double score(Map<String, Float> features, Object other) {
156156
157157 int stride = fieldSize * K ;
158158
159- double []assist = assistbuffer .get ();
159+ float []assist = assistbuffer .get ();
160160 if (assist == null ) {
161- assist = new double [K * fieldSize * (maxFeatureNum + 1 )];
161+ assist = new float [K * fieldSize * (maxFeatureNum + 1 )];
162162 assistbuffer .set (assist );
163163 }
164164
@@ -183,7 +183,11 @@ public double score(Map<String, Float> features, Object other) {
183183 for (Map .Entry <String , Float > feature : features .entrySet ()) {
184184
185185 // field idx
186- fieldIdxArr [cidx ] = field2IndexMap .get (feature .getKey ().split (fieldDelim )[0 ]);
186+ Integer fieldIdx = field2IndexMap .get (feature .getKey ().split (fieldDelim )[0 ]);
187+ if (fieldIdx == null ) {
188+ continue ;
189+ }
190+ fieldIdxArr [cidx ] = fieldIdx ;
187191
188192 float val = transform (feature .getKey (), feature .getValue ());
189193 // val
0 commit comments