Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
Fixed a bug of null feature handling
Browse files Browse the repository at this point in the history
  • Loading branch information
myui committed Oct 22, 2013
1 parent 7c9cf02 commit 1f392a3
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/hivemall/classifier/AROWClassifierUDTF.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/hivemall/classifier/BinaryOnlineClassifierUDTF.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/hivemall/classifier/ConfidenceWeightedUDTF.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/hivemall/classifier/SoftConfideceWeightedUDTF.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/hivemall/regression/AROWRegressionUDTF.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/hivemall/regression/OnlineRegressionUDTF.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1f392a3

Please sign in to comment.