forked from jorgecasas/php-ml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
72 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
declare (strict_types = 1); | ||
|
||
namespace Phpml\Math; | ||
|
||
interface Kernel | ||
{ | ||
|
||
/** | ||
* @param float $a | ||
* @param float $b | ||
* | ||
* @return float | ||
*/ | ||
public function compute($a, $b); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare (strict_types = 1); | ||
|
||
namespace Phpml\Regression; | ||
|
||
class LeastSquares implements Regression | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $features; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $targets; | ||
|
||
/** | ||
* @param array $features | ||
* @param array $targets | ||
*/ | ||
public function train(array $features, array $targets) | ||
{ | ||
$this->features = $features; | ||
$this->targets = $targets; | ||
} | ||
|
||
/** | ||
* @param array $features | ||
* | ||
* @return mixed | ||
*/ | ||
public function predict(array $features) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare (strict_types = 1); | ||
|
||
namespace Phpml\Regression; | ||
|
||
interface Regression | ||
{ | ||
/** | ||
* @param array $features | ||
* @param array $targets | ||
*/ | ||
public function train(array $features, array $targets); | ||
|
||
/** | ||
* @param array $features | ||
* | ||
* @return mixed | ||
*/ | ||
public function predict(array $features); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
declare (strict_types = 1); | ||
|
||
namespace tests\Phpml\Math; | ||
|
||
use Phpml\Math\Product; | ||
|
||
class ProductTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testScalarProduct() | ||
{ | ||
$this->assertEquals(10, Product::scalar([2, 3], [-1, 4])); | ||
$this->assertEquals(-0.1, Product::scalar([1, 4, 1], [-2, 0.5, -0.1])); | ||
$this->assertEquals(8, Product::scalar([2], [4])); | ||
} | ||
|
||
} | ||
} |