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

Commit

Permalink
Changed the behavior of add_bias()
Browse files Browse the repository at this point in the history
  • Loading branch information
myui committed Aug 4, 2014
1 parent 25df4a7 commit dc46f73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 8 additions & 0 deletions scripts/ddl/define-ftvec-udf.hive
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,20 @@ create temporary function rand_amplify as 'hivemall.ftvec.amplify.RandomAmplifie
drop temporary function conv2dense;
create temporary function conv2dense as 'hivemall.ftvec.ConvertToDenseModelUDAF';

-- for backward compatibility
drop temporary function addBias;
create temporary function addBias as 'hivemall.ftvec.AddBiasUDF';

drop temporary function add_bias;
create temporary function add_bias as 'hivemall.ftvec.AddBiasUDF';

-- for backward compatibility
drop temporary function sortByFeature;
create temporary function sortByFeature as 'hivemall.ftvec.SortByFeatureUDF';

drop temporary function sort_by_feature;
create temporary function sort_by_feature as 'hivemall.ftvec.SortByFeatureUDF';

drop temporary function extract_feature;
create temporary function extract_feature as 'hivemall.ftvec.ExtractFeatureUDF';

Expand Down
3 changes: 1 addition & 2 deletions src/main/hivemall/HivemallConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

public final class HivemallConstants {

public static final String BIAS_CLAUSE = "+bias";
public static final int BIAS_CLAUSE_INT = -1;
public static final String BIAS_CLAUSE = "0";

// org.apache.hadoop.hive.serde.Constants (hive 0.9)
// org.apache.hadoop.hive.serde.serdeConstants (hive 0.10 or later)
Expand Down
5 changes: 2 additions & 3 deletions src/main/hivemall/ftvec/AddBiasUDF.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;

@Description(name = "addBias", value = "_FUNC_(feature_vector in array<string>) - Returns features with a bias in array<string>")
@Description(name = "add_bias", value = "_FUNC_(feature_vector in array<string>) - Returns features with a bias in array<string>")
@UDFType(deterministic = true, stateful = false)
public final class AddBiasUDF extends UDF {

public List<Text> evaluate(List<String> ftvec) {
String biasClause = Integer.toString(HivemallConstants.BIAS_CLAUSE_INT);
return evaluate(ftvec, biasClause);
return evaluate(ftvec, HivemallConstants.BIAS_CLAUSE);
}

public List<Text> evaluate(List<String> ftvec, String biasClause) {
Expand Down

0 comments on commit dc46f73

Please sign in to comment.