Dalsza praca nad integracją
This commit is contained in:
parent
599a4ce252
commit
6cb9ffc781
|
@ -190,6 +190,8 @@ const Hero = () => {
|
||||||
ball.style.left = x + "%"
|
ball.style.left = x + "%"
|
||||||
ball.style.top = y + "%"
|
ball.style.top = y + "%"
|
||||||
}
|
}
|
||||||
|
//var shooterX = konwerturX(ball.style.left)
|
||||||
|
//var shooterY = konwetujY(ball.style.top)
|
||||||
posytion.innerHTML = "x:" + konwerturX(ball.style.left) + "m " + "y:" + konwetujY(ball.style.top) + "m";
|
posytion.innerHTML = "x:" + konwerturX(ball.style.left) + "m " + "y:" + konwetujY(ball.style.top) + "m";
|
||||||
bojo.addEventListener("mouseup", function(){
|
bojo.addEventListener("mouseup", function(){
|
||||||
ball.style.background = pColor
|
ball.style.background = pColor
|
||||||
|
@ -204,20 +206,29 @@ const Hero = () => {
|
||||||
// // Wyłanie zapytania do serwera
|
// // Wyłanie zapytania do serwera
|
||||||
function sentQuestion() {
|
function sentQuestion() {
|
||||||
var ball = document.querySelector('.football');
|
var ball = document.querySelector('.football');
|
||||||
if (ball) {
|
|
||||||
fetch("http://127.0.0.1:5000/get_model").then(
|
if (ball) {
|
||||||
res=> res.json()
|
// Użyj backticksów zamiast zwykłych cudzysłowów
|
||||||
).then(
|
//console.log('Wysyłanie wartości: ', ball);
|
||||||
data => {
|
shooterX = konwerturX(ball.style.left)
|
||||||
setData(data)
|
shooterY = konwetujY(ball.style.top)
|
||||||
console.log(data)
|
console.log('Wysyłanie wartości: ', shooterX, shooterY);
|
||||||
}
|
fetch(`http://127.0.0.1:5000/get_model?x=${shooterX}&y=${shooterY}`).then(
|
||||||
)
|
res => res.json()
|
||||||
eX = data.response
|
).then(
|
||||||
document.getElementById("ex").innerHTML = "Współczynnik xG: "+ eX
|
data => {
|
||||||
} else {
|
setData(data);
|
||||||
alert('Piłka nie jest obecnie na boisku.');
|
console.log(data);
|
||||||
}
|
// Przenieś tę linię do środka bloku .then(), aby uniknąć błędów
|
||||||
|
let eX = data.response;
|
||||||
|
document.getElementById("ex").innerHTML = "Współczynnik xG: " + eX;
|
||||||
|
}
|
||||||
|
).catch(error => {
|
||||||
|
console.error('Błąd:', error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert('Piłka nie jest obecnie na boisku.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from flask import Flask
|
from flask import Flask, request, jsonify
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from modele.modele import LogisticRegression_predict_proba
|
from modele.modele import LogisticRegression_predict_proba
|
||||||
|
|
||||||
|
@ -15,14 +15,21 @@ app.config['CORS_HEADERS'] = 'Content-Type'
|
||||||
# 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>")
|
||||||
@app.route("/get_model")
|
@app.route("/get_model", methods = ['GET'])
|
||||||
def get_model():
|
def get_model():
|
||||||
|
|
||||||
#x = int(x[0:2])
|
# x = int(x[0:2])
|
||||||
#y = int(y[0:2])
|
# y = int(y[0:2])
|
||||||
|
x = request.args.get('x', type=float)
|
||||||
|
y = request.args.get('y', type=float)
|
||||||
|
## change model on xgboost
|
||||||
|
## add angle, match minutes and number of players
|
||||||
|
|
||||||
response = LogisticRegression_predict_proba(position_x=5,
|
if y is None and x is None:
|
||||||
position_y=5,
|
return jsonify({"error": "Brak wymaganych parametrów"}), 400
|
||||||
|
|
||||||
|
response = LogisticRegression_predict_proba(position_x=x,
|
||||||
|
position_y=y,
|
||||||
angle = 13.67,
|
angle = 13.67,
|
||||||
match_minute=13,
|
match_minute=13,
|
||||||
Number_Intervening_Opponents=3,
|
Number_Intervening_Opponents=3,
|
||||||
|
@ -33,7 +40,8 @@ def get_model():
|
||||||
#print(y)
|
#print(y)
|
||||||
#print(response)
|
#print(response)
|
||||||
res = str(response)
|
res = str(response)
|
||||||
return {"response":res}
|
#return {"response":res}
|
||||||
|
return jsonify({"response":res})
|
||||||
|
|
||||||
# uruchomienie serwera
|
# uruchomienie serwera
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue