| Server IP : 45.152.65.97 / Your IP : 216.73.217.140 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1p mod_fcgid/2.3.9a System : Windows NT C20260123164925 10.0 build 20348 (Windows Server 2016) AMD64 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : passthru,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,putenv,exec MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/wwwroot/shujupai.cn/wp-content/plugins/jingcaizuqiu/includes/ |
Upload File : |
<?php
if (!defined('ABSPATH')) {
exit;
}
require_once JCZP_PLUGIN_DIR . 'includes/api.php';
class JCZP_Predictor {
private $api;
public function __construct() {
$this->api = new JCZP_API();
}
public function get_today_matches() {
$matches = $this->api->get_today_matches();
$this->predict_matches($matches);
return $matches;
}
private function predict_matches(&$matches) {
foreach ($matches as &$match) {
$probabilities = $this->calculate_probabilities($match);
$result = $this->make_prediction($probabilities);
$match['prediction'] = $result;
$match['confidence'] = $this->calculate_confidence($probabilities, $result);
}
}
private function calculate_probabilities($match) {
$home_advantage = 15;
$home_strength = $match['home_rating'] + $home_advantage;
$away_strength = $match['away_rating'];
$home_win_prob = $home_strength / ($home_strength + $away_strength);
$away_win_prob = $away_strength / ($home_strength + $away_strength);
$draw_prob = 0.25 + (0.1 * abs($home_strength - $away_strength) / 30);
$total = $home_win_prob + $away_win_prob + $draw_prob;
$home_win_prob /= $total;
$away_win_prob /= $total;
$draw_prob /= $total;
return array(
'home_win' => $home_win_prob,
'draw' => $draw_prob,
'away_win' => $away_win_prob
);
}
private function make_prediction($probabilities) {
$max_prob = max($probabilities);
if ($max_prob === $probabilities['home_win']) {
return '胜';
} elseif ($max_prob === $probabilities['away_win']) {
return '负';
} else {
return '平';
}
}
private function calculate_confidence($probabilities, $result) {
switch ($result) {
case '胜':
$confidence = min(95, ($probabilities['home_win'] - 0.33) * 200);
break;
case '负':
$confidence = min(95, ($probabilities['away_win'] - 0.33) * 200);
break;
case '平':
$confidence = min(90, ($probabilities['draw'] - 0.25) * 200);
break;
default:
$confidence = 50;
}
return round($confidence, 1);
}
}