CoolFace
Apppublic

3koozy/Predict_FBPLayer_Value

sourceHugging Faceunknownupdated 4y agoView on Hugging Face
0likes
app.py42 linesDownload Raw Back to root
1import pandas as pd2import numpy as np3from IPython.display import display4from sklearn import preprocessing5from sklearn.neighbors import KNeighborsRegressor6from sklearn.neural_network import MLPRegressor7from sklearn.preprocessing import OneHotEncoder8from pickle import dump, load9import gradio as gr10 11# load the model12mlp_model = load(open('mlp_classifier.pkl', 'rb'))13# load the scaler14my_scaler = load(open('scaler.pkl', 'rb'))15hot_enc_scaler = load(open('hot_enc.pkl', 'rb'))16 17description = '''18This 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.19'''20 21def predict_value(age,height_cm,weight_kg,overall_skill,potential_skill,nationality,club):22  #pre-processing:23  numerical_features = [[age,height_cm,weight_kg,overall_skill,potential_skill]]24  catagorical_features = [[nationality,club]]25  numerical_features = my_scaler.transform(numerical_features)  26  catagorical_features = hot_enc_scaler.transform(catagorical_features).toarray()27  sample_player = np.concatenate((numerical_features[0], catagorical_features[0]), axis=0)28  #predict:29  predicted_value = mlp_model.predict(sample_player.reshape(1, -1))30  return predicted_value31 32 33demo = gr.Interface(34    fn=predict_value,35    inputs=[gr.Slider(15, 60),gr.Slider(100, 200),gr.Slider(0, 100),gr.Slider(0, 100),gr.Slider(0, 100),36            gr.inputs.Dropdown(["Argentina" , "Saudi Arabia", "England"]),37            gr.inputs.Dropdown(["FC Barcelona" , "Juventus", "Liverpool", "Al Hilal", "Al Nassr"])],38            outputs=[gr.Number(label='Net Worth (Euros)')],39            title= "TalentAI - Estimate FB Player Value (Eur)",40            description = description,41            article = "Abdulaziz Alakooz developed this prototype as part of Thkaa AI in sports contest - August 2022.")42demo.launch()