rozbudowa serwera, i pliku modele.py
This commit is contained in:
parent
ebedecbd4d
commit
4cbed48308
@ -17,28 +17,23 @@ const Hero = () => {
|
|||||||
//przez listener nanoszący zawodników na boisko. 1 - strzelec , 2 - bramkarz , 3 - obronca, 4 - napasnik. zmienna przez aktywacje przycskówk bb1, bb2, bb3 i bb4
|
//przez listener nanoszący zawodników na boisko. 1 - strzelec , 2 - bramkarz , 3 - obronca, 4 - napasnik. zmienna przez aktywacje przycskówk bb1, bb2, bb3 i bb4
|
||||||
|
|
||||||
let active_bbt = "bbt1";
|
let active_bbt = "bbt1";
|
||||||
let number_of_defenders = 0;
|
const [number_of_defenders, setNumberOfDevenders] = useState(0);
|
||||||
let number_of_strikers = 0;
|
const [number_of_strikers, setNumberOfStrikers] = useState(0)
|
||||||
let number_of_goalkeepers = 0;
|
const [number_of_goalkeepers, setNumberOfGoalkeppers] = useState(0);
|
||||||
var numer_od_shooters = 0;
|
const [number_of_shooters,setNumberOfShooters] = useState(0);
|
||||||
var eX = " ";
|
|
||||||
|
|
||||||
|
|
||||||
// zmienne globalne bedace danymi wejsciowymi do modelu
|
// zmienne globalne bedace danymi wejsciowymi do modelu
|
||||||
|
|
||||||
var shooterX = 12;
|
|
||||||
var shooterY = 12;
|
|
||||||
|
|
||||||
var shooter = [0,0]
|
var shooter = [0,0]
|
||||||
var goalkeeper = [0,0]
|
var goalkeeper = [0,0]
|
||||||
|
|
||||||
var stricers = new Array;
|
var stricers = new Array;
|
||||||
var defenders = new Array;
|
var defenders = new Array;
|
||||||
|
|
||||||
var bodyPart = "";
|
const [bodyPart,setBodyPart] = useState('prawa');
|
||||||
var technique = "";
|
const [technique,setTechnique] = useState('zwykly');
|
||||||
var actionType = "";
|
const [actionType,setActionType] = useState('pozycyjny');
|
||||||
var shooterPossition = "";
|
const [shooterPossition,setPossition] = useState('napastnik');
|
||||||
|
|
||||||
//zamiana procentowych pozycji na kartezyjskie
|
//zamiana procentowych pozycji na kartezyjskie
|
||||||
function konwerturX(x){
|
function konwerturX(x){
|
||||||
@ -59,16 +54,6 @@ const Hero = () => {
|
|||||||
document.getElementById(a).style.background = "#00CC66";
|
document.getElementById(a).style.background = "#00CC66";
|
||||||
active_bbt = a
|
active_bbt = a
|
||||||
}
|
}
|
||||||
function changeLeg(a){
|
|
||||||
|
|
||||||
document.getElementById("bbt5").style.background = "#99FFCC";
|
|
||||||
document.getElementById("bbt6").style.background = "#99FFCC";
|
|
||||||
document.getElementById("bbt7").style.background = "#99FFCC";
|
|
||||||
document.getElementById("bbt8").style.background = "#99FFCC";
|
|
||||||
document.getElementById(a).style.background = "#00CC66";
|
|
||||||
|
|
||||||
Leg_bbt = a
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset Boiska
|
// Reset Boiska
|
||||||
function resetField() {
|
function resetField() {
|
||||||
@ -84,10 +69,10 @@ const Hero = () => {
|
|||||||
players.forEach(function(element) {
|
players.forEach(function(element) {
|
||||||
list.removeChild(element);
|
list.removeChild(element);
|
||||||
})
|
})
|
||||||
number_of_defenders = 0
|
setNumberOfDevenders(0);
|
||||||
number_of_strikers = 0
|
setNumberOfStrikers(0)
|
||||||
number_of_goalkeepers = 0
|
setNumberOfGoalkeppers(0)
|
||||||
numer_od_shooters = 0
|
setNumberOfShooters(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,13 +86,13 @@ const Hero = () => {
|
|||||||
list.removeChild(player)
|
list.removeChild(player)
|
||||||
bojo.removeChild(ball)
|
bojo.removeChild(ball)
|
||||||
if(possition == 1){
|
if(possition == 1){
|
||||||
number_of_goalkeepers = 0
|
setNumberOfGoalkeppers(0)
|
||||||
}else if(possition == 2){
|
}else if(possition == 2){
|
||||||
number_of_defenders = number_of_defenders -1 ;
|
setNumberOfDevenders(number_of_defenders-1) ;
|
||||||
}else if (possition == 3){
|
}else if (possition == 3){
|
||||||
number_of_strikers = number_of_strikers -1 ;
|
setNumberOfStrikers(number_of_strikers-1) ;
|
||||||
}else if(possition == 0){
|
}else if(possition == 0){
|
||||||
numer_od_shooters = 0
|
setNumberOfShooters(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,21 +100,6 @@ const Hero = () => {
|
|||||||
function loadPlayers(){
|
function loadPlayers(){
|
||||||
var players = document.querySelectorAll('.player')
|
var players = document.querySelectorAll('.player')
|
||||||
|
|
||||||
|
|
||||||
//zgranie informacji z list
|
|
||||||
var bodyPartList = document.getElementById('bodyPartList')
|
|
||||||
var actionTypeList = document.getElementById('actionTypeList')
|
|
||||||
var possitionList = document.getElementById('possitionList')
|
|
||||||
var shootTypeList = document.getElementById('shootTypeList')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bodyPart = bodyPartList.getAttribute('value')
|
|
||||||
alert(bodyPart)
|
|
||||||
actionType = actionTypeList.value
|
|
||||||
shooterPossition = possitionList.value
|
|
||||||
technique = shootTypeList.value
|
|
||||||
|
|
||||||
// wyczyszczenie list zawierajacych lokalizacje zawodnikow
|
// wyczyszczenie list zawierajacych lokalizacje zawodnikow
|
||||||
defenders = []
|
defenders = []
|
||||||
stricers = []
|
stricers = []
|
||||||
@ -260,15 +230,15 @@ const Hero = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// // Wyłanie zapytania do serwera
|
// // Wyłanie zapytania do serwera
|
||||||
function sentQuestion() {
|
function sentQuestion() {
|
||||||
|
///Dziwny Blad
|
||||||
loadPlayers()
|
loadPlayers()
|
||||||
alert(bodyPart)
|
if (number_of_shooters == 1) {
|
||||||
if (numer_od_shooters > 0) {
|
|
||||||
// Użyj backticksów zamiast zwykłych cudzysłowów
|
// Użyj backticksów zamiast zwykłych cudzysłowów
|
||||||
|
fetch(`http://127.0.0.1:5000/get_model?shooter=${shooter}&goalkeeper=${goalkeeper}&defenders=${defenders}&strickers=${stricers}&bodyPart=${bodyPart}&technique=${technique}&actionType=${actionType}&shooterPossition=${shooterPossition}`).then(
|
||||||
fetch(`http://127.0.0.1:5000/get_model?shooter=${shooter}&goalkeeper=${goalkeeper}&defenders=${defenders}&strickers=${stricers}&bodyPart=4${bodyPart}&technique=${technique}&actionType=${actionType}&shooterPossition=${shooterPossition}`).then(
|
|
||||||
res => res.json()
|
res => res.json()
|
||||||
).then(
|
).then(
|
||||||
data => {
|
data => {
|
||||||
@ -307,11 +277,11 @@ const Hero = () => {
|
|||||||
|
|
||||||
//dodanie zawodnika do listy oraz punktu do mapy w zaleznosci od aktywnosci przycisku 1,2,3 lub 4
|
//dodanie zawodnika do listy oraz punktu do mapy w zaleznosci od aktywnosci przycisku 1,2,3 lub 4
|
||||||
if(active_bbt=="bbt1"){
|
if(active_bbt=="bbt1"){
|
||||||
if(numer_od_shooters < 1 ){
|
if(number_of_shooters < 1 ){
|
||||||
addPlayer(0,ball)
|
addPlayer(0,ball)
|
||||||
bojo.appendChild(ball)
|
bojo.appendChild(ball)
|
||||||
ball.style.background = "#fc0303"
|
ball.style.background = "#fc0303"
|
||||||
numer_od_shooters = numer_od_shooters + 1
|
setNumberOfShooters(number_of_shooters+1)
|
||||||
}else{alert("mozesz dodac tylko jednego strzelca")}
|
}else{alert("mozesz dodac tylko jednego strzelca")}
|
||||||
}else if(active_bbt == "bbt2"){
|
}else if(active_bbt == "bbt2"){
|
||||||
|
|
||||||
@ -319,19 +289,19 @@ const Hero = () => {
|
|||||||
addPlayer(1,ball)
|
addPlayer(1,ball)
|
||||||
bojo.appendChild(ball)
|
bojo.appendChild(ball)
|
||||||
ball.style.background = "#03e7fc"
|
ball.style.background = "#03e7fc"
|
||||||
number_of_goalkeepers = number_of_goalkeepers + 1
|
setNumberOfGoalkeppers(number_of_goalkeepers+1)
|
||||||
}else{alert("mozesz dodac tylko jednego bramkarza")}
|
}else{alert("mozesz dodac tylko jednego bramkarza")}
|
||||||
}else if(active_bbt == "bbt3"){
|
}else if(active_bbt == "bbt3"){
|
||||||
if(number_of_defenders <= 10){
|
if(number_of_defenders <= 10){
|
||||||
addPlayer(2,ball);
|
addPlayer(2,ball);
|
||||||
number_of_defenders = number_of_defenders +1;
|
setNumberOfDevenders(number_of_defenders+1)
|
||||||
bojo.appendChild(ball)
|
bojo.appendChild(ball)
|
||||||
ball.style.background = "#0324fc"
|
ball.style.background = "#0324fc"
|
||||||
}else{alert("maksymalna liczba obroncow")}
|
}else{alert("maksymalna liczba obroncow")}
|
||||||
}else if(active_bbt == "bbt4"){
|
}else if(active_bbt == "bbt4"){
|
||||||
if(number_of_strikers <= 10){
|
if(number_of_strikers <= 10){
|
||||||
addPlayer(3,ball);
|
addPlayer(3,ball);
|
||||||
number_of_strikers = number_of_strikers + 1;
|
setNumberOfStrikers(number_of_strikers+1);
|
||||||
bojo.appendChild(ball)
|
bojo.appendChild(ball)
|
||||||
ball.style.background = "#fc6703"
|
ball.style.background = "#fc6703"
|
||||||
}else{alert("maksymalna liczba napastnikow")}
|
}else{alert("maksymalna liczba napastnikow")}
|
||||||
@ -369,7 +339,9 @@ const Hero = () => {
|
|||||||
<div className="top-bar">
|
<div className="top-bar">
|
||||||
|
|
||||||
<form className="dropdown" id = "bodyPartList">
|
<form className="dropdown" id = "bodyPartList">
|
||||||
<select className="dropbtn">
|
<select className="dropbtn"
|
||||||
|
onChange={event => setBodyPart(event.target.value)}
|
||||||
|
defaultValue={bodyPart}>
|
||||||
<option value = "prawa">Noga Prawa</option>
|
<option value = "prawa">Noga Prawa</option>
|
||||||
<option value = "lewa">Noga Lewa</option>
|
<option value = "lewa">Noga Lewa</option>
|
||||||
<option value = "glowa">Głowa</option>
|
<option value = "glowa">Głowa</option>
|
||||||
@ -378,8 +350,11 @@ const Hero = () => {
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form className="dropdown" id = "shootTypeList">
|
<form className="dropdown" id = "shootTypeList">
|
||||||
<select className="dropbtn">
|
<select className="dropbtn" onChange={event => setTechnique(event.target.value)}
|
||||||
|
defaultValue = {technique}>
|
||||||
<option value="zwykly"> Zwykły </option>
|
<option value="zwykly"> Zwykły </option>
|
||||||
<option value = "voley"> Wolej </option>
|
<option value = "voley"> Wolej </option>
|
||||||
<option value = "pol-voley"> Półwolej </option>
|
<option value = "pol-voley"> Półwolej </option>
|
||||||
@ -390,8 +365,8 @@ const Hero = () => {
|
|||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form className="dropdown" id = "actionTypeList" onChange={event => setActionType(event.target.value)}
|
||||||
<form className="dropdown" id = "actionTypeList">
|
defaultValue={technique}>
|
||||||
<select className="dropbtn">
|
<select className="dropbtn">
|
||||||
<option value = "pozycyjny"> Atak Pozycyjny </option>
|
<option value = "pozycyjny"> Atak Pozycyjny </option>
|
||||||
<option value = "wolny"> Rzut Wolny </option>
|
<option value = "wolny"> Rzut Wolny </option>
|
||||||
@ -400,9 +375,9 @@ const Hero = () => {
|
|||||||
<option value="rozpoczecie"> Rozpoczęcie </option>
|
<option value="rozpoczecie"> Rozpoczęcie </option>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
|
<form className="dropdown" id = "possitionList"
|
||||||
|
onChange={event => setPossition(event.target.value)}
|
||||||
<form className="dropdown" id = "possitionList">
|
defaultValue={shooterPossition}>
|
||||||
<select className="dropbtn">
|
<select className="dropbtn">
|
||||||
<option value= "napastnik" > Napastnik </option>
|
<option value= "napastnik" > Napastnik </option>
|
||||||
<option value = "bramkarz"> Bramkarz </option>
|
<option value = "bramkarz"> Bramkarz </option>
|
||||||
|
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
from joblib import load
|
from joblib import load
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
|
import math
|
||||||
|
|
||||||
# Funkcja zwraca prawdopodobieństwo zdobycia gola
|
# Funkcja zwraca prawdopodobieństwo zdobycia gola
|
||||||
def LogisticRegression_predict_proba(position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead):
|
def LogisticRegression_predict_proba(position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead):
|
||||||
@ -89,24 +90,21 @@ def xgboost_predict_proba(minute, position_name, shot_body_part_name, shot_techn
|
|||||||
|
|
||||||
#XgBoost_2
|
#XgBoost_2
|
||||||
|
|
||||||
def xgboost_predict_proba_v2(minute, position_name, shot_body_part_name, shot_technique_name,
|
def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, minute,position_name,shot_body_part_name,
|
||||||
shot_type_name, shot_first_time, shot_one_on_one,
|
shot_technique_name,shot_type_name,shot_first_time,shot_aerial_won,shot_deflected,shot_open_goal,
|
||||||
shot_aerial_won, shot_deflected, shot_open_goal,
|
shot_follows_dribble,shot_redirect, shot_kick_off):
|
||||||
shot_follows_dribble, shot_redirect, x1, y1,
|
|
||||||
number_of_players_opponents, number_of_players_teammates,
|
|
||||||
angle, distance):
|
|
||||||
|
|
||||||
model = load('xgboost.joblib')
|
model = load('xgboost.joblib')
|
||||||
X_new = pd.DataFrame(columns=['minute', 'position_name', 'shot_body_part_name', 'shot_technique_name',
|
X_new = pd.DataFrame(columns=['minute', 'position_name', 'shot_body_part_name',
|
||||||
'shot_type_name', 'shot_first_time', 'shot_one_on_one',
|
'shot_technique_name','shot_type_name', 'shot_first_time',
|
||||||
'shot_aerial_won', 'shot_deflected', 'shot_open_goal',
|
'shot_one_on_one','shot_aerial_won', 'shot_deflected',
|
||||||
'shot_follows_dribble', 'shot_redirect', 'x1', 'y1',
|
'shot_open_goal','shot_follows_dribble', 'shot_redirect',
|
||||||
'number_of_players_opponents', 'number_of_players_teammates',
|
'x1', 'y1','number_of_players_opponents',
|
||||||
'angle', 'distance', 'x_player_opponent_Goalkeeper',
|
'number_of_players_teammates','angle', 'distance',
|
||||||
'x_player_opponent_8', 'x_player_opponent_1', 'x_player_opponent_2',
|
'x_player_opponent_Goalkeeper',
|
||||||
'x_player_opponent_3', 'x_player_teammate_1', 'x_player_opponent_4',
|
'x_player_opponent_1', 'x_player_opponent_2','x_player_opponent_3',
|
||||||
'x_player_opponent_5', 'x_player_opponent_6', 'x_player_teammate_2',
|
'x_player_opponent_4','x_player_opponent_5', 'x_player_opponent_6',
|
||||||
'x_player_opponent_9', 'x_player_opponent_10', 'x_player_opponent_11',
|
'x_player_teammate_2','x_player_opponent_9', 'x_player_opponent_10',
|
||||||
|
'x_player_opponent_11','x_player_teammate_1',
|
||||||
'x_player_teammate_3', 'x_player_teammate_4','x_player_teammate_5',
|
'x_player_teammate_3', 'x_player_teammate_4','x_player_teammate_5',
|
||||||
'x_player_teammate_6', 'x_player_teammate_7', 'x_player_teammate_8',
|
'x_player_teammate_6', 'x_player_teammate_7', 'x_player_teammate_8',
|
||||||
'x_player_teammate_9', 'x_player_teammate_10',
|
'x_player_teammate_9', 'x_player_teammate_10',
|
||||||
@ -121,31 +119,99 @@ def xgboost_predict_proba_v2(minute, position_name, shot_body_part_name, shot_te
|
|||||||
'x_player_teammate_Goalkeeper', 'y_player_teammate_Goalkeeper',
|
'x_player_teammate_Goalkeeper', 'y_player_teammate_Goalkeeper',
|
||||||
'shot_kick_off'])
|
'shot_kick_off'])
|
||||||
|
|
||||||
X_new.loc[len(X_new.index)] = [minute, position_name, shot_body_part_name, shot_technique_name,
|
|
||||||
shot_type_name, shot_first_time, shot_one_on_one,
|
shooter = konwertujDoListy(shooter)
|
||||||
shot_aerial_won, shot_deflected, shot_open_goal,
|
teamMatesList = konwertujDoListy(teamMatesList)
|
||||||
shot_follows_dribble, shot_redirect, x1, y1,
|
opponentsList = konwertujDoListy(opponentsList)
|
||||||
number_of_players_opponents, number_of_players_teammates,
|
goalkeeper = konwertujDoListy(goalkeeper)
|
||||||
angle, distance, x_player_opponent_Goalkeeper,
|
|
||||||
x_player_opponent_8, x_player_opponent_1, x_player_opponent_2,
|
# obliczenie katu oraz odleglosci
|
||||||
x_player_opponent_3, x_player_teammate_1, x_player_opponent_4,
|
angle = loc2angle(x = shooter[0], y = shooter[1])
|
||||||
x_player_opponent_5, x_player_opponent_6, x_player_teammate_2,
|
print("kat: " + str(angle))
|
||||||
x_player_opponent_9, x_player_opponent_10, x_player_opponent_11,
|
distance = loc2distance(x = shooter[0], y = shooter[1])
|
||||||
x_player_teammate_3, x_player_teammate_4, x_player_teammate_5,
|
print("dystans: " + str(distance))
|
||||||
x_player_teammate_6, x_player_teammate_7, x_player_teammate_8,
|
#Sortowanie list zawodnikow
|
||||||
x_player_teammate_9, x_player_teammate_10,
|
teamMatesList = sortNearestToShooter(teamMatesList,shooter= shooter)
|
||||||
y_player_opponent_Goalkeeper, y_player_opponent_8,
|
opponentsList = sortNearestToShooter(opponentsList, shooter=shooter)
|
||||||
y_player_opponent_1, y_player_opponent_2, y_player_opponent_3,
|
# Obliczenie ilosci zawosników
|
||||||
y_player_teammate_1, y_player_opponent_4, y_player_opponent_5,
|
teamMatesList = zmienWMaciez(teamMatesList)
|
||||||
y_player_opponent_6, y_player_teammate_2, y_player_opponent_9,
|
opponentsList = zmienWMaciez(opponentsList)
|
||||||
y_player_opponent_10, y_player_opponent_11, y_player_teammate_3,
|
|
||||||
y_player_teammate_4, y_player_teammate_5, y_player_teammate_6,
|
number_of_players_opponents = len(teamMatesList)
|
||||||
y_player_teammate_7, y_player_teammate_8, y_player_teammate_9,
|
number_of_players_teammates = len(opponentsList)
|
||||||
y_player_teammate_10, x_player_opponent_7, y_player_opponent_7,
|
# Bramkarz
|
||||||
|
x_player_opponent_Goalkeeper = goalkeeper[0]
|
||||||
|
y_player_opponent_Goalkeeper = goalkeeper[1]
|
||||||
|
# Uproszczona funkcja trzeba rozbudowac
|
||||||
|
shot_one_on_one = True if number_of_players_opponents == 1 else False
|
||||||
|
# TeamMate goalkeppe
|
||||||
|
|
||||||
|
x_player_teammate_Goalkeeper = None
|
||||||
|
y_player_teammate_Goalkeeper = None
|
||||||
|
#Reszta Zawodnikow
|
||||||
|
|
||||||
|
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
||||||
|
print(X_new.head)
|
||||||
|
X_new.loc[len(X_new.index)] = [minute, position_name, shot_body_part_name,
|
||||||
|
shot_technique_name,shot_type_name, shot_first_time,
|
||||||
|
shot_one_on_one,shot_aerial_won, shot_deflected,
|
||||||
|
shot_open_goal,shot_follows_dribble, shot_redirect,
|
||||||
|
shooter[0], shooter[1],number_of_players_opponents,
|
||||||
|
number_of_players_teammates,angle, distance,
|
||||||
|
x_player_opponent_Goalkeeper,
|
||||||
|
opponentsList[0][0], opponentsList[1][0], opponentsList[2][0],
|
||||||
|
opponentsList[3][0], opponentsList[4][0], opponentsList[5][0],
|
||||||
|
opponentsList[6][0], opponentsList[7][0], teamMatesList[8][0],
|
||||||
|
opponentsList[9][0], opponentsList[10][0],
|
||||||
|
teamMatesList[0][0], teamMatesList[1][0], teamMatesList[2][0],
|
||||||
|
teamMatesList[3][0], teamMatesList[4][0], teamMatesList[5][0],
|
||||||
|
teamMatesList[6][0], teamMatesList[7][0],teamMatesList[8][0],
|
||||||
|
teamMatesList[9][0],
|
||||||
|
y_player_opponent_Goalkeeper,
|
||||||
|
opponentsList[0][1], opponentsList[1][1], opponentsList[2][1],
|
||||||
|
opponentsList[3][1], opponentsList[4][1],opponentsList[5][1],
|
||||||
|
opponentsList[6][1], opponentsList[7][1], opponentsList[8][1],
|
||||||
|
opponentsList[9][1], opponentsList[10][1],
|
||||||
|
teamMatesList[0][1],teamMatesList[1][1], teamMatesList[2][1],
|
||||||
|
teamMatesList[4][1],teamMatesList[5][1], teamMatesList[6][1], teamMatesList[7][1],
|
||||||
|
teamMatesList[8][1], teamMatesList[9][1],
|
||||||
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
|
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
|
||||||
shot_kick_off]
|
shot_kick_off]
|
||||||
|
|
||||||
return model.predict_proba(X_new)[0][1].round(2)
|
return model.predict_proba(X_new)[0][1].round(2)
|
||||||
|
|
||||||
|
|
||||||
|
# Pomocnicze Funkcje
|
||||||
|
def sortNearestToShooter(playerList, shooter):
|
||||||
|
|
||||||
|
return playerList
|
||||||
|
|
||||||
|
|
||||||
|
def loc2distance(x, y):
|
||||||
|
return math.sqrt(x**2 + (y - 34)**2)
|
||||||
|
|
||||||
|
def loc2locdistance(x1, y1, x2, y2):
|
||||||
|
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
|
||||||
|
|
||||||
|
def loc2angle(x, y):
|
||||||
|
rads = math.atan(7.32 * x / (x**2 + (y - 34)**2 - (7.32/2)**2))
|
||||||
|
rads = math.pi + rads if rads < 0 else rads
|
||||||
|
deg = math.degrees(rads)
|
||||||
|
return deg
|
||||||
|
|
||||||
|
def konwertujDoListy(listaString):
|
||||||
|
listaString = listaString.split(",")
|
||||||
|
listaFloat = []
|
||||||
|
for elem in listaString:
|
||||||
|
listaFloat.append(float(elem))
|
||||||
|
return listaFloat
|
||||||
|
|
||||||
|
def zmienWMaciez(lista):
|
||||||
|
maciez = []
|
||||||
|
for i in range(0,len(lista),2):
|
||||||
|
player = [lista[i],lista[i+1]]
|
||||||
|
maciez.append(player)
|
||||||
|
if(len(maciez) < 10):
|
||||||
|
for i in range(len(maciez),11,1):
|
||||||
|
maciez.append([None,None])
|
||||||
|
return maciez
|
48
app/src/flask-server/modele/testy.py
Normal file
48
app/src/flask-server/modele/testy.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
from modele import zmienWMaciez,xgboost_predict_proba_v2,konwertujDoListy
|
||||||
|
|
||||||
|
|
||||||
|
#zmien maciez test
|
||||||
|
'''
|
||||||
|
lista = [2,3,43,12,323,12,23,43,54,90]
|
||||||
|
print(zmienWMaciez(lista))
|
||||||
|
lista = zmienWMaciez(lista)
|
||||||
|
print(lista[3][0])
|
||||||
|
print(lista[3][1])
|
||||||
|
print(lista[0][0])
|
||||||
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
|
string = "49.27,49.73,48.49,34.75,19.95,28.44"
|
||||||
|
|
||||||
|
string = konwertujDoListy(string)
|
||||||
|
print(string)
|
||||||
|
print(string[3])
|
||||||
|
|
||||||
|
string = zmienWMaciez(string)
|
||||||
|
print(string)
|
||||||
|
'''
|
||||||
|
'''
|
||||||
|
a = ['minute', 'position_name', 'shot_body_part_name', 'shot_technique_name',
|
||||||
|
'shot_type_name', 'shot_first_time', 'shot_one_on_one',
|
||||||
|
'shot_aerial_won', 'shot_deflected', 'shot_open_goal',
|
||||||
|
'shot_follows_dribble', 'shot_redirect', 'x1', 'y1',
|
||||||
|
'number_of_players_opponents', 'number_of_players_teammates',
|
||||||
|
'angle', 'distance', 'x_player_opponent_Goalkeeper',
|
||||||
|
'x_player_opponent_1', 'x_player_opponent_2','x_player_opponent_3', 'x_player_opponent_4',
|
||||||
|
'x_player_opponent_5', 'x_player_opponent_6', 'x_player_teammate_2',
|
||||||
|
'x_player_opponent_9', 'x_player_opponent_10', 'x_player_opponent_11','x_player_teammate_1'
|
||||||
|
'x_player_teammate_3', 'x_player_teammate_4', 'x_player_teammate_5',
|
||||||
|
'x_player_teammate_6', 'x_player_teammate_7', 'x_player_teammate_8',
|
||||||
|
'x_player_teammate_9', 'x_player_teammate_10',
|
||||||
|
'y_player_opponent_Goalkeeper', 'y_player_opponent_8',
|
||||||
|
'y_player_opponent_1', 'y_player_opponent_2', 'y_player_opponent_3',
|
||||||
|
'y_player_teammate_1', 'y_player_opponent_4', 'y_player_opponent_5',
|
||||||
|
'y_player_opponent_6', 'y_player_teammate_2', 'y_player_opponent_9',
|
||||||
|
'y_player_opponent_10', 'y_player_opponent_11', 'y_player_teammate_3',
|
||||||
|
'y_player_teammate_4', 'y_player_teammate_5', 'y_player_teammate_6',
|
||||||
|
'y_player_teammate_7', 'y_player_teammate_8', 'y_player_teammate_9',
|
||||||
|
'y_player_teammate_10', 'x_player_opponent_7', 'y_player_opponent_7',
|
||||||
|
'x_player_teammate_Goalkeeper', 'y_player_teammate_Goalkeeper',
|
||||||
|
'shot_kick_off']
|
||||||
|
print(len(a))
|
||||||
|
'''
|
@ -1,32 +1,12 @@
|
|||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from modele.modele import LogisticRegression_predict_proba, xgboost_predict_proba, xgboost_predict_proba_v2
|
from modele.modele import LogisticRegression_predict_proba, xgboost_predict_proba, xgboost_predict_proba_v2
|
||||||
import math
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
CORS(app)
|
CORS(app)
|
||||||
app.config['CORS_HEADERS'] = 'Content-Type'
|
app.config['CORS_HEADERS'] = 'Content-Type'
|
||||||
|
|
||||||
def loc2angle(x, y):
|
|
||||||
rads = math.atan(7.32 * x / (x**2 + (y - 34)**2 - (7.32/2)**2))
|
|
||||||
rads = math.pi + rads if rads < 0 else rads
|
|
||||||
deg = math.degrees(rads)
|
|
||||||
return deg
|
|
||||||
|
|
||||||
def loc2distance(x, y):
|
|
||||||
return math.sqrt(x**2 + (y - 34)**2)
|
|
||||||
|
|
||||||
def loc2locdistance(x1, y1, x2, y2):
|
|
||||||
return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
|
|
||||||
|
|
||||||
#Konwertuje string zawierajacy liczby odzielone , i konwertuje do float
|
|
||||||
def konwertujDoListy(listaString):
|
|
||||||
listaString = listaString.split(",")
|
|
||||||
listaFloat = []
|
|
||||||
for elem in listaString:
|
|
||||||
listaFloat.append(float(elem))
|
|
||||||
return listaFloat
|
|
||||||
# zapytanie o regresje logistyczną na podstawie pozycji piłki
|
# zapytanie o regresje logistyczną na podstawie pozycji piłki
|
||||||
|
|
||||||
# @app.route("/LRegresion<x>&<y>")
|
# @app.route("/LRegresion<x>&<y>")
|
||||||
@ -35,20 +15,12 @@ def get_model():
|
|||||||
|
|
||||||
# Pozycja strzelca
|
# Pozycja strzelca
|
||||||
shooter = request.args.get('shooter')
|
shooter = request.args.get('shooter')
|
||||||
shooter = konwertujDoListy(shooter)
|
|
||||||
|
|
||||||
print("wprowadzone dane:")
|
print("wprowadzone dane:")
|
||||||
print("x strzelca: " + str(shooter[0]))
|
print("strzelec: " + shooter)
|
||||||
print("y strzelca: " + str(shooter[1]))
|
|
||||||
|
|
||||||
if shooter[0] is None and shooter[1] is None:
|
if shooter[0] is None and shooter[1] is None:
|
||||||
return jsonify({"error": "Brak wymaganych parametrów"}), 400
|
return jsonify({"error": "Brak wymaganych parametrów"}), 400
|
||||||
# Kąt oraz dystans od bramki
|
|
||||||
angle = loc2angle(x = shooter[0], y = shooter[1])
|
|
||||||
dist = loc2distance(x = shooter[0], y = shooter[1])
|
|
||||||
|
|
||||||
print("kąt: " + str(angle))
|
|
||||||
print("dystans: " + str(dist) )
|
|
||||||
|
|
||||||
# Elementy z list: czesc ciała,rodzaj uderzenia,pozycja strzelca oraz typ akcji
|
# Elementy z list: czesc ciała,rodzaj uderzenia,pozycja strzelca oraz typ akcji
|
||||||
|
|
||||||
@ -67,23 +39,22 @@ def get_model():
|
|||||||
teamMatesList = request.args.get('defenders')
|
teamMatesList = request.args.get('defenders')
|
||||||
opponentsList = request.args.get('strickers')
|
opponentsList = request.args.get('strickers')
|
||||||
|
|
||||||
teamMatesList = konwertujDoListy(teamMatesList)
|
|
||||||
opponentsList = konwertujDoListy(opponentsList)
|
|
||||||
print("wspolrzedne obroncow: " + teamMatesList)
|
print("wspolrzedne obroncow: " + teamMatesList)
|
||||||
print("wspolrzedne przeciwnikow: " + opponentsList)
|
print("wspolrzedne przeciwnikow: " + opponentsList)
|
||||||
|
|
||||||
|
|
||||||
# Bramkarz
|
# Bramkarz
|
||||||
goalkepper = request.args.get('goalkeeper')
|
goalkepper = "2,2"
|
||||||
goalkepper = konwertujDoListy(goalkepper)
|
#goalkepper = request.args.get('goalkeeper')
|
||||||
|
|
||||||
print("bramkarz: " + str(goalkepper) )
|
print("bramkarz: " + str(goalkepper) )
|
||||||
|
|
||||||
|
response = xgboost_predict_proba_v2(shooter = shooter,
|
||||||
response = xgboost_predict_proba_v2(minute = 20, position_name = position_name, shot_body_part_name = body_part, shot_technique_name = technique,
|
opponentsList = opponentsList, teamMatesList = teamMatesList ,minute = 20, position_name = position_name, shot_body_part_name = body_part, shot_technique_name = technique,
|
||||||
shot_type_name = acionType, shot_first_time = False,
|
shot_type_name = acionType, shot_first_time = False,
|
||||||
shot_aerial_won = False, shot_deflected = False, shot_open_goal = False,
|
shot_aerial_won = False, shot_deflected = False, shot_open_goal = False,
|
||||||
shot_follows_dribble = False, shot_redirect = False, shooter = shooter,
|
shot_follows_dribble = False, shot_redirect = False, shot_kick_off = False, goalkeeper= goalkepper
|
||||||
opponentsList = opponentsList, teamMatesList = teamMatesList,
|
)
|
||||||
angle = angle, distance = dist)
|
|
||||||
|
|
||||||
#print(response)
|
#print(response)
|
||||||
res = str(response)
|
res = str(response)
|
||||||
|
BIN
app/src/flask-server/xgboost.joblib
Normal file
BIN
app/src/flask-server/xgboost.joblib
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user