Model does not responds to the changes in input

Ask the community or our support engineers for answers to questions.

Hello there!

I built a multi linear regression app to predict credit card balance, but model is showing a constant prediction even when the inputs are changed.

I have used @stcache and @st.cache(allow_output_mutation=True), but still facing the issue.

App link:

Github link:

App code:

import streamlit as st
import pandas as pd
import numpy as np
import as px
import pickle
from PIL import Image


def user_input_features(Income, Rating, Cards, Student):

    data = {'Income': [Income],'Rating': [Rating],'Cards': [Cards],'Student': [Student]}
    data = pd.DataFrame.from_dict(data)
    scalar = pickle.load(open('scaler_feature.pkl', 'rb')) 
    scaled_data = scalar.transform(data)
    X1 = pd.DataFrame(data=scaled_data, columns=data.columns)
    return X1

Income = st.number_input('Income')       
Rating = st.number_input('Rating')
Cards = st.number_input('Cards')
Student = st.selectbox('Please Enter Yes if you are student, otherwise No',('Yes','No'))
    #st.write('You selected:', Student)
if Student == 'Yes':
    Student = 1
elif Student == 'No':
    Student = 0

input_df = user_input_features(Income, Rating, Cards, Student)

filename = 'finalized_model.sav'
lm = pickle.load(open(filename, 'rb'))
pred = lm.predict(input_df)

   pred = -pred
st.subheader("The Average Predicted Balance is")

Thank you for your help!