From 25aa3abbfc79a1eddec627b31642e0b0cc73b853 Mon Sep 17 00:00:00 2001 From: guoguibing Date: Mon, 30 Jun 2014 14:18:34 +0800 Subject: [PATCH] Set Default Algorithm Name --- librec/src/main/java/librec/ext/AR.java | 3 --- librec/src/main/java/librec/ext/NMF.java | 2 -- librec/src/main/java/librec/ext/PD.java | 2 -- librec/src/main/java/librec/ext/PRankD.java | 1 - librec/src/main/java/librec/ext/SlopeOne.java | 2 -- librec/src/main/java/librec/intf/Recommender.java | 3 +++ librec/src/main/java/librec/ranking/BPRMF.java | 1 - librec/src/main/java/librec/ranking/CLiMF.java | 2 -- librec/src/main/java/librec/ranking/RankALS.java | 1 - librec/src/main/java/librec/ranking/RankSGD.java | 1 - librec/src/main/java/librec/ranking/WRMF.java | 1 - librec/src/main/java/librec/rating/BiasedMF.java | 2 -- librec/src/main/java/librec/rating/ItemKNN.java | 1 - librec/src/main/java/librec/rating/PMF.java | 2 -- librec/src/main/java/librec/rating/RSTE.java | 2 -- librec/src/main/java/librec/rating/RegSVD.java | 2 -- librec/src/main/java/librec/rating/SoRec.java | 1 - librec/src/main/java/librec/rating/SoReg.java | 1 - librec/src/main/java/librec/rating/SocialMF.java | 1 - librec/src/main/java/librec/rating/UserKNN.java | 1 - 20 files changed, 3 insertions(+), 29 deletions(-) diff --git a/librec/src/main/java/librec/ext/AR.java b/librec/src/main/java/librec/ext/AR.java index 17d319e29..ce585cefa 100644 --- a/librec/src/main/java/librec/ext/AR.java +++ b/librec/src/main/java/librec/ext/AR.java @@ -52,9 +52,6 @@ public class AR extends Recommender { public AR(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - // Association rules recommender - algoName = "AR"; - // cannot predict ratings, but only order preferences isRankingPred = true; } diff --git a/librec/src/main/java/librec/ext/NMF.java b/librec/src/main/java/librec/ext/NMF.java index 5be8aa703..3350691b7 100644 --- a/librec/src/main/java/librec/ext/NMF.java +++ b/librec/src/main/java/librec/ext/NMF.java @@ -42,8 +42,6 @@ public class NMF extends IterativeRecommender { public NMF(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "NMF"; - // no need to update learning rate lRate = -1; } diff --git a/librec/src/main/java/librec/ext/PD.java b/librec/src/main/java/librec/ext/PD.java index 8df81cd90..c6fa906a8 100644 --- a/librec/src/main/java/librec/ext/PD.java +++ b/librec/src/main/java/librec/ext/PD.java @@ -53,8 +53,6 @@ public class PD extends Recommender { public PD(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - - algoName = "PD"; } @Override diff --git a/librec/src/main/java/librec/ext/PRankD.java b/librec/src/main/java/librec/ext/PRankD.java index 077e51f0d..c2879c43e 100644 --- a/librec/src/main/java/librec/ext/PRankD.java +++ b/librec/src/main/java/librec/ext/PRankD.java @@ -61,7 +61,6 @@ public class PRankD extends RankSGD { public PRankD(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "PRankD"; isRankingPred = true; } diff --git a/librec/src/main/java/librec/ext/SlopeOne.java b/librec/src/main/java/librec/ext/SlopeOne.java index 4e265e58b..f32ebc247 100644 --- a/librec/src/main/java/librec/ext/SlopeOne.java +++ b/librec/src/main/java/librec/ext/SlopeOne.java @@ -38,8 +38,6 @@ public class SlopeOne extends Recommender { public SlopeOne(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - - algoName = "SlopeOne"; } @Override diff --git a/librec/src/main/java/librec/intf/Recommender.java b/librec/src/main/java/librec/intf/Recommender.java index 0e338006d..7e0e8d83f 100644 --- a/librec/src/main/java/librec/intf/Recommender.java +++ b/librec/src/main/java/librec/intf/Recommender.java @@ -133,6 +133,9 @@ public Recommender(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) numRates = trainMatrix.size(); globalMean = trainMatrix.sum() / numRates; + // class name as the default algorithm name + algoName = this.getClass().getSimpleName(); + // fold info foldInfo = fold > 0 ? " fold [" + fold + "]" : ""; diff --git a/librec/src/main/java/librec/ranking/BPRMF.java b/librec/src/main/java/librec/ranking/BPRMF.java index 6f1a9fe82..c3a0da5a1 100644 --- a/librec/src/main/java/librec/ranking/BPRMF.java +++ b/librec/src/main/java/librec/ranking/BPRMF.java @@ -49,7 +49,6 @@ public class BPRMF extends IterativeRecommender { public BPRMF(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "BPRMF"; isRankingPred = true; initByNorm = false; diff --git a/librec/src/main/java/librec/ranking/CLiMF.java b/librec/src/main/java/librec/ranking/CLiMF.java index 8e18b2faf..204725ae4 100644 --- a/librec/src/main/java/librec/ranking/CLiMF.java +++ b/librec/src/main/java/librec/ranking/CLiMF.java @@ -38,8 +38,6 @@ public class CLiMF extends IterativeRecommender { public CLiMF(SparseMatrix rm, SparseMatrix tm, int fold) { super(rm, tm, fold); - - algoName = "CLiMF"; } @Override diff --git a/librec/src/main/java/librec/ranking/RankALS.java b/librec/src/main/java/librec/ranking/RankALS.java index f053edbe5..aa182d64d 100644 --- a/librec/src/main/java/librec/ranking/RankALS.java +++ b/librec/src/main/java/librec/ranking/RankALS.java @@ -52,7 +52,6 @@ public class RankALS extends IterativeRecommender { public RankALS(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "RankALS"; isRankingPred = true; } diff --git a/librec/src/main/java/librec/ranking/RankSGD.java b/librec/src/main/java/librec/ranking/RankSGD.java index a7131db84..590e0e129 100644 --- a/librec/src/main/java/librec/ranking/RankSGD.java +++ b/librec/src/main/java/librec/ranking/RankSGD.java @@ -44,7 +44,6 @@ public class RankSGD extends IterativeRecommender { public RankSGD(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "RankSGD"; isRankingPred = true; } diff --git a/librec/src/main/java/librec/ranking/WRMF.java b/librec/src/main/java/librec/ranking/WRMF.java index 65e22ecfc..25b2f517d 100644 --- a/librec/src/main/java/librec/ranking/WRMF.java +++ b/librec/src/main/java/librec/ranking/WRMF.java @@ -50,7 +50,6 @@ public class WRMF extends IterativeRecommender { public WRMF(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "WRMF"; isRankingPred = true; // item recommendation alpha = cf.getDouble("WRMF.alpha"); diff --git a/librec/src/main/java/librec/rating/BiasedMF.java b/librec/src/main/java/librec/rating/BiasedMF.java index 76a4762db..9c801f1bd 100644 --- a/librec/src/main/java/librec/rating/BiasedMF.java +++ b/librec/src/main/java/librec/rating/BiasedMF.java @@ -37,8 +37,6 @@ public class BiasedMF extends IterativeRecommender { public BiasedMF(SparseMatrix rm, SparseMatrix tm, int fold) { super(rm, tm, fold); - - algoName = "BiasedMF"; } protected void initModel() { diff --git a/librec/src/main/java/librec/rating/ItemKNN.java b/librec/src/main/java/librec/rating/ItemKNN.java index e8b1f4f1e..adf8bd625 100644 --- a/librec/src/main/java/librec/rating/ItemKNN.java +++ b/librec/src/main/java/librec/rating/ItemKNN.java @@ -65,7 +65,6 @@ public class ItemKNN extends Recommender { public ItemKNN(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "ItemKNN"; knn = cf.getInt("num.neighbors"); } diff --git a/librec/src/main/java/librec/rating/PMF.java b/librec/src/main/java/librec/rating/PMF.java index f3dca943c..f92aacd94 100644 --- a/librec/src/main/java/librec/rating/PMF.java +++ b/librec/src/main/java/librec/rating/PMF.java @@ -37,8 +37,6 @@ public class PMF extends IterativeRecommender { public PMF(SparseMatrix rm, SparseMatrix tm, int fold) { super(rm, tm, fold); - algoName = "PMF"; - // disable bold driver isBoldDriver = false; diff --git a/librec/src/main/java/librec/rating/RSTE.java b/librec/src/main/java/librec/rating/RSTE.java index 7901a9e50..c2ac9ed99 100644 --- a/librec/src/main/java/librec/rating/RSTE.java +++ b/librec/src/main/java/librec/rating/RSTE.java @@ -44,8 +44,6 @@ public class RSTE extends SocialRecommender { public RSTE(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "RSTE"; - initByNorm = false; alpha = cf.getDouble("RSTE.alpha"); } diff --git a/librec/src/main/java/librec/rating/RegSVD.java b/librec/src/main/java/librec/rating/RegSVD.java index f1987cfc1..30b2086a2 100644 --- a/librec/src/main/java/librec/rating/RegSVD.java +++ b/librec/src/main/java/librec/rating/RegSVD.java @@ -34,8 +34,6 @@ public class RegSVD extends IterativeRecommender { public RegSVD(SparseMatrix rm, SparseMatrix tm, int fold) { super(rm, tm, fold); - - algoName = "RegSVD"; } @Override diff --git a/librec/src/main/java/librec/rating/SoRec.java b/librec/src/main/java/librec/rating/SoRec.java index 5b49938f5..2c38ff4eb 100644 --- a/librec/src/main/java/librec/rating/SoRec.java +++ b/librec/src/main/java/librec/rating/SoRec.java @@ -44,7 +44,6 @@ public class SoRec extends SocialRecommender { public SoRec(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "SoRec"; initByNorm = false; } diff --git a/librec/src/main/java/librec/rating/SoReg.java b/librec/src/main/java/librec/rating/SoReg.java index 51b983a2b..425d7be82 100644 --- a/librec/src/main/java/librec/rating/SoReg.java +++ b/librec/src/main/java/librec/rating/SoReg.java @@ -49,7 +49,6 @@ public class SoReg extends SocialRecommender { public SoReg(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "SoReg"; initByNorm = false; } diff --git a/librec/src/main/java/librec/rating/SocialMF.java b/librec/src/main/java/librec/rating/SocialMF.java index e67412bfb..7998daeeb 100644 --- a/librec/src/main/java/librec/rating/SocialMF.java +++ b/librec/src/main/java/librec/rating/SocialMF.java @@ -36,7 +36,6 @@ public class SocialMF extends SocialRecommender { public SocialMF(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "SocialMF"; initByNorm = false; } diff --git a/librec/src/main/java/librec/rating/UserKNN.java b/librec/src/main/java/librec/rating/UserKNN.java index ef8997e81..be3769992 100644 --- a/librec/src/main/java/librec/rating/UserKNN.java +++ b/librec/src/main/java/librec/rating/UserKNN.java @@ -64,7 +64,6 @@ public class UserKNN extends Recommender { public UserKNN(SparseMatrix trainMatrix, SparseMatrix testMatrix, int fold) { super(trainMatrix, testMatrix, fold); - algoName = "UserKNN"; knn = cf.getInt("num.neighbors"); }