mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
test some broken tests
This commit is contained in:
parent
663cf6b11e
commit
5e6ccb0b36
|
|
@ -91,6 +91,7 @@ final class Apriori
|
|||
|
||||
$totalSet = \array_unique($totalSet);
|
||||
\sort($totalSet);
|
||||
\sort($subset);
|
||||
|
||||
// Combinations of items
|
||||
$combinations = self::generateSubsets($totalSet);
|
||||
|
|
@ -99,6 +100,10 @@ final class Apriori
|
|||
$table = [];
|
||||
foreach ($combinations as &$c) {
|
||||
\sort($c);
|
||||
if (!empty($subset) && $c !== $subset) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$table[\implode(':', $c)] = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ final class MemoryCF
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function euclideanDistance(array $ranking, array $rankings) : array
|
||||
private function euclideanDistance(array $ranking, array $rankings) : array
|
||||
{
|
||||
$distances = [];
|
||||
foreach ($rankings as $idx => $r) {
|
||||
|
|
@ -107,7 +107,7 @@ final class MemoryCF
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function cosineDistance(array $ranking, array $rankings) : array
|
||||
private function cosineDistance(array $ranking, array $rankings) : array
|
||||
{
|
||||
$distances = [];
|
||||
foreach ($rankings as $idx => $r) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,23 @@ final class AprioriTest extends \PHPUnit\Framework\TestCase
|
|||
public function testApriori() : void
|
||||
{
|
||||
self::assertEquals(
|
||||
[],
|
||||
[
|
||||
'theta' => 2,
|
||||
'epsilon' => 2,
|
||||
'epsilon:theta' => 0,
|
||||
'beta' => 4,
|
||||
'beta:theta' => 2,
|
||||
'beta:epsilon' => 2,
|
||||
'beta:epsilon:theta' => 0,
|
||||
'alpha' => 4,
|
||||
'alpha:theta' => 2,
|
||||
'alpha:epsilon' => 2,
|
||||
'alpha:epsilon:theta' => 0,
|
||||
'alpha:beta' => 4,
|
||||
'alpha:beta:theta' => 2,
|
||||
'alpha:beta:epsilon' => 2,
|
||||
'alpha:beta:epsilon:theta' => 0,
|
||||
],
|
||||
Apriori::apriori([
|
||||
['alpha', 'beta', 'epsilon'],
|
||||
['alpha', 'beta', 'theta'],
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@ final class DependencyResolverTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
self::assertEquals(
|
||||
null,
|
||||
DependencyResolver::resolve([0 => [1, 2], 1 => [0, 2]])
|
||||
DependencyResolver::resolve([0 => [1, 2], 1 => [0, 2], 2 => []])
|
||||
);
|
||||
|
||||
self::assertEquals(
|
||||
[0, 1, 2, 3],
|
||||
DependencyResolver::resolve([0 => [1, 2], 1 => [2, 3]])
|
||||
DependencyResolver::resolve([0 => [1, 2], 1 => [2, 3], 2 => [], 3 => []])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ final class MarkovChainTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testStepProbability() : void
|
||||
{
|
||||
$markov = new MarkovChain();
|
||||
$markov = new MarkovChain(2);
|
||||
$markov->setTraining(
|
||||
[
|
||||
'A A' => ['A' => 0.18, 'D' => 0.6, 'G' => 0.22],
|
||||
|
|
@ -85,7 +85,7 @@ final class MarkovChainTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testPathProbability() : void
|
||||
{
|
||||
$markov = new MarkovChain();
|
||||
$markov = new MarkovChain(2);
|
||||
$markov->setTraining(
|
||||
[
|
||||
'A A' => ['A' => 0.18, 'D' => 0.6, 'G' => 0.22],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Business\Recommendation;
|
||||
|
||||
use phpOMS\Business\Recommendation\BayesianPersonalizedRanking;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Business\Recommendation\BayesianPersonalizedRankingTest: Article affinity/correlation
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class BayesianPersonalizedRankingTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
}
|
||||
40
tests/Business/Recommendation/MemoryCFTest.php
Normal file
40
tests/Business/Recommendation/MemoryCFTest.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Business\Recommendation;
|
||||
|
||||
use phpOMS\Business\Recommendation\MemoryCF;
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Business\Recommendation\MemoryCFTest: Article affinity/correlation
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class MemoryCFTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testBestMatch() : void
|
||||
{
|
||||
$memory = new MemoryCF([
|
||||
'A' => [1.0, 2.0],
|
||||
'B' => [2.0, 4.0],
|
||||
'C' => [2.5, 4.0],
|
||||
'D' => [4.5, 5.0],
|
||||
]);
|
||||
|
||||
self::assertEquals(
|
||||
['B', 'C'],
|
||||
$memory->bestMatch([2.2, 4.1], 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -247,7 +247,10 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
public function testGetYield() : void
|
||||
{
|
||||
BaseModelMapper::create()->execute($this->model);
|
||||
self::assertCount(1, BaseModelMapper::yield()->execute());
|
||||
|
||||
foreach (BaseModelMapper::yield()->execute() as $model) {
|
||||
self::assertGreaterThan(0, $model->id);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetFor() : void
|
||||
|
|
@ -281,6 +284,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
$model1 = new BaseModel();
|
||||
$model1->datetime = new \DateTime('now');
|
||||
$id1 = BaseModelMapper::create()->execute($model1);
|
||||
|
||||
\sleep(1);
|
||||
$model2 = new BaseModel();
|
||||
$model2->datetime = new \DateTime('now');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user