Spaces:
Sleeping
Sleeping
Delete src
Browse files- src/label_encoder.pkl +0 -3
- src/lung_cancer_classifier.h5 +0 -3
- src/requirements.txt +0 -6
- src/streamlit_app.py +0 -76
src/label_encoder.pkl
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:71f60109d277dd7a7214745370e35402d31c5abdec368c7a7a259ee5bcc180be
|
| 3 |
-
size 351
|
|
|
|
|
|
|
|
|
|
|
|
src/lung_cancer_classifier.h5
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:7444437d2b7d73ef8de823a92a9dc2de6c7353ed30a71539c0352489869d0a74
|
| 3 |
-
size 64032
|
|
|
|
|
|
|
|
|
|
|
|
src/requirements.txt
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 1 |
-
streamlit
|
| 2 |
-
tensorflow
|
| 3 |
-
numpy
|
| 4 |
-
pandas
|
| 5 |
-
scikit-learn
|
| 6 |
-
joblib
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/streamlit_app.py
DELETED
|
@@ -1,76 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import numpy as np
|
| 3 |
-
import tensorflow as tf
|
| 4 |
-
import joblib
|
| 5 |
-
|
| 6 |
-
# --- Load model and label encoder ---
|
| 7 |
-
model = tf.keras.models.load_model("lung_cancer_classifier.h5") # Load H5 model
|
| 8 |
-
le_target = joblib.load("label_encoder.pkl")
|
| 9 |
-
|
| 10 |
-
# --- Page configuration ---
|
| 11 |
-
st.set_page_config(page_title="Lung Cancer Risk Classifier", layout="centered")
|
| 12 |
-
|
| 13 |
-
# --- Title and description ---
|
| 14 |
-
st.title("Lung Cancer Risk Prediction")
|
| 15 |
-
st.write("""
|
| 16 |
-
This application predicts the **level of lung cancer risk** for a patient.
|
| 17 |
-
**Note:** The data used to train this model consists of patients already diagnosed with lung cancer.
|
| 18 |
-
The target of this classification is the **Lung Cancer Level**.
|
| 19 |
-
""")
|
| 20 |
-
|
| 21 |
-
# --- Input fields ---
|
| 22 |
-
Age = st.number_input("Age", min_value=1, max_value=100, value=37)
|
| 23 |
-
|
| 24 |
-
# Gender dropdown fixed to show Male/Female but return encoded value
|
| 25 |
-
Gender = st.selectbox(
|
| 26 |
-
"Gender",
|
| 27 |
-
options=[("Male", 1), ("Female", 2)],
|
| 28 |
-
format_func=lambda x: x[0] # show only label
|
| 29 |
-
)[1] # get encoded value
|
| 30 |
-
|
| 31 |
-
Air_Pollution = st.slider("Air Pollution Exposure", 1, 8, 4)
|
| 32 |
-
Alcohol_use = st.slider("Alcohol Use", 1, 8, 5)
|
| 33 |
-
Dust_Allergy = st.slider("Dust Allergy", 1, 8, 5)
|
| 34 |
-
Occupational_Hazards = st.slider("Occupational Hazards", 1, 8, 5)
|
| 35 |
-
Genetic_Risk = st.slider("Genetic Risk", 1, 7, 5)
|
| 36 |
-
Chronic_Lung_Disease = st.slider("Chronic Lung Disease", 1, 7, 4)
|
| 37 |
-
Balanced_Diet = st.slider("Balanced Diet", 1, 7, 4)
|
| 38 |
-
Obesity = st.slider("Obesity", 1, 7, 4)
|
| 39 |
-
Smoking = st.slider("Smoking", 1, 8, 4)
|
| 40 |
-
Passive_Smoker = st.slider("Passive Smoker", 1, 8, 4)
|
| 41 |
-
Chest_Pain = st.slider("Chest Pain", 1, 9, 4)
|
| 42 |
-
Coughing_of_Blood = st.slider("Coughing of Blood", 1, 9, 4)
|
| 43 |
-
Fatigue = st.slider("Fatigue", 1, 9, 4)
|
| 44 |
-
Weight_Loss = st.slider("Weight Loss", 1, 8, 4)
|
| 45 |
-
Shortness_of_Breath = st.slider("Shortness of Breath", 1, 9, 4)
|
| 46 |
-
Wheezing = st.slider("Wheezing", 1, 8, 4)
|
| 47 |
-
Swallowing_Difficulty = st.slider("Swallowing Difficulty", 1, 8, 4)
|
| 48 |
-
Clubbing_of_Finger_Nails = st.slider("Clubbing of Finger Nails", 1, 9, 4)
|
| 49 |
-
Frequent_Cold = st.slider("Frequent Cold", 1, 7, 4)
|
| 50 |
-
Dry_Cough = st.slider("Dry Cough", 1, 7, 4)
|
| 51 |
-
Snoring = st.slider("Snoring", 1, 7, 3)
|
| 52 |
-
|
| 53 |
-
# --- Combine inputs ---
|
| 54 |
-
input_data = np.array([[
|
| 55 |
-
Age, Gender, Air_Pollution, Alcohol_use, Dust_Allergy,
|
| 56 |
-
Occupational_Hazards, Genetic_Risk, Chronic_Lung_Disease,
|
| 57 |
-
Balanced_Diet, Obesity, Smoking, Passive_Smoker,
|
| 58 |
-
Chest_Pain, Coughing_of_Blood, Fatigue, Weight_Loss,
|
| 59 |
-
Shortness_of_Breath, Wheezing, Swallowing_Difficulty,
|
| 60 |
-
Clubbing_of_Finger_Nails, Frequent_Cold, Dry_Cough, Snoring
|
| 61 |
-
]])
|
| 62 |
-
|
| 63 |
-
# --- Prediction ---
|
| 64 |
-
if st.button("Predict"):
|
| 65 |
-
prediction = model.predict(input_data)
|
| 66 |
-
predicted_class = prediction.argmax(axis=1)[0]
|
| 67 |
-
confidence = prediction.max(axis=1)[0]
|
| 68 |
-
|
| 69 |
-
label = le_target.inverse_transform([predicted_class])[0]
|
| 70 |
-
|
| 71 |
-
st.success(f"Predicted Lung Cancer Level: {label}")
|
| 72 |
-
st.info(f"Prediction Confidence: {confidence:.2%}")
|
| 73 |
-
|
| 74 |
-
# --- Footer ---
|
| 75 |
-
st.markdown("---")
|
| 76 |
-
st.markdown("**Train By:** Edcel Bogay")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|