Spaces:
Sleeping
Sleeping
narinsak unawong
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
import streamlit as st
|
3 |
import pickle
|
4 |
import pandas as pd
|
@@ -41,12 +40,14 @@ input_data['island'] = island_encoder.transform(input_data['island'])
|
|
41 |
input_data['sex'] = sex_encoder.transform(input_data['sex'])
|
42 |
|
43 |
# Ensure the columns are in the correct order
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
|
47 |
# Make prediction
|
48 |
prediction = model.predict(input_data)
|
49 |
|
50 |
# Show the result
|
51 |
st.write(f'Predicted Species: {species_encoder.inverse_transform(prediction)}')
|
52 |
-
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import pickle
|
3 |
import pandas as pd
|
|
|
40 |
input_data['sex'] = sex_encoder.transform(input_data['sex'])
|
41 |
|
42 |
# Ensure the columns are in the correct order
|
43 |
+
# Check if the model includes a ColumnTransformer and use it if available
|
44 |
+
if isinstance(model, Pipeline):
|
45 |
+
preprocessor = model.named_steps.get('preprocessor') # Replace with actual step name if different
|
46 |
+
if preprocessor:
|
47 |
+
input_data = preprocessor.transform(input_data) # Apply any necessary transformations
|
48 |
|
49 |
# Make prediction
|
50 |
prediction = model.predict(input_data)
|
51 |
|
52 |
# Show the result
|
53 |
st.write(f'Predicted Species: {species_encoder.inverse_transform(prediction)}')
|
|