zeel sheladiya commited on
Commit
8fb8334
·
1 Parent(s): fff6aba
app.py CHANGED
@@ -1,12 +1,42 @@
1
  import gradio as gr
2
  import pandas as pd
3
  import random
 
 
 
4
 
5
  data = pd.read_pickle("merged_all_table.pkl", compression='bz2')
6
 
7
  home_team_id = sorted(data["home_team_long_name"].unique())
8
  away_team_id = sorted(data["away_team_long_name"].unique())
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  def predict(Home_team, Away_team, Model_name):
12
 
@@ -19,11 +49,20 @@ def predict(Home_team, Away_team, Model_name):
19
  if Model_name == "":
20
  raise gr.Error("Model is required, Please Select The Model!")
21
 
22
- if Model_name == "Simple Model":
23
- # model = km.load_model('models/simple_model.pkl')
24
- pass
 
 
 
 
 
 
 
 
 
 
25
 
26
- return "Model is in under construction 🛠️🚜"
27
 
28
  # markup table for markdown
29
  # # Members:
@@ -72,7 +111,7 @@ with gr.Blocks() as demo:
72
 
73
  dd_model = gr.Dropdown(
74
  label="Model ( Feature Under Construction 🚧 )",
75
- choices=["Simple Model"],
76
  info="Select Your Model:",
77
  multiselect=False,
78
  )
 
1
  import gradio as gr
2
  import pandas as pd
3
  import random
4
+ from keras.models import load_model
5
+ import tensorflow as tf
6
+ import numpy as np
7
 
8
  data = pd.read_pickle("merged_all_table.pkl", compression='bz2')
9
 
10
  home_team_id = sorted(data["home_team_long_name"].unique())
11
  away_team_id = sorted(data["away_team_long_name"].unique())
12
 
13
+ nn_model = load_model('models/nn_model.h5')
14
+
15
+
16
+ def main_process(model, Home_team, Away_team):
17
+
18
+ home_temp = data[data["home_team_long_name"] == Home_team]
19
+ home_temp = home_temp[["home_team_overall_score", "home_total_goal", "home_players_avg_overall_rating", "home_players_avg_overall_score", "home_players_avg_ideal_body_rate", "home_total_win", "home_total_loose", "home_total_draw", "league_home_total_win", "league_home_total_loose", "league_home_total_draw"]]
20
+ print("Home Team Data Geathring ✅")
21
+
22
+ away_temp = data[data["away_team_long_name"] == Away_team]
23
+ away_temp = away_temp[["away_team_overall_score", "away_total_goal", "away_players_avg_overall_rating", "away_players_avg_overall_score", "away_players_avg_ideal_body_rate", "away_total_win", "away_total_loose", "away_total_draw", "league_away_total_win", "league_away_total_loose", "league_away_total_draw"]]
24
+ print("Away Team Data Geathring ✅")
25
+
26
+ table = pd.concat([home_temp.mean(), away_temp.mean()], axis=0)
27
+ table = table[["home_team_overall_score", "away_team_overall_score", "home_total_goal", "away_total_goal", "home_players_avg_overall_rating", "home_players_avg_overall_score", "home_players_avg_ideal_body_rate", "away_players_avg_overall_rating", "away_players_avg_overall_score", "away_players_avg_ideal_body_rate", "home_total_win", "home_total_loose", "home_total_draw", "away_total_win", "away_total_loose", "away_total_draw", "league_home_total_win", "league_home_total_loose", "league_home_total_draw", "league_away_total_win", "league_away_total_loose", "league_away_total_draw"]]
28
+ print("Table Concatination ✅")
29
+
30
+ X = table.to_frame().T
31
+
32
+ pred = model.predict(X)
33
+ predicted_labels = np.argmax(pred)
34
+ print("Data Prediction ✅")
35
+
36
+ print(predicted_labels)
37
+
38
+ return predicted_labels
39
+
40
 
41
  def predict(Home_team, Away_team, Model_name):
42
 
 
49
  if Model_name == "":
50
  raise gr.Error("Model is required, Please Select The Model!")
51
 
52
+ if Model_name == "Simple Nueral Network Model":
53
+ model = nn_model
54
+
55
+ prediction = main_process(model, Home_team, Away_team)
56
+
57
+ if prediction == 0:
58
+ return "🥳 Home Team Win 🎉"
59
+
60
+ if prediction == 1:
61
+ return "🥳 Away Team Win 🎉"
62
+
63
+ if prediction == 2:
64
+ return "😑 Match Draw 😑"
65
 
 
66
 
67
  # markup table for markdown
68
  # # Members:
 
111
 
112
  dd_model = gr.Dropdown(
113
  label="Model ( Feature Under Construction 🚧 )",
114
+ choices=["Simple Nueral Network Model"],
115
  info="Select Your Model:",
116
  multiselect=False,
117
  )
models/{simple_model.pkl → nn_model.h5} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:646659c40f96f43be2e15e1e472f6c8fe4198e4d8c35202becef888c96d50389
3
- size 2204975
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77acbf1549229bfb38a4e61aa313a3633122cc1d5087978277ef0a3e40607e46
3
+ size 2302560
requirements.txt CHANGED
@@ -1,11 +1,14 @@
 
1
  aiofiles==23.1.0
2
  aiohttp==3.8.5
3
  aiosignal==1.3.1
4
  altair==5.0.1
5
  annotated-types==0.5.0
6
  anyio==3.7.1
 
7
  async-timeout==4.0.2
8
  attrs==23.1.0
 
9
  certifi==2023.7.22
