Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- app.py +45 -0
- original.csv +0 -0
- predicted.csv +0 -0
- requirements.txt +65 -0
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
df_original = pd.read_csv('original.csv')
|
5 |
+
df_predicted = pd.read_csv('predicted.csv')
|
6 |
+
|
7 |
+
def load_examples():
|
8 |
+
st = []
|
9 |
+
for i in range(10):
|
10 |
+
st.append(';'.join(map(str, df_original.iloc[i])))
|
11 |
+
return st
|
12 |
+
|
13 |
+
examples = load_examples()
|
14 |
+
|
15 |
+
def check_equal(original,predicted):
|
16 |
+
percentage = 1
|
17 |
+
lower = original * (1 - percentage)
|
18 |
+
upper = original * (1 + percentage)
|
19 |
+
return (predicted >= lower and predicted <= upper)
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
def predict(user_game_time):
|
24 |
+
(user_id, game_name, time_played) = user_game_time.split(';')
|
25 |
+
|
26 |
+
user_id = int(user_id)
|
27 |
+
time_played_original = float(time_played)
|
28 |
+
|
29 |
+
# Search query
|
30 |
+
time_played_predicted = df_predicted[(df_predicted['user-id'] == user_id) & (df_predicted['game-title'] == game_name)].iloc[0,2]
|
31 |
+
# Check
|
32 |
+
right_predict = check_equal(time_played_original, time_played_predicted)
|
33 |
+
equal = "Equal" if right_predict else "Not Equal"
|
34 |
+
|
35 |
+
ans = f"Time original: {time_played_original}\n Time predicted: {time_played_predicted}\n They are equal: {equal}"
|
36 |
+
|
37 |
+
return ans
|
38 |
+
|
39 |
+
|
40 |
+
gr.Interface(
|
41 |
+
fn=predict,
|
42 |
+
inputs="text",
|
43 |
+
outputs="text",
|
44 |
+
examples=examples
|
45 |
+
).launch(share=False)
|
original.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
predicted.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
requirements.txt
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==23.2.1
|
2 |
+
altair==5.2.0
|
3 |
+
annotated-types==0.6.0
|
4 |
+
anyio==3.7.1
|
5 |
+
attrs==23.1.0
|
6 |
+
certifi==2023.11.17
|
7 |
+
charset-normalizer==3.3.2
|
8 |
+
click==8.1.7
|
9 |
+
colorama==0.4.6
|
10 |
+
contourpy==1.2.0
|
11 |
+
cycler==0.12.1
|
12 |
+
exceptiongroup==1.2.0
|
13 |
+
fastapi==0.104.1
|
14 |
+
ffmpy==0.3.1
|
15 |
+
filelock==3.13.1
|
16 |
+
fonttools==4.46.0
|
17 |
+
fsspec==2023.12.0
|
18 |
+
gradio==4.7.1
|
19 |
+
gradio_client==0.7.0
|
20 |
+
h11==0.14.0
|
21 |
+
httpcore==1.0.2
|
22 |
+
httpx==0.25.2
|
23 |
+
huggingface-hub==0.19.4
|
24 |
+
idna==3.6
|
25 |
+
importlib-resources==6.1.1
|
26 |
+
Jinja2==3.1.2
|
27 |
+
jsonschema==4.20.0
|
28 |
+
jsonschema-specifications==2023.11.2
|
29 |
+
kiwisolver==1.4.5
|
30 |
+
markdown-it-py==3.0.0
|
31 |
+
MarkupSafe==2.1.3
|
32 |
+
matplotlib==3.8.2
|
33 |
+
mdurl==0.1.2
|
34 |
+
numpy==1.26.2
|
35 |
+
orjson==3.9.10
|
36 |
+
packaging==23.2
|
37 |
+
pandas==2.1.3
|
38 |
+
Pillow==10.1.0
|
39 |
+
pydantic==2.5.2
|
40 |
+
pydantic_core==2.14.5
|
41 |
+
pydub==0.25.1
|
42 |
+
Pygments==2.17.2
|
43 |
+
pyparsing==3.1.1
|
44 |
+
python-dateutil==2.8.2
|
45 |
+
python-multipart==0.0.6
|
46 |
+
pytz==2023.3.post1
|
47 |
+
PyYAML==6.0.1
|
48 |
+
referencing==0.31.1
|
49 |
+
requests==2.31.0
|
50 |
+
rich==13.7.0
|
51 |
+
rpds-py==0.13.2
|
52 |
+
semantic-version==2.10.0
|
53 |
+
shellingham==1.5.4
|
54 |
+
six==1.16.0
|
55 |
+
sniffio==1.3.0
|
56 |
+
starlette==0.27.0
|
57 |
+
tomlkit==0.12.0
|
58 |
+
toolz==0.12.0
|
59 |
+
tqdm==4.66.1
|
60 |
+
typer==0.9.0
|
61 |
+
typing_extensions==4.8.0
|
62 |
+
tzdata==2023.3
|
63 |
+
urllib3==2.1.0
|
64 |
+
uvicorn==0.24.0.post1
|
65 |
+
websockets==11.0.3
|