yusufenes commited on
Commit
fb2cdea
·
verified ·
1 Parent(s): 621b68c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -54,8 +54,33 @@ def model_fit(X_train,y_train):
54
  hgb.fit(X_train,y_train)
55
  return hgb
56
 
57
- df,X_train,X_test,y_train,y_test = final_df(df)
58
- model = model_fit(X_train,y_train)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  import streamlit as st
61
 
@@ -74,8 +99,7 @@ def price(companyName,modelName,modelYear,locaiton,mileage,engineType,engineCapa
74
  'Transmission Type':[transmissionType],
75
  'Registration Status':[registrationStatus]
76
  })
77
- input_data = pd.get_dummies(input_data, drop_first=True)
78
- prediction=model.predict(input_data)[0]
79
  return prediction
80
  st.title('Car Price Prediction:car @yusufenes')
81
  st.write('Please Chose Car Specifications')
 
54
  hgb.fit(X_train,y_train)
55
  return hgb
56
 
57
+ from sklearn.compose import ColumnTransformer
58
+ from sklearn.pipeline import Pipeline
59
+ from sklearn.preprocessing import OneHotEncoder, StandardScaler
60
+
61
+ # define the preprocessing steps
62
+ categorical_features = ['Company Name', 'Model Name', 'Location', 'Engine Type', 'Color', 'Assembly', 'Body Type', 'Transmission Type', 'Registration Status']
63
+ numeric_features = ['Model Year', 'Mileage', 'Engine Capacity']
64
+
65
+ categorical_transformer = Pipeline(steps=[
66
+ ('onehot', OneHotEncoder(drop='if_binary', handle_unknown='ignore'))
67
+ ])
68
+
69
+ numeric_transformer = StandardScaler()
70
+
71
+ preprocessor = ColumnTransformer(
72
+ transformers=[
73
+ ('num', numeric_transformer, numeric_features),
74
+ ('cat', categorical_transformer, categorical_features)
75
+ ]
76
+ )
77
+
78
+ # create the pipeline
79
+ model = Pipeline(steps=[('preprocessor', preprocessor),
80
+ ('hgb', HistGradientBoostingRegressor())])
81
+
82
+ # fit the pipeline
83
+ model.fit(X_train, y_train)
84
 
85
  import streamlit as st
86
 
 
99
  'Transmission Type':[transmissionType],
100
  'Registration Status':[registrationStatus]
101
  })
102
+ prediction = model.predict(input_data)[0]
 
103
  return prediction
104
  st.title('Car Price Prediction:car @yusufenes')
105
  st.write('Please Chose Car Specifications')