integracja na labach

This commit is contained in:
Szymon Obst 2023-12-12 18:42:33 +01:00
parent 9e2beafb90
commit c099e92132
6 changed files with 36 additions and 20 deletions

8
app/package-lock.json generated
View File

@ -33,7 +33,7 @@
"post": "^0.0.1",
"postcss": "^8.4.32",
"tailwindcss": "^3.3.5",
"vite": "^5.0.0"
"vite": "^5.0.8"
}
},
"node_modules/@aashutoshrathi/word-wrap": {
@ -5290,9 +5290,9 @@
}
},
"node_modules/vite": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.0.5.tgz",
"integrity": "sha512-OekeWqR9Ls56f3zd4CaxzbbS11gqYkEiBtnWFFgYR2WV8oPJRRKq0mpskYy/XaoCL3L7VINDhqqOMNDiYdGvGg==",
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/vite/-/vite-5.0.8.tgz",
"integrity": "sha512-jYMALd8aeqR3yS9xlHd0OzQJndS9fH5ylVgWdB+pxTwxLKdO1pgC5Dlb398BUxpfaBxa4M9oT7j1g503Gaj5IQ==",
"dev": true,
"dependencies": {
"esbuild": "^0.19.3",

View File

@ -36,6 +36,6 @@
"post": "^0.0.1",
"postcss": "^8.4.32",
"tailwindcss": "^3.3.5",
"vite": "^5.0.0"
"vite": "^5.0.8"
}
}

View File

@ -7,9 +7,7 @@ import { logo, menu, close } from "../assets";
const Hero = () => {
const [data,setData] = useState([{}])
// Reset Boiska
function resetField() {
var footballField = document.getElementById('footballField');
@ -21,30 +19,25 @@ const Hero = () => {
}
// Wysłanie zapytania do serwera
function sentQuestion() {
var ball = document.querySelector('.football');
if (ball) {
var x = ball.style.left;
var y = ball.style.top;
var query = "/LRegresion" + x + "&" + y
alert(query)
fetch("/LRegresion").then(
var query = "http://localhost:5000/LRegresion" + x + "&" + y
fetch(query).then(
res => res.json
).then(
data => {
setData(data)
console.log(data)``
console.log(data)
}
)
} else {
alert('Piłka nie jest obecnie na boisku.');
}
}
/* Funkcja dodająca listener do boiska*/
/* Funkcja dodająca listener do boiska*/
function boiskoListener(){
var x = event.clientX - footballField.getBoundingClientRect().left;
var y = event.clientY - footballField.getBoundingClientRect().top;
@ -63,7 +56,7 @@ const Hero = () => {
useEffect(()=>{
var footballField = document.getElementById('footballField');
footballField.addEventListener('click', boiskoListener)
},[]);
});
/*zwracany komponent zawierajacy boisko*/

View File

@ -0,0 +1,13 @@
from joblib import load
import pandas as pd
# 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):
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.loc[len(X_new.index)] = [position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead]
return model.predict_proba(X_new)[0][1].round(2)
#kolejne modele

View File

@ -1,5 +1,7 @@
from flask import Flask
from flask_cors import CORS
from modele.modele import LogisticRegression_predict_proba
app = Flask(__name__)
CORS(app)
@ -9,10 +11,18 @@ CORS(app)
def members():
return{"members":["Member1","Member2","Member3"]}
# zapytanie o regresje logistyczną na podstawie pozycji piłki
@app.route("/LRegresion<x>&<y>")
def LRegresion(x,y):
num = x+y
return str(num)
x = int(x[0:2])
y = int(y[0:2])
response = LogisticRegression_predict_proba(9.23, -2.24, 9.5, 13.67, 13, 3, 0, 1, 0)
return {"response":[str(response),"proces"]}
# uruchomienie serwera
if __name__ == "__main__":
app.run(debug = True)