Upload 3 files
Browse files- app.py +34 -0
- requirements.txt +57 -0
- svm_model.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import pickle
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
with open('svm_model.pkl', 'rb') as f:
|
| 7 |
+
svm_model_pipeline = pickle.load(f)
|
| 8 |
+
|
| 9 |
+
def predict_purchase(Gender, Age, EstimatedSalary):
|
| 10 |
+
input_df = pd.DataFrame([[
|
| 11 |
+
Gender, Age, EstimatedSalary
|
| 12 |
+
]],
|
| 13 |
+
columns = [
|
| 14 |
+
'Gender', 'Age', 'EstimatedSalary'
|
| 15 |
+
])
|
| 16 |
+
|
| 17 |
+
prediction = svm_model_pipeline.predict(input_df)[0]
|
| 18 |
+
|
| 19 |
+
return "Purchased" if prediction == 1 else "Not Purchased"
|
| 20 |
+
|
| 21 |
+
inputs = [
|
| 22 |
+
gr.Radio(["Male", "Female"], label="Gender"),
|
| 23 |
+
gr.Number(label="Age"),
|
| 24 |
+
gr.Number(label="Estimated Salary")
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
app = gr.Interface(
|
| 28 |
+
fn = predict_purchase,
|
| 29 |
+
inputs = inputs,
|
| 30 |
+
outputs = "text",
|
| 31 |
+
title = "Social Network Ads Purchase Prediction"
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
app.launch(share=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==24.1.0
|
| 2 |
+
annotated-doc==0.0.4
|
| 3 |
+
annotated-types==0.7.0
|
| 4 |
+
anyio==4.12.1
|
| 5 |
+
audioop-lts==0.2.2
|
| 6 |
+
brotli==1.2.0
|
| 7 |
+
certifi==2026.1.4
|
| 8 |
+
click==8.3.1
|
| 9 |
+
colorama==0.4.6
|
| 10 |
+
fastapi==0.128.0
|
| 11 |
+
ffmpy==1.0.0
|
| 12 |
+
filelock==3.20.3
|
| 13 |
+
fsspec==2026.1.0
|
| 14 |
+
gradio==6.5.1
|
| 15 |
+
gradio_client==2.0.3
|
| 16 |
+
groovy==0.1.2
|
| 17 |
+
h11==0.16.0
|
| 18 |
+
hf-xet==1.2.0
|
| 19 |
+
httpcore==1.0.9
|
| 20 |
+
httpx==0.28.1
|
| 21 |
+
huggingface_hub==1.3.7
|
| 22 |
+
idna==3.11
|
| 23 |
+
Jinja2==3.1.6
|
| 24 |
+
joblib==1.5.3
|
| 25 |
+
markdown-it-py==4.0.0
|
| 26 |
+
MarkupSafe==3.0.3
|
| 27 |
+
mdurl==0.1.2
|
| 28 |
+
numpy==2.4.2
|
| 29 |
+
orjson==3.11.6
|
| 30 |
+
packaging==26.0
|
| 31 |
+
pandas==3.0.0
|
| 32 |
+
pillow==12.1.0
|
| 33 |
+
pydantic==2.12.5
|
| 34 |
+
pydantic_core==2.41.5
|
| 35 |
+
pydub==0.25.1
|
| 36 |
+
Pygments==2.19.2
|
| 37 |
+
python-dateutil==2.9.0.post0
|
| 38 |
+
python-multipart==0.0.22
|
| 39 |
+
pytz==2025.2
|
| 40 |
+
PyYAML==6.0.3
|
| 41 |
+
rich==14.3.2
|
| 42 |
+
safehttpx==0.1.7
|
| 43 |
+
scikit-learn==1.8.0
|
| 44 |
+
scipy==1.17.0
|
| 45 |
+
semantic-version==2.10.0
|
| 46 |
+
shellingham==1.5.4
|
| 47 |
+
six==1.17.0
|
| 48 |
+
starlette==0.50.0
|
| 49 |
+
threadpoolctl==3.6.0
|
| 50 |
+
tomlkit==0.13.3
|
| 51 |
+
tqdm==4.67.2
|
| 52 |
+
typer==0.21.1
|
| 53 |
+
typer-slim==0.21.1
|
| 54 |
+
typing-inspection==0.4.2
|
| 55 |
+
typing_extensions==4.15.0
|
| 56 |
+
tzdata==2025.3
|
| 57 |
+
uvicorn==0.40.0
|
svm_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:512a9607793cdfa88379d48d55c8dfedd5341b52e71cf2487c4820ec536348cb
|
| 3 |
+
size 8422
|