File size: 1,680 Bytes
fc85fa5 |
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 |
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 6 09:56:29 2023
@author: HP
"""
import numpy as np
import pickle
import streamlit as st
# loading the saved model
#loaded_model = pickle.load(open('medical_insurance_cost_predictor.sav', 'rb'))
loaded_model = pickle.load(open('medical_insurance_cost_predictor.h5', 'rb'))
#creating a function for Prediction
def medical_insurance_cost_prediction(input_data):
# changing the input_data to numpy array
input_data_as_numpy_array = np.asarray(input_data)
# reshape the array as we are predicting for one instance
input_data_reshaped = input_data_as_numpy_array.reshape(1,-1)
prediction = loaded_model.predict(input_data_reshaped)
print(prediction)
return prediction
def main():
#giving a title
#st.title('Medical Insurance Prediction Web App')
st.title('It is working!!!')
#getting input from the user
age = st.text_input('Age')
sex = st.text_input('Sex: 0 -> Female, 1 -> Male')
bmi = st.text_input('Body Mass Index')
children = st.text_input('Number of Children')
smoker = st.text_input('Smoker: 0 -> No, 1 -> Yes')
region = st.text_input('Region of Living: 0 -> NorthEast, 1-> NorthWest, 2-> SouthEast, 3-> SouthWest')
#code for prediction
diagnosis = ''
# getting the input data from the user
#if st.button('Predicted Medical Insurance Cost: '):
if st.button('Hit this button!: '):
diagnosis = medical_insurance_cost_prediction([age,sex,bmi,children,smoker,region])
st.success(diagnosis)
if __name__ == '__main__':
main()
|