-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-client.php
40 lines (32 loc) · 917 Bytes
/
example-client.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
<?php
function skit($samples,$targets,$predict,$debug=false){
if($debug){
echo "<pre>";
var_dump("samples",$samples,"targets",$targets,"predict",$predict);
echo "</pre>";
}
$json_encode=json_encode($samples);
$json_encode=urlencode($json_encode);
$targets=json_encode($targets);
$targets=urlencode($targets);
$predict=json_encode($predict);
$predict=urlencode($predict);
$url="http://fillwithyourip:8080/?x={$json_encode}&y={$targets}&predict={$predict}";
$terserah=file_get_contents($url);
$isi=explode("[[",$terserah)[1];
$isi=explode("]]",$isi)[0];
$isi=(float)$isi;
if($debug){
echo "<pre>";
var_dump($isi);
echo "</pre>";
}
return $isi;
}
//call the function here
$samples = [[13.4,13.4,36.2,30.1,60.3,60.3]];
$targets = [[10.7]];
$predict = [[13.6,13.6,37.6,30.5,61.9,61.9]];
$prediction=skit($samples,$targets,$predict);
echo "Your prediction is: " . $prediction;
?>