Generates all proper subsets for given set $sample without the empty set.

@param mixed[] $sample

@return mixed[][]
182451
private function antecedents(array $sample): array
    {
        $cardinality = count($sample);
        $antecedents = $this->powerSet($sample);

        return array_filter($antecedents, function ($antecedent) use ($cardinality) {
            return (count($antecedent) != $cardinality) && ($antecedent != []);
        });
    }
73140
protected function output(array $sample)
    {
        $sum = 0;
        foreach ($this->weights as $index => $w) {
            if ($index == 0) {
                $sum += $w;
            } else {
                $sum += $w * $sample[$index - 1];
            }
        }

        return $sum;
    }
1136139
protected function assign(array $sample) : int
    {
        $bestDistance = INF;
        $bestCluster = -1;

        foreach ($this->centroids as $cluster => $centroid) {
            $distance = $this->kernel->compute($sample, $centroid);

            if ($distance < $bestDistance) {
                $bestDistance = $distance;
                $bestCluster = $cluster;
            }
        }

        return (int) $bestCluster;
    }
264368
public function transform(array &$samples) : void
    {
        foreach ($samples as &$sample) {
            $vectors = [];

            foreach ($sample as $column => &$value) {
                if (is_resource($value) ? get_resource_type($value) === 'gd' : false) {
                    $image = $this->intervention->make($value);

                    $resize = $image->getWidth() !== $this->width
                        and $image->getHeight() !== $this->height;

                    if ($resize) {
                        $image = $image->fit($this->width, $this->height);
                    }

                    $value = $image->getCore();
                }
            }
        }
    }
190543
protected function jointLogLikelihood(array $sample) : array
    {
        $likelihoods = [];

        foreach ($this->probs as $class => $probs) {
            $likelihood = $this->priors[$class] ?? LOG_EPSILON;

            foreach ($sample as $column => $feature) {
                $likelihood += $probs[$column][$feature] ?? LOG_EPSILON;
            }

            $likelihoods[$class] = $likelihood;
        }

        return $likelihoods;
    }
399823
public function transform(array &$samples) : void
    {
        if ($this->intervals === null) {
            throw new RuntimeException('Transformer has not been fitted.');
        }
        
        $last = end($this->categories);

        foreach ($samples as &$sample) {
            foreach ($this->intervals as $column => $interval) {
                $value = &$sample[$column];

                foreach ($interval as $i => $edge) {
                    if ($value < $edge) {
                        $value = $this->categories[$i];

                        continue 2;
                    }
                }

                $value = $last;
            }
        }
    }
261288
public function transform(array &$samples) : void
    {
        foreach ($samples as &$sample) {
            foreach ($sample as &$feature) {
                if (is_string($feature)) {
                    $feature = strip_tags($feature);
                }
            }
        }
    }
1079035
public function transform(array &$samples) : void
    {
        if ($this->categories === null) {
            throw new RuntimeException('Transformer has not been fitted.');
        }

        $templates = [];

        foreach ($this->categories as $column => $categories) {
            $templates[$column] = array_fill(0, count($categories), 0);
        }

        foreach ($samples as &$sample) {
            $vector = [];

            foreach ($this->categories as $column => $categories) {
                $category = $sample[$column];
                $features = $templates[$column];

                if (isset($categories[$category])) {
                    $features[$categories[$category]] = 1;
                }

                $vector = array_merge($vector, $features);

                unset($sample[$column]);
            }

            $sample = array_merge($sample, $vector);
        }
    }
834811
protected function membership(array $sample) : array
    {
        $membership = $distances = [];

        foreach ($this->centroids as $centroid) {
            $distances[] = $this->kernel->compute($sample, $centroid);
        }

        $total = array_sum($distances) ?: EPSILON;

        foreach ($distances as $distance) {
            $membership[] = $distance / $total;
        }

        return $membership;
    }
1236243
function sample(collection) {
        var array = isArrayLike(collection) ? collection : values(collection), length = array.length;
        return length > 0 ? array[baseRandom(0, length - 1)] : undefined;
      }
314146
public function transform(array &$samples) : void
    {
        foreach ($samples as &$sample) {
            $vectors = [];

            foreach ($sample as $column => $image) {
                if (is_resource($image) ? get_resource_type($image) === 'gd' : false) {
                    $width = imagesx($image);
                    $height = imagesy($image);

                    $vector = [];

                    for ($x = 0; $x < $width; $x++) {
                        for ($y = 0; $y < $height; $y++) {
                            $pixel = imagecolorat($image, $x, $y);

                            $vector[] = $pixel & 0xFF;
            
                            for ($i = 8; $i <= $this->mu; $i *= 2) {
                                $vector[] = ($pixel >> $i) & 0xFF;
                            }
                        }
                    }

                    unset($sample[$column]);

                    imagedestroy($image);

                    $vectors[] = $vector;
                }
            }

            $sample = array_merge($sample, ...$vectors);
        }
    }
590575
private function candidates(array $samples) : array
    {
        $candidates = [];

        foreach ($samples as $p) {
            foreach ($samples as $q) {
                if (count(array_merge(array_diff($p, $q), array_diff($q, $p))) != 2) {
                    continue;
                }

                $candidate = array_unique(array_merge($p, $q));

                if ($this->contains($candidates, $candidate)) {
                    continue;
                }

                foreach ((array) $this->samples as $sample) {
                    if ($this->subset($sample, $candidate)) {
                        $candidates[] = $candidate;
                        continue 2;
                    }
                }
            }
        }

        return $candidates;
    }
257048
public function transform(array &$samples) : void
    {
        if ($this->selected === null) {
            throw new RuntimeException('Transformer has not been fitted.');
        }

        foreach ($samples as &$sample) {
            $sample = array_intersect_key($sample, $this->selected);
        }
    }
643048
protected function pairwiseDistances(Matrix $samples) : Matrix
    {
        $distances = [];

        foreach ($samples as $a) {
            $temp = [];

            foreach ($samples as $b) {
                $temp[] = $this->kernel->compute($a, $b);
            }

            $distances[] = $temp;
        }

        return Matrix::quick($distances);
    }
903652
public function transform(array &$samples) : void
    {
        foreach ($samples as &$sample) {
            foreach ($sample as &$feature) {
                if (is_string($feature)) {
                    $feature = preg_replace($this->stopWords, '', $feature);
                }
            }
        }
    }
1137376
public function transform(array &$samples) : void
    {
        foreach ($samples as &$sample) {
            foreach ($sample as &$feature) {
                if (is_string($feature) and is_numeric($feature)) {
                    $feature = (int) $feature == $feature
                        ? (int) $feature
                        : (float) $feature;
                }
            }
        }
    }
425873
protected function getSamples() {
        if (!$this->_samples) {
            $this->_samples = new SampleList(
                $this->version,
                $this->solution['assistantSid'],
                $this->solution['sid']
            );
        }

        return $this->_samples;
    }