narinsak unawong commited on
Commit
533c469
·
verified ·
1 Parent(s): 1ea1fcd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import pickle
3
  import pandas as pd
4
  from sklearn.pipeline import Pipeline
 
5
 
6
  # Load the model and encoders
7
  with open('model_penguin_706.pkl', 'rb') as file:
@@ -41,6 +42,11 @@ input_data = pd.DataFrame({
41
  'culmen_depth_mm': [culmen_depth_mm]
42
  })
43
 
 
 
 
 
 
44
  # Apply encoding to categorical features (check column names here!)
45
  input_data['species'] = species_encoder.transform(input_data['species'])
46
  input_data['island'] = island_encoder.transform(input_data['island'])
 
2
  import pickle
3
  import pandas as pd
4
  from sklearn.pipeline import Pipeline
5
+ import numpy as np
6
 
7
  # Load the model and encoders
8
  with open('model_penguin_706.pkl', 'rb') as file:
 
42
  'culmen_depth_mm': [culmen_depth_mm]
43
  })
44
 
45
+ # Check for NaN values in the input data
46
+ if input_data.isna().any().any():
47
+ st.warning("Input data contains NaN values. Filling with default values.")
48
+ input_data = input_data.fillna(0) # Replace NaN values with 0 or appropriate value
49
+
50
  # Apply encoding to categorical features (check column names here!)
51
  input_data['species'] = species_encoder.transform(input_data['species'])
52
  input_data['island'] = island_encoder.transform(input_data['island'])