-
Notifications
You must be signed in to change notification settings - Fork 1
/
Plugin.php
85 lines (61 loc) · 2.16 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php namespace Frukt\Kadr;
use System\Classes\PluginBase;
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Classifiers\KNearestNeighbors;
use Rubix\ML\Datasets\Unlabeled;
use Rubix\ML\CrossValidation\Metrics\MeanAbsoluteError;
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
class Plugin extends PluginBase
{
public function registerComponents()
{
}
public function registerSettings()
{
return [
'settings' => [
'label' => 'НАСТРОЙКИ KADR',
'description' => 'Управляйте настройками программы',
'category' => 'kadr',
'icon' => 'icon-cog',
'class' => 'Frukt\Kadr\Models\Settings',
'order' => 500,
'keywords' => 'settings kadr',
'permissions' => []
]
];
}
public function register()
{
$this->registerConsoleCommand('dataset:entergroups', 'Frukt\Kadr\Console\EnterToGroups');
$this->registerConsoleCommand('dataset:addconditions', 'Frukt\Kadr\Console\AddConditions');
$this->registerConsoleCommand('make:demoset', 'Frukt\Kadr\Console\MakeDemo');
$this->registerConsoleCommand('ml:go', 'Frukt\Kadr\Console\Go');
app(EloquentFactory::class)->load(plugins_path('frukt/kadr/factories'));
}
public function boot()
{
/* $samples = [
[3, 4, 50.5],
[1, 5, 24.7],
[4, 4, 62.0],
[3, 2, 31.1],
];
$labels = ['married', 'divorced', 'married', 'divorced'];
$dataset = new Labeled($samples, $labels);
$estimator = new KNearestNeighbors(3);
$estimator->train($dataset);
trace_log($estimator->trained());
$samples = [
[4, 3, 44.2],
[2, 2, 100.7],
[2, 4, 19.5],
[3, 3, 55.0],
];
$dataset = new Unlabeled($samples);
$predictions = $estimator->predict($dataset);
$probabilities = $estimator->proba($dataset);
print_r($probabilities);
print_r($predictions); */
}
}