fixed gradient ascent
This commit is contained in:
parent
45b1f51685
commit
a938b70d57
4 changed files with 31 additions and 3 deletions
|
|
@ -105,6 +105,16 @@ public class MatrixTest {
|
|||
|
||||
@Test
|
||||
public void vectorMultiply(){
|
||||
assertArrayEquals(
|
||||
new double[]{0.1, 0.4, 0.9, 1.6},
|
||||
Matrix.Elemental.multiply(
|
||||
new double[]{1, 2, 3, 4},
|
||||
new double[]{0.1, 0.2, 0.3, 0.4}),
|
||||
0.001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vectorMatrixMultiply(){
|
||||
assertArrayEquals(
|
||||
new double[]{1.4, 1.9, 2.4, 2.9},
|
||||
Matrix.multiply(
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class LinearRegressionTest {
|
|||
|
||||
@Test
|
||||
public void gradientAscent() {
|
||||
double[] theta = LinearRegression.gradientDescent( // one iteration
|
||||
double[] theta = LinearRegression.gradientDescentIteration( // one iteration
|
||||
/* x */ new double[][]{{1, 5},{1, 2},{1, 4},{1, 5}},
|
||||
/* y */ new double[]{1, 6, 4, 2},
|
||||
/* theta */ new double[]{0, 0},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue