Spaces:
Build error
Build error
decisionscience
commited on
Commit
•
2d64403
1
Parent(s):
207a615
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,28 @@
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
|
4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# Write a function to take user inputs
|
7 |
def user_input_features():
|
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
|
4 |
+
# Model
|
5 |
+
|
6 |
+
import seaborn as sns
|
7 |
+
import pandas as pd
|
8 |
+
from sklearn.model_selection import train_test_split
|
9 |
+
from sklearn.linear_model import LinearRegression
|
10 |
+
from sklearn.metrics import mean_squared_error, r2_score
|
11 |
+
|
12 |
+
# Load dataset
|
13 |
+
df = sns.load_dataset('mpg')
|
14 |
+
df.dropna(inplace=True) # Dropping missing values
|
15 |
+
|
16 |
+
# Selecting relevant features for simplicity
|
17 |
+
features = df[['cylinders', 'displacement', 'horsepower', 'weight', 'acceleration', 'model_year']]
|
18 |
+
target = df['mpg']
|
19 |
+
|
20 |
+
# Splitting the dataset into training and testing sets
|
21 |
+
X_train, X_test, y_train, y_test = train_test_split(features, target, test_size=0.2, random_state=42)
|
22 |
+
|
23 |
+
# Create and train the model
|
24 |
+
model = LinearRegression()
|
25 |
+
model.fit(X_train, y_train)
|
26 |
|
27 |
# Write a function to take user inputs
|
28 |
def user_input_features():
|