This commit is contained in:
unknown 2023-12-19 17:29:03 +01:00
parent 31fde0ad1b
commit fc2fef33e6
5 changed files with 47 additions and 15 deletions

View File

@ -8,8 +8,6 @@ import { logo, menu, close } from "../assets";
const Hero = () => { const Hero = () => {
const [data,setData] = useState([{}])
//zmienne globalne //zmienne globalne
//zmienna mówiąca który przycisk jest aktywny, jest ona wykorzystywana //zmienna mówiąca który przycisk jest aktywny, jest ona wykorzystywana
@ -19,9 +17,9 @@ const Hero = () => {
let number_of_defenders = 0; let number_of_defenders = 0;
let number_of_strikers = 0; let number_of_strikers = 0;
let shooterX = 0; var shooterX = 0;
let shooterY = 0; var shooterY = 0;
var eX = " ";
// zmienne globalne bedace danymi wejsciowymi do modelu // zmienne globalne bedace danymi wejsciowymi do modelu
@ -34,6 +32,15 @@ const Hero = () => {
active_bbt = a active_bbt = a
} }
function changeLeg(a){
document.getElementById("bbt4").style.background = "white";
document.getElementById("bbt5").style.background = "white";
document.getElementById("bbt6").style.background = "white";
document.getElementById(a).style.background = "grey";
Leg_bbt = a
}
// Reset Boiska // Reset Boiska
function resetField() { function resetField() {
@ -58,13 +65,11 @@ const Hero = () => {
} }
// Wysłanie zapytania do serwera // Wysłanie zapytania do serwera
const [data,setData] = useState([{}])
function sentQuestion() { function sentQuestion() {
var ball = document.querySelector('.football'); var ball = document.querySelector('.football');
if (ball) { if (ball) {
var x = ball.style.left; fetch("http://localhost:5000/LRegresion" + shooterX + "&" + shooterY).then(
var y = ball.style.top;
var query = "http://localhost:5000/LRegresion" + shooterX + "&" + shooterY
fetch(query).then(
res=> res.json() res=> res.json()
).then( ).then(
data => { data => {
@ -72,10 +77,12 @@ const Hero = () => {
console.log(data) console.log(data)
} }
) )
alert(data.response) eX = data.response
document.getElementById("ex").innerHTML = "Ex:"+ eX
} else { } else {
alert('Piłka nie jest obecnie na boisku.'); alert('Piłka nie jest obecnie na boisku.');
} }
} }
/* Funkcja dodająca listener do boiska*/ /* Funkcja dodająca listener do boiska*/
@ -83,12 +90,13 @@ const Hero = () => {
var x = event.clientX - footballField.getBoundingClientRect().left; var x = event.clientX - footballField.getBoundingClientRect().left;
var y = event.clientY - footballField.getBoundingClientRect().top; var y = event.clientY - footballField.getBoundingClientRect().top;
shooterX = (x * 105)/600 shooterX = (x * 105)/600
shooterY = ((400 - y) * 69)/ 400 shooterY = ((400 - y) * 69)/ 400
// Przypadek kiedy zaznaczamy strzelca // Przypadek kiedy zaznaczamy strzelca
if(active_bbt == "bbt1"){ if(active_bbt == "bbt1"){
var existingBall = document.querySelector('.football'); let existingBall = document.querySelector('.football');
if (!existingBall) { if (!existingBall) {
var ball = document.createElement('div'); var ball = document.createElement('div');
@ -137,6 +145,16 @@ const Hero = () => {
document.getElementById("bbt3").addEventListener("click",function(){ document.getElementById("bbt3").addEventListener("click",function(){
changePlayer("bbt3") changePlayer("bbt3")
},false) },false)
document.getElementById("bbt4").addEventListener("click",function(){
changeLeg("bbt4")
},false)
document.getElementById("bbt5").addEventListener("click",function(){
changeLeg("bbt5")
},false)
document.getElementById("bbt6").addEventListener("click",function(){
changeLeg("bbt6")
},false)
},[]); },[]);
/*zwracany komponent zawierajacy boisko*/ /*zwracany komponent zawierajacy boisko*/
@ -184,6 +202,9 @@ const Hero = () => {
<button className="cho-defence" id = "bbt5">Noga słabsza</button> <button className="cho-defence" id = "bbt5">Noga słabsza</button>
<button className="cho-atack" id = "bbt6">Głowa</button> <button className="cho-atack" id = "bbt6">Głowa</button>
</div> </div>
<div>
<b id = "ex" className="Ex">Ex:</b>
</div>
</div> </div>
</body> </body>

View File

@ -1,8 +1,12 @@
from joblib import load from joblib import load
import pandas as pd import pandas as pd
from math import sqrt
# 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, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead):
distance_to_goalM = sqrt(( (position_x**2) + (position_y**2)))
model = load('regresja_logistyczna.joblib') model = load('regresja_logistyczna.joblib')
X_new = pd.DataFrame(columns=['position_x', 'position_y', 'distance_to_goalM', 'angle','match_minute', 'Number_Intervening_Opponents','Number_Intervening_Teammates', 'isFoot', 'isHead']) X_new = pd.DataFrame(columns=['position_x', 'position_y', 'distance_to_goalM', 'angle','match_minute', 'Number_Intervening_Opponents','Number_Intervening_Teammates', 'isFoot', 'isHead'])
X_new.loc[len(X_new.index)] = [position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead] X_new.loc[len(X_new.index)] = [position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead]

View File

@ -16,10 +16,13 @@ def members():
@app.route("/LRegresion<x>&<y>") @app.route("/LRegresion<x>&<y>")
def LRegresion(x,y): def LRegresion(x,y):
x = round(x,2) x = int(x[0:2])
y = round(y,2) y = int(y[0:2])
response = LogisticRegression_predict_proba(x, y, 9.5, 13.67, 13, 3, 0, 1, 0) response = LogisticRegression_predict_proba(x, y, 13.67, 13, 3, 0, 1, 0)
print(x)
print(y)
print(response)
return {"response":[str(response)]} return {"response":[str(response)]}
# uruchomienie serwera # uruchomienie serwera

View File

@ -4,6 +4,10 @@
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;
.Ex{
font-size: 40px;
}
body { body {
margin: 50px; margin: 50px;
display: grid; display: grid;