File size: 2,125 Bytes
f4700e5
1360774
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8db06ae
1360774
fa4d2f5
 
 
1360774
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import streamlit as st
import joblib
from huggingface_hub import hf_hub_download
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.feature_selection import RFE

# Constants
MODEL_REPO = "thatblackfox/civil"
MODEL_FILE = "model.joblib"

# ==== Load Model with Caching ====
def load_model():
    model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE)
    model = joblib.load(model_path)
    return model

# ==== Streamlit UI ====
st.set_page_config(page_title="Backward Linear Regression", layout="centered")
st.title("Backward Linear Regression")
st.markdown("Please enter the values of each feature")

radius = st.number_input('RADIUS: ')
sentry = st.number_input('Speed @ Entry: ')
sexit  = st.number_input('Speed @ Exit : ')
ls = st.number_input('Ls: ')
tlength = st.number_input('Tan Length: ')
e = st.number_input('e: ')
sdistance = st.number_input('Sight distance: ')
dangle = st.number_input('D Angle: ')
total_width = st.number_input('Total width: ')
cw_width = st.number_input('CW Width: ')
lshoulder_width = st.number_input('Shoulder width (L) : ')
rshoulder_width  = st.number_input('Shoulder width (R) : ')
long_chord = st.number_input('Long Chord (Lc): ')
appex_distance = st.number_input('Appex Distance (Es): ')
mid_speed = st.number_input('Mid Speed: ')
pcu = st.number_input('PCU: ')

if st.button("Generate"):
    try:
        model = load_model()
        ins = { 'Speed @ Entry': [sentry],
                'e': [e],
                'Shoulder width (L) ': [lshoulder_width],
                'Shoulder width (R) ': [rshoulder_width],
                'Mid Speed': [mid_speed]}
        in_df = pd.DataFrame.from_dict(ins)
        predict = model.predict(in_df)
        # ==== Display Output ====
        st.success("✅ Prediction generated successfully!")
        st.write("### **Predicted Value:**")
        st.metric(label="Model Output", value=round(predict[0], 3))

        # # Optional: Show input summary
        # with st.expander("Show Input Data"):
        #     st.dataframe(in_df)

    except Exception as err:
        st.error(f"⚠️ Error: {err}")