10
  charset-normalizer==3.2.0
11
  click==8.1.6
@@ -15,33 +18,49 @@ exceptiongroup==1.1.2
15
  fastapi==0.101.0
16
  ffmpy==0.3.1
17
  filelock==3.12.2
 
18
  fonttools==4.42.0
19
  frozenlist==1.4.0
20
  fsspec==2023.6.0
 
 
 
 
21
  gradio==3.39.0
22
  gradio_client==0.3.0
 
23
  h11==0.14.0
 
24
  httpcore==0.17.3
25
  httpx==0.24.1
26
  huggingface-hub==0.16.4
27
  idna==3.4
 
28
  importlib-resources==6.0.0
29
  Jinja2==3.1.2
30
  jsonschema==4.18.6
31
  jsonschema-specifications==2023.7.1
 
32
  kiwisolver==1.4.4
 
33
  linkify-it-py==2.0.2
 
34
  markdown-it-py==2.2.0
35
  MarkupSafe==2.1.3
36
  matplotlib==3.7.2
37
  mdit-py-plugins==0.3.3
38
  mdurl==0.1.2
39
  multidict==6.0.4
40
- numpy==1.25.2
 
 
41
  orjson==3.9.3
42
  packaging==23.1
43
  pandas==2.0.3
44
  Pillow==10.0.0
 
 
 
45
  pydantic==2.1.1
46
  pydantic_core==2.4.0
47
  pydub==0.25.1
@@ -52,18 +71,28 @@ pytz==2023.3
52
  PyYAML==6.0.1
53
  referencing==0.30.2
54
  requests==2.31.0
 
55
  rpds-py==0.9.2
 
56
  semantic-version==2.10.0
57
  six==1.16.0
58
  sniffio==1.3.0
59
  starlette==0.27.0
 
 
 
 
 
 
60
  toolz==0.12.0
61
  tqdm==4.65.0
62
- typing_extensions==4.7.1
63
  tzdata==2023.3
64
  uc-micro-py==1.0.2
65
- urllib3==2.0.4
66
  uvicorn==0.23.2
67
  websockets==11.0.3
 
 
68
  yarl==1.9.2
69
  zipp==3.16.2
 
1
+ absl-py==1.4.0
2
  aiofiles==23.1.0
3
  aiohttp==3.8.5
4
  aiosignal==1.3.1
5
  altair==5.0.1
6
  annotated-types==0.5.0
7
  anyio==3.7.1
8
+ astunparse==1.6.3
9
  async-timeout==4.0.2
10
  attrs==23.1.0
11
+ cachetools==5.3.1
12
  certifi==2023.7.22
13
  charset-normalizer==3.2.0
14
  click==8.1.6
 
18
  fastapi==0.101.0
19
  ffmpy==0.3.1
20
  filelock==3.12.2
21
+ flatbuffers==23.5.26
22
  fonttools==4.42.0
23
  frozenlist==1.4.0
24
  fsspec==2023.6.0
25
+ gast==0.4.0
26
+ google-auth==2.22.0
27
+ google-auth-oauthlib==1.0.0
28
+ google-pasta==0.2.0
29
  gradio==3.39.0
30
  gradio_client==0.3.0
31
+ grpcio==1.56.2
32
  h11==0.14.0
33
+ h5py==3.9.0
34
  httpcore==0.17.3
35
  httpx==0.24.1
36
  huggingface-hub==0.16.4
37
  idna==3.4
38
+ importlib-metadata==6.8.0
39
  importlib-resources==6.0.0
40
  Jinja2==3.1.2
41
  jsonschema==4.18.6
42
  jsonschema-specifications==2023.7.1
43
+ keras==2.13.1
44
  kiwisolver==1.4.4
45
+ libclang==16.0.6
46
  linkify-it-py==2.0.2
47
+ Markdown==3.4.4
48
  markdown-it-py==2.2.0
49
  MarkupSafe==2.1.3
50
  matplotlib==3.7.2
51
  mdit-py-plugins==0.3.3
52
  mdurl==0.1.2
53
  multidict==6.0.4
54
+ numpy==1.24.3
55
+ oauthlib==3.2.2
56
+ opt-einsum==3.3.0
57
  orjson==3.9.3
58
  packaging==23.1
59
  pandas==2.0.3
60
  Pillow==10.0.0
61
+ protobuf==4.24.0
62
+ pyasn1==0.5.0
63
+ pyasn1-modules==0.3.0
64
  pydantic==2.1.1
65
  pydantic_core==2.4.0
66
  pydub==0.25.1
 
71
  PyYAML==6.0.1
72
  referencing==0.30.2
73
  requests==2.31.0
74
+ requests-oauthlib==1.3.1
75
  rpds-py==0.9.2
76
+ rsa==4.9
77
  semantic-version==2.10.0
78
  six==1.16.0
79
  sniffio==1.3.0
80
  starlette==0.27.0
81
+ tensorflow==2.13.0
82
+ tensorboard==2.13.0
83
+ tensorboard-data-server==0.7.1
84
+ tensorflow-estimator==2.13.0
85
+ tensorflow-macos==2.13.0
86
+ termcolor==2.3.0
87
  toolz==0.12.0
88
  tqdm==4.65.0
89
+ typing_extensions==4.5.0
90
  tzdata==2023.3
91
  uc-micro-py==1.0.2
92
+ urllib3==1.26.16
93
  uvicorn==0.23.2
94
  websockets==11.0.3
95
+ Werkzeug==2.3.6
96
+ wrapt==1.15.0
97
  yarl==1.9.2
98
  zipp==3.16.2