3koozy's picture
Update app.py
d268dba
import pandas as pd
import numpy as np
from IPython.display import display
from sklearn import preprocessing
from sklearn.neighbors import KNeighborsRegressor
from sklearn.neural_network import MLPRegressor
from sklearn.preprocessing import OneHotEncoder
from pickle import dump, load
import gradio as gr
# load the model
mlp_model = load(open('mlp_classifier.pkl', 'rb'))
# load the scaler
my_scaler = load(open('scaler.pkl', 'rb'))
hot_enc_scaler = load(open('hot_enc.pkl', 'rb'))
description = '''
This small prototype is using Big Data and AI to provide an accurate estimate of FootBall player net worth in euros based on bio info and skill level.
'''
def predict_value(age,height_cm,weight_kg,overall_skill,potential_skill,nationality,club):
#pre-processing:
numerical_features = [[age,height_cm,weight_kg,overall_skill,potential_skill]]
catagorical_features = [[nationality,club]]
numerical_features = my_scaler.transform(numerical_features)
catagorical_features = hot_enc_scaler.transform(catagorical_features).toarray()
sample_player = np.concatenate((numerical_features[0], catagorical_features[0]), axis=0)
#predict:
predicted_value = mlp_model.predict(sample_player.reshape(1, -1))
return predicted_value
demo = gr.Interface(
fn=predict_value,
inputs=[gr.Slider(15, 60),gr.Slider(100, 200),gr.Slider(0, 100),gr.Slider(0, 100),gr.Slider(0, 100),
gr.inputs.Dropdown(["Argentina" , "Saudi Arabia", "England"]),
gr.inputs.Dropdown(["FC Barcelona" , "Juventus", "Liverpool", "Al Hilal", "Al Nassr"])],
outputs=[gr.Number(label='Net Worth (Euros)')],
title= "TalentAI - Estimate FB Player Value (Eur)",
description = description,
article = "Abdulaziz Alakooz developed this prototype as part of Thkaa AI in sports contest - August 2022.")
demo.launch()