Author: tommaso
Date: Mon Oct 8 20:27:03 2012
New Revision: 1395756
URL: http://svn.apache.org/viewvc?rev=1395756&view=rev
Log:
[HAMA-651] - fixed format
Modified:
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/CostFunction.java
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/LinearRegressionModel.java
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/RegressionModel.java
Modified:
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/CostFunction.java
URL:
http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/CostFunction.java?rev=1395756&r1=1395755&r2=1395756&view=diff
==============================================================================
--- hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/CostFunction.java
(original)
+++ hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/CostFunction.java
Mon Oct 8 20:27:03 2012
@@ -27,9 +27,10 @@ public interface CostFunction {
/**
* Calculates the cost function for a given item (input x, output y), a model
* defined by the hypothesis parametrized by the vector theta
- * @param x the input vector
- * @param y the learned output for x
- * @param theta the parameters vector theta
+ *
+ * @param x the input vector
+ * @param y the learned output for x
+ * @param theta the parameters vector theta
* @param hypothesis the hypothesis function to model the problem
* @return the calculated cost for input x and output y
*/
Modified:
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java
URL:
http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java?rev=1395756&r1=1395755&r2=1395756&view=diff
==============================================================================
---
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java
(original)
+++
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/GradientDescentBSP.java
Mon Oct 8 20:27:03 2012
@@ -55,7 +55,7 @@ public class GradientDescentBSP extends
threshold = peer.getConfiguration().getFloat(THRESHOLD, 0.01f);
alpha = peer.getConfiguration().getFloat(ALPHA, 0.3f);
try {
- regressionModel = ((Class<? extends
RegressionModel>)peer.getConfiguration().getClass(REGRESSION_MODEL_CLASS,
LinearRegressionModel.class)).newInstance();
+ regressionModel = ((Class<? extends RegressionModel>)
peer.getConfiguration().getClass(REGRESSION_MODEL_CLASS,
LinearRegressionModel.class)).newInstance();
} catch (Exception e) {
throw new IOException(e);
}
@@ -106,14 +106,12 @@ public class GradientDescentBSP extends
totalCost /= numRead;
- if (cost - totalCost < 0){
+ if (cost - totalCost < 0) {
throw new RuntimeException("gradient descent failed to converge with
alpha " + alpha);
- }
- else if (totalCost == 0 || cost - totalCost < threshold) {
+ } else if (totalCost == 0 || cost - totalCost < threshold) {
cost = totalCost;
break;
- }
- else {
+ } else {
cost = totalCost;
}
@@ -123,7 +121,6 @@ public class GradientDescentBSP extends
}
-
peer.sync();
peer.reopenInput();
Modified:
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/LinearRegressionModel.java
URL:
http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/LinearRegressionModel.java?rev=1395756&r1=1395755&r2=1395756&view=diff
==============================================================================
---
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/LinearRegressionModel.java
(original)
+++
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/LinearRegressionModel.java
Mon Oct 8 20:27:03 2012
@@ -30,7 +30,7 @@ public class LinearRegressionModel imple
costFunction = new CostFunction() {
@Override
public double calculateCostForItem(DoubleVector x, double y,
DoubleVector theta, HypothesisFunction hypothesis) {
- return y * Math.pow(applyHypothesis(theta, x) - y, 2) / 2;
+ return y * Math.pow(applyHypothesis(theta, x) - y, 2) / 2;
}
};
}
Modified:
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/RegressionModel.java
URL:
http://svn.apache.org/viewvc/hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/RegressionModel.java?rev=1395756&r1=1395755&r2=1395756&view=diff
==============================================================================
---
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/RegressionModel.java
(original)
+++
hama/trunk/ml/src/main/java/org/apache/hama/ml/regression/RegressionModel.java
Mon Oct 8 20:27:03 2012
@@ -27,8 +27,9 @@ public interface RegressionModel extends
/**
* Calculates the cost function for a given item (input x, output y) and
* the model's parameters defined by the vector theta
- * @param x the input vector
- * @param y the learned output for x
+ *
+ * @param x the input vector
+ * @param y the learned output for x
* @param theta the parameters vector theta
* @return the calculated cost for input x and output y
*/