hilal35 commited on
Commit
491bcc2
1 Parent(s): 28ca5c0

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -89
app.py DELETED
@@ -1,89 +0,0 @@
1
- Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
2
- Type "help", "copyright", "credits" or "license()" for more information.
3
- #!/usr/bin/env python
4
- # coding: utf-8
5
-
6
- # # Araba Fiyatı Tahmin Eden Model ve Deployment
7
-
8
-
9
- #import libraries
10
- import pandas as pd
11
- from sklearn.model_selection import train_test_split
12
- from sklearn.linear_model import LinearRegression
13
- from sklearn.metrics import r2_score,mean_squared_error
14
- from sklearn.pipeline import Pipeline
15
- from sklearn.compose import ColumnTransformer
16
- from sklearn.preprocessing import StandardScaler,OneHotEncoder
17
-
18
-
19
-
20
- #Load data
21
- df=pd.read_excel('cars.xls')
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
- X=df.drop('Price',axis=1)
30
- y=df[['Price']]
31
-
32
-
33
-
34
- X_train,X_test,y_train,y_test=train_test_split(X,y,
35
- test_size=0.2,
36
- random_state=42)
37
-
38
-
39
-
40
-
41
- preproccer=ColumnTransformer(transformers=[('num',StandardScaler(),
42
- ['Mileage','Cylinder','Liter','Doors']),
43
- ('cat',OneHotEncoder(),['Make','Model','Trim','Type'])])
44
-
45
-
46
-
47
-
48
- model=LinearRegression()
49
- pipe=Pipeline(steps=[('preprocessor',preproccer),
50
- ('model',model)])
51
- pipe.fit(X_train,y_train)
52
- y_pred=pipe.predict(X_test)
53
- mean_squared_error(y_test,y_pred)**0.5,r2_score(y_test,y_pred)
54
-
55
- import streamlit as st
56
- def price(make,model,trim,mileage,car_type,cylinder,liter,doors,cruise,sound,leather):
57
- input_data=pd.DataFrame({
58
- 'Make':[make],
59
- 'Model':[model],
60
- 'Trim':[trim],
61
- 'Mileage':[mileage],
62
- 'Type':[car_type],
63
- 'Car_type':[car_type],
64
- 'Cylinder':[cylinder],
65
- 'Liter':[liter],
66
- 'Doors':[doors],
67
- 'Cruise':[cruise],
68
- 'Sound':[sound],
69
- 'Leather':[leather]
70
- })
71
- prediction=pipe.predict(input_data)[0]
72
- return prediction
73
- st.title("Araba Fiyatı Tahmin :red_car: @drmurataltun")
74
- st.write("Arabanın özelliklerini seçin")
75
- make=st.selectbox("Marka",df['Make'].unique())
76
- model=st.selectbox("Model",df[df['Make']==make]['Model'].unique())
77
- trim=st.selectbox("Trim",df[(df['Make']==make) & (df['Model']==model)]['Trim'].unique())
78
- mileage=st.number_input("Kilometre",200,60000)
79
- car_type=st.selectbox("Tipi",df[(df['Make']==make) & (df['Model']==model) & (df['Trim']==trim )]['Type'].unique())
80
- cylinder=st.selectbox("Silindir",df['Cylinder'].unique())
81
- liter=st.number_input("Liter",1,6)
82
- doors=st.selectbox("Kapı",df['Doors'].unique())
83
- cruise=st.radio("Hız S.",[True,False])
84
- sound=st.radio("Ses Sistemi",[True,False])
85
- leather=st.radio("Deri döşeme",[True,False])
86
- if st.button("Tahmin"):
87
- pred=price(make,model,trim,mileage,car_type,cylinder,liter,doors,cruise,sound,leather)
88
-
89
- st.write("11062024:Predicted Price :red_car: $",round(pred[0],2))