jagruthh commited on
Commit
7c5fedc
·
verified ·
1 Parent(s): f9805ea

Upload 9 files

Browse files
Files changed (9) hide show
  1. .DS_Store +0 -0
  2. .gitattributes +2 -35
  3. Procfile +1 -0
  4. README.md +58 -13
  5. __pycache__/app.cpython-37.pyc +0 -0
  6. app.py +54 -0
  7. model.pkl +0 -0
  8. static/css/styles.css +65 -0
  9. templates/home.html +215 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
.gitattributes CHANGED
@@ -1,35 +1,2 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: gunicorn app:app
README.md CHANGED
@@ -1,13 +1,58 @@
1
- ---
2
- title: UsedCarPrice
3
- emoji: 📉
4
- colorFrom: gray
5
- colorTo: yellow
6
- sdk: gradio
7
- sdk_version: 4.21.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # used-car-price-predictor
2
+ Programmed an ML model
3
+ ## Table of Content
4
+ * [Demo](#demo)
5
+ * [Overview](#overview)
6
+ * [Local Setup](#local-setup)
7
+ * [Directory Tree](#directory-tree)
8
+
9
+
10
+ ## Demo
11
+ Link: [https://ask-car-price.herokuapp.com](https://ask-car-price.herokuapp.com)
12
+
13
+ [![](https://i.imgur.com/Dynlly3.png)](https://ask-car-price.herokuapp.com)
14
+
15
+ [![](https://i.imgur.com/GqErsg7.png)](https://ask-car-price.herokuapp.com)
16
+
17
+ ## Overview
18
+ This is a Flask web app which predicts the selling price of a car using multiple linear regression model made by me and my friend [Nishith](https://github.com/Nishith-Reddy)
19
+
20
+ Dataset: [![](https://www.kaggle.com/datasets/nehalbirla/vehicle-dataset-from-cardekho)](https://www.kaggle.com/datasets/nehalbirla/vehicle-dataset-from-cardekho)
21
+
22
+ ## Local Setup
23
+ Clone the repository on your local environment <br>
24
+
25
+ ```bash
26
+ git clone https://github.com/Nishith-Reddy/Ml_Car_Price_Prediction
27
+ ```
28
+ Navigate to the folder <br>
29
+ ```bash
30
+ cd ML_Car_Price_Prediction
31
+ ```
32
+ Install the required dependencies <br>
33
+ ```bash
34
+ pip install -r requirements.txt
35
+ ```
36
+ Run the localhost-server <br>
37
+ ```bash
38
+ flask run
39
+ ```
40
+ The web-app will be available at `127.0.0.1:5000` on your browser.
41
+ ## Directory Tree
42
+ ```
43
+ ├── Procfile
44
+ ├── app
45
+ │ ├── main.py
46
+ │ ├── static
47
+ │ │ └── css
48
+ │ │ └── styles.css
49
+ │ └── templates
50
+ │ └── home.html
51
+ ├── model.pkl
52
+ ├── requirements.txt
53
+ ├── runtime.txt
54
+ └── wsgi.py
55
+ ```
56
+ ## Technologies Used
57
+ ![](https://forthebadge.com/images/badges/made-with-python.svg)
58
+ [<img target="_blank" src="https://flask.palletsprojects.com/en/1.1.x/_images/flask-logo.png" width=170>](https://flask.palletsprojects.com/en/1.1.x/) [<img target="_blank" src="https://number1.co.za/wp-content/uploads/2017/10/gunicorn_logo-300x85.png" width=280>](https://gunicorn.org) [<img target="_blank" src="https://scikit-learn.org/stable/_static/scikit-learn-logo-small.png" width=200>](https://scikit-learn.org/stable/)
__pycache__/app.cpython-37.pyc ADDED
Binary file (1.37 kB). View file
 
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, render_template
2
+ from flask_cors import cross_origin
3
+ import sklearn
4
+ import pickle
5
+ import pandas as pd
6
+ import numpy as np
7
+
8
+ app = Flask(__name__)
9
+ model = pickle.load(open("model.pkl", "rb"))
10
+
11
+
12
+ @app.route("/")
13
+ @cross_origin()
14
+ def home():
15
+ return render_template("home.html")
16
+
17
+
18
+
19
+
20
+ @app.route("/predict", methods = ["GET", "POST"])
21
+ @cross_origin()
22
+ def predict():
23
+ if request.method == "POST":
24
+ y_min = 1992
25
+ y_max = 2020
26
+ km_min = 1
27
+ km_max = 170000
28
+
29
+ brand = int(request.form['brand'])
30
+ fuel = int(request.form['fuel'])
31
+ transmission = int(request.form['transmission'])
32
+ seller_type = int(request.form['seller_type'])
33
+ owner = int(request.form['owner'])
34
+ km_driven = int(request.form["km_driven"])
35
+ year = int(request.form["yearinput"])
36
+
37
+ year = (year - y_min)/(y_max-y_min)
38
+ km_driven = (km_driven - km_min)/(km_max-km_min)
39
+ t = [year,km_driven,transmission,fuel,seller_type,brand,owner]
40
+ test = np.array(t).reshape(1, 7)
41
+
42
+ prediction=model.predict(test)
43
+
44
+ output=round(prediction[0],2)
45
+ return render_template('home.html',prediction_text="Your car price is Rs. {}".format(abs(output)))
46
+
47
+
48
+ return render_template("home.html")
49
+
50
+
51
+
52
+
53
+ if __name__ == "__main__":
54
+ app.run(debug=True)
model.pkl ADDED
Binary file (897 Bytes). View file
 
static/css/styles.css ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ * {
2
+ font-family: 'Fira Sans', sans-serif;
3
+ }
4
+ body {
5
+ background-color: #393c41;
6
+ text-align: center;
7
+ }
8
+
9
+
10
+ .navbar {
11
+ background-color: #313741;
12
+ }
13
+
14
+ a {
15
+ color: #00ADB5;
16
+ font-weight: 500;
17
+
18
+
19
+ }
20
+
21
+ a:hover {
22
+ color: #EEEEEE;
23
+ transition: all 2 s ease;
24
+
25
+ }
26
+
27
+ .navbar-brand {
28
+ font-size: 1.5rem;
29
+ }
30
+
31
+ .card {
32
+ background-color: #EEEEEE;
33
+ }
34
+
35
+ .btn-secondary {
36
+ border: none;
37
+ width: 10rem;
38
+ background-color: #00ADB5;
39
+ }
40
+
41
+ .btn-secondary:hover {
42
+ color: #00ADB5;
43
+ background-color: #222831;
44
+ transition: all 0.5s ease;
45
+ }
46
+
47
+ .card {
48
+ border-radius: 0.8em;
49
+ }
50
+
51
+ .card-body {
52
+ padding: 3rem;
53
+ }
54
+
55
+ .output {
56
+ color: #00ADB5;
57
+ }
58
+
59
+ select {
60
+ width: 10rem;
61
+ text-align: center;
62
+ margin-left: 10px;
63
+ }
64
+
65
+
templates/home.html ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html lang="en">
2
+
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Car Price Predictor</title>
7
+
8
+
9
+ <!-- BootStrap -->
10
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
11
+ integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
12
+
13
+
14
+ <!-- css -->
15
+ <link rel="stylesheet" href="/static/css/styles.css">
16
+ <link rel="preconnect" href="https://fonts.googleapis.com">
17
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
18
+ <link href="https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,100;0,400;0,500;1,100;1,400&display=swap" rel="stylesheet">
19
+
20
+ </head>
21
+
22
+ <body>
23
+
24
+ <!-- As a heading -->
25
+ <nav class="navbar navbar-inverse navbar-fixed-top">
26
+ <div class="container-fluid">
27
+ <div class="navbar-header">
28
+ <a class="navbar-brand" href="#">Car Price Predictor</a>
29
+ </div>
30
+ </div>
31
+ </nav>
32
+
33
+ <div class="container">
34
+
35
+
36
+
37
+ <form action="\predict" method="post">
38
+ <br>
39
+ <br>
40
+ <div class="row">
41
+ <div class="col-sm-6">
42
+ <div class="card">
43
+ <div class="card-body">
44
+ <!-- Brand -->
45
+ <h5 class="card-title">Brand</h5>
46
+ <select name="brand" id="brand" required="required">
47
+ <option value="18">Maruti</option>
48
+ <option value="10">Hyundai</option>
49
+ <option value="5">Datsun</option>
50
+ <option value="9">Honda</option>
51
+ <option value="25">Tata</option>
52
+ <option value="3">Chevrolet</option>
53
+ <option value="26">Toyota</option>
54
+ <option value="12">Jaguar</option>
55
+ <option value="19">Mercedes-Benz</option>
56
+ <option value="1">Audi</option>
57
+ <option value="24">Skoda</option>
58
+ <option value="13">Jeep</option>
59
+ <option value="2">BMW</option>
60
+ <option value="17">Mahindra</option>
61
+ <option value="8">Ford</option>
62
+ <option value="21">Nissan</option>
63
+ <option value="23">Renault</option>
64
+ <option value="6">Fiat</option>
65
+ <option value="27">Volkswagen</option>
66
+ <option value="28">Volvo</option>
67
+ <option value="20">Mitsubishi</option>
68
+ <option value="15">Land</option>
69
+ <option value="4">Daewoo</option>
70
+ <option value="16">MG</option>
71
+ <option value="7">Force</option>
72
+ <option value="11">Isuzu</option>
73
+ <option value="22">OpelCorsa</option>
74
+ <option value="0">Ambassador</option>
75
+ <option value="14">Kia</option>
76
+ </select>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ <br>
81
+ <br>
82
+ <br>
83
+ <div class="col-sm-6">
84
+ <div class="card">
85
+ <div class="card-body">
86
+ <h5 class="card-title">Year</h5> <!--year-->
87
+ <input type="range" name="year" id="year" min="1850" max="2050" value="1850" oninput="this.form.yearinput.value=this.value" />
88
+ <input type="number" name="yearinput" id="yearinput" min="1850" max="2050" value="1850" oninput="this.form.year.value=this.value" />
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </div>
93
+
94
+ <br>
95
+ <br>
96
+ <br>
97
+
98
+ <div class="row">
99
+ <div class="col-sm-6">
100
+ <div class="card">
101
+ <div class="card-body">
102
+ <!-- km_driven -->
103
+ <h5 class="card-title">Km Driven</h5>
104
+ <input type="number" name="km_driven" id="km_driven" min="0"/>
105
+ </div>
106
+ </div>
107
+ </div>
108
+ <div class="col-sm-6">
109
+ <div class="card">
110
+ <div class="card-body">
111
+ <h5 class="card-title">Fuel</h5>
112
+ <!-- Fuel -->
113
+ <select name="fuel" id="fuel" required="required">
114
+ <option value="4">Petrol</option>
115
+ <option value="1">Diesel</option>
116
+ <option value="0">CNG</option>
117
+ <option value="3">LPG</option>
118
+ <option value="2">Electric</option>
119
+ </select>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ </div>
124
+
125
+
126
+
127
+ <br>
128
+ <br>
129
+ <br>
130
+
131
+ <div class="row">
132
+ <div class="col-sm-6">
133
+ <div class="card">
134
+ <div class="card-body">
135
+ <h5 class="card-title">Transmission </h5>
136
+ <!-- Transmission -->
137
+ <select name="transmission" id = "transmission" required="required">
138
+ <option value="1">Manual</option>
139
+ <option value="0">Automatic</option>
140
+ </select>
141
+ </div>
142
+ </div>
143
+ </div>
144
+ <div class="col-sm-6">
145
+ <div class="card">
146
+ <div class="card-body">
147
+ <h5 class="card-title">Seller Type</h5>
148
+ <!-- seller_type -->
149
+ <select name="seller_type" id="seller_type" required="required">
150
+ <option value="2">Individual</option>
151
+ <option value="1">Dealer</option>
152
+ <option value="0">Trustmark Dealer </option>
153
+ </select>
154
+ </div>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ <br>
159
+ <br>
160
+ <br>
161
+
162
+ <div class="row">
163
+ <div class="col-sm-6">
164
+ <div class="card">
165
+ <div class="card-body">
166
+ <h5 class="card-title">Owner</h5>
167
+ <!-- owner -->
168
+ <select name="owner" id="owner" required="required">
169
+ <option value="0">Test Drive Car</option>
170
+ <option value="1">First Owner</option>
171
+ <option value="2">Second Owner</option>
172
+ <option value="3">Third Owner</option>
173
+ <option value="4">Fourth & Above Owner</option>
174
+
175
+ </select>
176
+ </div>
177
+ </div>
178
+ </div>
179
+ </div>
180
+
181
+
182
+ <br>
183
+ <br>
184
+ <br>
185
+ <!-- Submit -->
186
+ <input type="submit" value="Submit" class="btn btn-secondary">
187
+ </form>
188
+
189
+ <br>
190
+ <br>
191
+ <h3 class = 'output'>{{ prediction_text }}</h3>
192
+
193
+ <br>
194
+ <br>
195
+
196
+
197
+ </div>
198
+
199
+
200
+
201
+
202
+ <!-- JavaScript -->
203
+ <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
204
+ integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
205
+ crossorigin="anonymous"></script>
206
+ <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
207
+ integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
208
+ crossorigin="anonymous"></script>
209
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
210
+ integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
211
+ crossorigin="anonymous"></script>
212
+
213
+ </body>
214
+
215
+ </html>