Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,6 @@ else:
|
|
23 |
column_trans = ColumnTransformer([('ohe', ohe_new, [0, 1, 4])], remainder='passthrough')
|
24 |
column_trans.fit(X_train)
|
25 |
|
26 |
-
if not hasattr(column_trans, '_name_to_fitted_passthrough'):
|
27 |
-
column_trans.fit(X_train)
|
28 |
-
|
29 |
# save the fitted ColumnTransformer object
|
30 |
with open('column_trans.pkl', 'wb') as f:
|
31 |
pickle.dump(column_trans, f)
|
@@ -52,11 +49,14 @@ if st.button('Click for car price'):
|
|
52 |
input_df = pd.DataFrame({'name': model_name, 'company':company_name, 'year': year,
|
53 |
'kms_driven':kms_driven, 'fuel_type': fuel_type}, index=[0])
|
54 |
|
|
|
|
|
|
|
55 |
# transform the input DataFrame using the fitted ColumnTransformer object
|
56 |
-
|
57 |
|
58 |
# make the prediction
|
59 |
-
prediction = pipe.predict(
|
60 |
|
61 |
if prediction <= 0:
|
62 |
st.write('The car is a scrap')
|
|
|
23 |
column_trans = ColumnTransformer([('ohe', ohe_new, [0, 1, 4])], remainder='passthrough')
|
24 |
column_trans.fit(X_train)
|
25 |
|
|
|
|
|
|
|
26 |
# save the fitted ColumnTransformer object
|
27 |
with open('column_trans.pkl', 'wb') as f:
|
28 |
pickle.dump(column_trans, f)
|
|
|
49 |
input_df = pd.DataFrame({'name': model_name, 'company':company_name, 'year': year,
|
50 |
'kms_driven':kms_driven, 'fuel_type': fuel_type}, index=[0])
|
51 |
|
52 |
+
# fit the ColumnTransformer object again on your data before using it to transform your input data
|
53 |
+
column_trans.fit(X_train)
|
54 |
+
|
55 |
# transform the input DataFrame using the fitted ColumnTransformer object
|
56 |
+
input_transformed = column_trans.transform(input_df)
|
57 |
|
58 |
# make the prediction
|
59 |
+
prediction = pipe.predict(input_transformed)
|
60 |
|
61 |
if prediction <= 0:
|
62 |
st.write('The car is a scrap')
|