-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
5 changed files
with
99 additions
and
135 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
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,73 @@ | ||
<?php | ||
|
||
namespace Rubix\ML\Traits; | ||
|
||
use Rubix\ML\Datasets\Dataset; | ||
use Rubix\ML\Estimator; | ||
use Rubix\ML\EstimatorType; | ||
use Rubix\ML\Exceptions\RuntimeException; | ||
use Rubix\ML\Learner; | ||
|
||
/** | ||
* Wrapper Aware | ||
* | ||
* This trait fulfills the requirements of the Wrapper interface and is suitable for most implementations. | ||
* | ||
* @category Machine Learning | ||
* @package Rubix/ML | ||
*/ | ||
trait WrapperAware | ||
{ | ||
/** | ||
* The base estimator. | ||
* | ||
* @var Learner | ||
*/ | ||
protected Estimator $base; | ||
|
||
/** | ||
* Return the base estimator instance. | ||
* | ||
* @return Estimator | ||
*/ | ||
public function base(): Estimator | ||
{ | ||
return $this->base; | ||
} | ||
|
||
/** | ||
* Return the estimator type. | ||
* | ||
* @internal | ||
* | ||
* @return EstimatorType | ||
*/ | ||
public function type() : EstimatorType | ||
{ | ||
return $this->base->type(); | ||
} | ||
|
||
/** | ||
* Return the data types that the estimator is compatible with. | ||
* | ||
* @internal | ||
* | ||
* @return list<\Rubix\ML\DataType> | ||
*/ | ||
public function compatibility() : array | ||
{ | ||
return $this->base->compatibility(); | ||
} | ||
|
||
/** | ||
* Make a prediction on a given sample dataset. | ||
* | ||
* @param Dataset $dataset | ||
* @throws RuntimeException | ||
* @return mixed[] | ||
*/ | ||
public function predict(Dataset $dataset) : array | ||
{ | ||
return $this->base->predict($dataset); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Rubix\ML; | ||
|
||
/** | ||
* Wrapper | ||
* | ||
* @category Machine Learning | ||
* @package Rubix/ML | ||
* @author Andrew DalPino | ||
*/ | ||
interface Wrapper extends Estimator | ||
{ | ||
/** | ||
* Return the base estimator instance. | ||
* | ||
* @return Estimator | ||
*/ | ||
public function base(): Estimator; | ||
} |