Code Duplication    Length = 12-14 lines in 2 locations

src/Phpml/DimensionReduction/KernelPCA.php 1 location

@@ 232-245 (lines=14) @@
229
     *
230
     * @return array
231
     */
232
    public function transform(array $sample)
233
    {
234
        if (!$this->fit) {
235
            throw new \Exception("KernelPCA has not been fitted with respect to original dataset, please run KernelPCA::fit() first");
236
        }
237
238
        if (is_array($sample[0])) {
239
            throw new \Exception("KernelPCA::transform() accepts only one-dimensional arrays");
240
        }
241
242
        $pairs = $this->getDistancePairs($sample);
243
244
        return $this->projectSample($pairs);
245
    }
246
}
247

src/Phpml/DimensionReduction/LDA.php 1 location

@@ 235-246 (lines=12) @@
232
     *
233
     * @return array
234
     */
235
    public function transform(array $sample)
236
    {
237
        if (!$this->fit) {
238
            throw new \Exception("LDA has not been fitted with respect to original dataset, please run LDA::fit() first");
239
        }
240
241
        if (! is_array($sample[0])) {
242
            $sample = [$sample];
243
        }
244
245
        return $this->reduce($sample);
246
    }
247
}
248