Permalink
Browse files

Fixed a bug of null feature handling

  • Loading branch information...
1 parent 7c9cf02 commit 1f392a38d5a1c98ae85a481bae45d2696fd28fea @myui committed Oct 22, 2013
@@ -106,6 +106,9 @@ protected void update(final List<?> features, final int y, final float alpha, fi
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -181,6 +181,9 @@ protected float predict(final List<?> features) {
float score = 0f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -215,6 +218,9 @@ protected PredictionResult calcScoreAndNorm(List<?> features) {
float squared_norm = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -251,6 +257,9 @@ protected PredictionResult calcScoreAndVariance(List<?> features) {
float variance = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -291,6 +300,9 @@ protected void update(final List<?> features, final float coeff) {
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {// w[f] += y * x[f]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -122,6 +122,9 @@ protected void update(final List<?> features, final float coeff, final float alp
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -232,6 +232,9 @@ protected void update(final List<?> features, final int y, final float alpha, fi
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -125,6 +125,9 @@ protected void update(final List<?> features, final Object actual_label, final O
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {// w[f] += y * x[f]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -146,6 +146,9 @@ protected void update(List<?> features, float alpha, Object actual_label, Object
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {// w[f] += y * x[f]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -256,6 +256,9 @@ protected final float squaredNorm(final List<?> features) {
float squared_norm = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final float v;
if(parseX) {
FeatureValue fv = FeatureValue.parse(f, feature_hashing);
@@ -280,6 +283,9 @@ protected final float calcScore(final Map<Object, WeightValue> weights, final Li
float score = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -312,6 +318,9 @@ protected final float calcVariance(final List<?> features) {
float variance = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final float v;
if(parseX) {
FeatureValue fv = FeatureValue.parse(f, feature_hashing);
@@ -337,6 +346,9 @@ protected final PredictionResult calcScoreAndVariance(final Map<Object, WeightVa
float variance = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -393,6 +405,9 @@ protected void update(List<?> features, float coeff, Object actual_label, Object
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {// w[f] += y * x[f]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -254,6 +254,9 @@ protected void update(final List<?> features, final Object actual_label, final O
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {// w[f] += y * x[f]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -102,6 +102,9 @@ protected void update(final Collection<?> features, final float coeff, final flo
final ObjectInspector featureInspector = featureListOI.getListElementObjectInspector();
for(Object f : features) {
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -186,6 +186,9 @@ protected float predict(final Collection<?> features) {
float score = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -220,6 +223,9 @@ protected PredictionResult calcScoreAndNorm(Collection<?> features) {
float squared_norm = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -256,6 +262,9 @@ protected PredictionResult calcScoreAndVariance(Collection<?> features) {
float variance = 0.f;
for(Object f : features) {// a += w[i] * x[i]
+ if(f == null) {
+ continue;
+ }
final Object k;
final float v;
if(parseX) {
@@ -301,6 +310,9 @@ protected void update(Collection<?> features, float coeff) {
final ObjectInspector featureInspector = this.featureInputOI;
for(Object f : features) {// w[i] += y * x[i]
+ if(f == null) {
+ continue;
+ }
final Object x;
final float xi;
if(parseX) {

0 comments on commit 1f392a3

Please sign in to comment.