Upload 3 files
Browse files- app.py +78 -0
- requirements.txt +11 -0
- svm.joblib +3 -0
app.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from joblib import load
|
| 3 |
+
|
| 4 |
+
# Load model
|
| 5 |
+
Model = load('svm.joblib')
|
| 6 |
+
|
| 7 |
+
# Prediction function
|
| 8 |
+
def predict_note_authentication(values):
|
| 9 |
+
prediction = Model.predict([values])
|
| 10 |
+
return prediction[0]
|
| 11 |
+
|
| 12 |
+
def main():
|
| 13 |
+
st.title("Mobile Price Classification ML App")
|
| 14 |
+
st.markdown("""
|
| 15 |
+
<div style="background-color:tomato;padding:10px">
|
| 16 |
+
<h2 style="color:white;text-align:center;">Predict the Price Range of a Mobile</h2>
|
| 17 |
+
</div>
|
| 18 |
+
""", unsafe_allow_html=True)
|
| 19 |
+
|
| 20 |
+
# Collect inputs
|
| 21 |
+
battery_power = st.number_input('Battery Power (mAh)', min_value=500, max_value=2000, step=10)
|
| 22 |
+
|
| 23 |
+
colour = st.selectbox('Colour', ['Blue', 'Other'])
|
| 24 |
+
colour = 1 if colour == 'Blue' else 0
|
| 25 |
+
|
| 26 |
+
clock_speed = st.number_input('Clock Speed (GHz)', min_value=0.5, max_value=3.0, step=0.1)
|
| 27 |
+
|
| 28 |
+
sim = st.selectbox('SIM Option', ['Dual', 'Single'])
|
| 29 |
+
sim = 1 if sim == 'Dual' else 0
|
| 30 |
+
|
| 31 |
+
front_camera = st.number_input('Front Camera Resolution (MP)', min_value=0, max_value=20, step=1)
|
| 32 |
+
|
| 33 |
+
network_4G = st.selectbox('Network (4G)', ['yes', 'no'])
|
| 34 |
+
four_g = 1 if network_4G == '4G' else 0
|
| 35 |
+
|
| 36 |
+
network_3G = st.selectbox('Network (3G)', ['yes', 'no'])
|
| 37 |
+
three_g = 1 if network_3G == '3G' else 0
|
| 38 |
+
|
| 39 |
+
int_memory = st.number_input('Internal Memory (GB)', min_value=2, max_value=64, step=1)
|
| 40 |
+
|
| 41 |
+
mobile_depth = st.selectbox('Mobile Depth (cm)', [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
|
| 42 |
+
|
| 43 |
+
mobile_wt = st.number_input('Mobile Weight (grams)', min_value=80, max_value=200, step=1)
|
| 44 |
+
|
| 45 |
+
n_cores = st.selectbox('Number of Cores', [1, 2, 3, 4, 5, 6, 7, 8])
|
| 46 |
+
|
| 47 |
+
primary_camera = st.number_input('Primary Camera Resolution (MP)', min_value=0, max_value=20, step=1)
|
| 48 |
+
|
| 49 |
+
px_height = st.number_input('Screen Pixel Height', min_value=0, max_value=2000, step=10)
|
| 50 |
+
px_width = st.number_input('Screen Pixel Width', min_value=100, max_value=2000, step=10)
|
| 51 |
+
|
| 52 |
+
ram = st.number_input('RAM (MB)', min_value=256, max_value=4000, step=10)
|
| 53 |
+
|
| 54 |
+
screen_height = st.number_input('Screen Height (cm)', min_value=0, max_value=20, step=1)
|
| 55 |
+
screen_width = st.number_input('Screen Width (cm)', min_value=0, max_value=20, step=1)
|
| 56 |
+
|
| 57 |
+
talk_time = st.number_input('Talk Time (hours)', min_value=1, max_value=20, step=1)
|
| 58 |
+
|
| 59 |
+
touch_screen = st.selectbox('Touch Screen', ['Yes', 'No'])
|
| 60 |
+
touch_screen = 1 if touch_screen == 'Yes' else 0
|
| 61 |
+
|
| 62 |
+
wifi = st.selectbox('Wi-Fi Support', ['Yes', 'No'])
|
| 63 |
+
wifi = 1 if wifi == 'Yes' else 0
|
| 64 |
+
|
| 65 |
+
# Prepare input for the model
|
| 66 |
+
values = [
|
| 67 |
+
battery_power, colour, clock_speed, sim, front_camera, four_g, int_memory, mobile_depth, mobile_wt,
|
| 68 |
+
n_cores, primary_camera, px_height, px_width, ram, screen_height, screen_width, talk_time, three_g,
|
| 69 |
+
touch_screen, wifi
|
| 70 |
+
]
|
| 71 |
+
|
| 72 |
+
# Predict and display result
|
| 73 |
+
if st.button("Predict"):
|
| 74 |
+
result = predict_note_authentication(values)
|
| 75 |
+
st.success(f'Predicted Price Class: {result}')
|
| 76 |
+
|
| 77 |
+
if __name__ == "__main__":
|
| 78 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
joblib==1.3.2
|
| 2 |
+
matplotlib==3.8.3
|
| 3 |
+
matplotlib-inline==0.1.6
|
| 4 |
+
numpy==1.26.4
|
| 5 |
+
pandas==2.2.
|
| 6 |
+
scikit-learn==1.4.1.post1
|
| 7 |
+
seaborn==0.13.2
|
| 8 |
+
stack-data==0.6.3
|
| 9 |
+
streamlit==1.32.2
|
| 10 |
+
streamlit-chat==0.1.1
|
| 11 |
+
|
svm.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:65d3310193cb50dd365b92f14959ce9553c7fb5829159f691e6b51110b7e2d5a
|
| 3 |
+
size 146981
|