Spaces:
Build error
Build error
decisionscience
commited on
Commit
•
207a615
1
Parent(s):
25940ca
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
# Load your trained model (or you can directly use the model if it's in the same script)
|
5 |
+
|
6 |
+
# Write a function to take user inputs
|
7 |
+
def user_input_features():
|
8 |
+
cylinders = st.sidebar.slider('Cylinders', 3, 8, 4)
|
9 |
+
displacement = st.sidebar.number_input('Displacement')
|
10 |
+
horsepower = st.sidebar.number_input('Horsepower')
|
11 |
+
weight = st.sidebar.number_input('Weight')
|
12 |
+
acceleration = st.sidebar.number_input('Acceleration')
|
13 |
+
model_year = st.sidebar.slider('Model Year', 70, 82, 76)
|
14 |
+
data = {'cylinders': cylinders,
|
15 |
+
'displacement': displacement,
|
16 |
+
'horsepower': horsepower,
|
17 |
+
'weight': weight,
|
18 |
+
'acceleration': acceleration,
|
19 |
+
'model_year': model_year}
|
20 |
+
features = pd.DataFrame(data, index=[0])
|
21 |
+
return features
|
22 |
+
|
23 |
+
# Main
|
24 |
+
st.write("""
|
25 |
+
# Simple MPG Prediction App
|
26 |
+
This app predicts the **Miles Per Gallon (MPG)** of your car!
|
27 |
+
""")
|
28 |
+
|
29 |
+
# User input features
|
30 |
+
input_df = user_input_features()
|
31 |
+
|
32 |
+
# Display the user input features
|
33 |
+
st.subheader('User Input features')
|
34 |
+
st.write(input_df)
|
35 |
+
|
36 |
+
# Predict and display the output
|
37 |
+
st.subheader('Prediction')
|
38 |
+
prediction = model.predict(input_df)
|
39 |
+
st.write(prediction)
|