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"from sklearn.model_selection import train_test_split\n",
|
11 |
+
"from sklearn.linear_model import LinearRegression\n",
|
12 |
+
"from sklearn.metrics import r2_score,mean_squared_error\n",
|
13 |
+
"from sklearn.compose import ColumnTransformer\n",
|
14 |
+
"from sklearn.preprocessing import StandardScaler,OneHotEncoder\n",
|
15 |
+
"from sklearn.pipeline import Pipeline\n"
|
16 |
+
]
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"cell_type": "code",
|
20 |
+
"execution_count": 2,
|
21 |
+
"metadata": {},
|
22 |
+
"outputs": [
|
23 |
+
{
|
24 |
+
"name": "stdout",
|
25 |
+
"output_type": "stream",
|
26 |
+
"text": [
|
27 |
+
"Requirement already satisfied: xlrd in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (2.0.1)\n",
|
28 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
29 |
+
]
|
30 |
+
}
|
31 |
+
],
|
32 |
+
"source": [
|
33 |
+
"pip install xlrd"
|
34 |
+
]
|
35 |
+
},
|
36 |
+
{
|
37 |
+
"cell_type": "code",
|
38 |
+
"execution_count": 3,
|
39 |
+
"metadata": {},
|
40 |
+
"outputs": [
|
41 |
+
{
|
42 |
+
"data": {
|
43 |
+
"text/html": [
|
44 |
+
"<div>\n",
|
45 |
+
"<style scoped>\n",
|
46 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
47 |
+
" vertical-align: middle;\n",
|
48 |
+
" }\n",
|
49 |
+
"\n",
|
50 |
+
" .dataframe tbody tr th {\n",
|
51 |
+
" vertical-align: top;\n",
|
52 |
+
" }\n",
|
53 |
+
"\n",
|
54 |
+
" .dataframe thead th {\n",
|
55 |
+
" text-align: right;\n",
|
56 |
+
" }\n",
|
57 |
+
"</style>\n",
|
58 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
59 |
+
" <thead>\n",
|
60 |
+
" <tr style=\"text-align: right;\">\n",
|
61 |
+
" <th></th>\n",
|
62 |
+
" <th>Price</th>\n",
|
63 |
+
" <th>Mileage</th>\n",
|
64 |
+
" <th>Make</th>\n",
|
65 |
+
" <th>Model</th>\n",
|
66 |
+
" <th>Trim</th>\n",
|
67 |
+
" <th>Type</th>\n",
|
68 |
+
" <th>Cylinder</th>\n",
|
69 |
+
" <th>Liter</th>\n",
|
70 |
+
" <th>Doors</th>\n",
|
71 |
+
" <th>Cruise</th>\n",
|
72 |
+
" <th>Sound</th>\n",
|
73 |
+
" <th>Leather</th>\n",
|
74 |
+
" </tr>\n",
|
75 |
+
" </thead>\n",
|
76 |
+
" <tbody>\n",
|
77 |
+
" <tr>\n",
|
78 |
+
" <th>0</th>\n",
|
79 |
+
" <td>17314.103129</td>\n",
|
80 |
+
" <td>8221</td>\n",
|
81 |
+
" <td>Buick</td>\n",
|
82 |
+
" <td>Century</td>\n",
|
83 |
+
" <td>Sedan 4D</td>\n",
|
84 |
+
" <td>Sedan</td>\n",
|
85 |
+
" <td>6</td>\n",
|
86 |
+
" <td>3.1</td>\n",
|
87 |
+
" <td>4</td>\n",
|
88 |
+
" <td>1</td>\n",
|
89 |
+
" <td>1</td>\n",
|
90 |
+
" <td>1</td>\n",
|
91 |
+
" </tr>\n",
|
92 |
+
" <tr>\n",
|
93 |
+
" <th>1</th>\n",
|
94 |
+
" <td>17542.036083</td>\n",
|
95 |
+
" <td>9135</td>\n",
|
96 |
+
" <td>Buick</td>\n",
|
97 |
+
" <td>Century</td>\n",
|
98 |
+
" <td>Sedan 4D</td>\n",
|
99 |
+
" <td>Sedan</td>\n",
|
100 |
+
" <td>6</td>\n",
|
101 |
+
" <td>3.1</td>\n",
|
102 |
+
" <td>4</td>\n",
|
103 |
+
" <td>1</td>\n",
|
104 |
+
" <td>1</td>\n",
|
105 |
+
" <td>0</td>\n",
|
106 |
+
" </tr>\n",
|
107 |
+
" <tr>\n",
|
108 |
+
" <th>2</th>\n",
|
109 |
+
" <td>16218.847862</td>\n",
|
110 |
+
" <td>13196</td>\n",
|
111 |
+
" <td>Buick</td>\n",
|
112 |
+
" <td>Century</td>\n",
|
113 |
+
" <td>Sedan 4D</td>\n",
|
114 |
+
" <td>Sedan</td>\n",
|
115 |
+
" <td>6</td>\n",
|
116 |
+
" <td>3.1</td>\n",
|
117 |
+
" <td>4</td>\n",
|
118 |
+
" <td>1</td>\n",
|
119 |
+
" <td>1</td>\n",
|
120 |
+
" <td>0</td>\n",
|
121 |
+
" </tr>\n",
|
122 |
+
" <tr>\n",
|
123 |
+
" <th>3</th>\n",
|
124 |
+
" <td>16336.913140</td>\n",
|
125 |
+
" <td>16342</td>\n",
|
126 |
+
" <td>Buick</td>\n",
|
127 |
+
" <td>Century</td>\n",
|
128 |
+
" <td>Sedan 4D</td>\n",
|
129 |
+
" <td>Sedan</td>\n",
|
130 |
+
" <td>6</td>\n",
|
131 |
+
" <td>3.1</td>\n",
|
132 |
+
" <td>4</td>\n",
|
133 |
+
" <td>1</td>\n",
|
134 |
+
" <td>0</td>\n",
|
135 |
+
" <td>0</td>\n",
|
136 |
+
" </tr>\n",
|
137 |
+
" <tr>\n",
|
138 |
+
" <th>4</th>\n",
|
139 |
+
" <td>16339.170324</td>\n",
|
140 |
+
" <td>19832</td>\n",
|
141 |
+
" <td>Buick</td>\n",
|
142 |
+
" <td>Century</td>\n",
|
143 |
+
" <td>Sedan 4D</td>\n",
|
144 |
+
" <td>Sedan</td>\n",
|
145 |
+
" <td>6</td>\n",
|
146 |
+
" <td>3.1</td>\n",
|
147 |
+
" <td>4</td>\n",
|
148 |
+
" <td>1</td>\n",
|
149 |
+
" <td>0</td>\n",
|
150 |
+
" <td>1</td>\n",
|
151 |
+
" </tr>\n",
|
152 |
+
" <tr>\n",
|
153 |
+
" <th>...</th>\n",
|
154 |
+
" <td>...</td>\n",
|
155 |
+
" <td>...</td>\n",
|
156 |
+
" <td>...</td>\n",
|
157 |
+
" <td>...</td>\n",
|
158 |
+
" <td>...</td>\n",
|
159 |
+
" <td>...</td>\n",
|
160 |
+
" <td>...</td>\n",
|
161 |
+
" <td>...</td>\n",
|
162 |
+
" <td>...</td>\n",
|
163 |
+
" <td>...</td>\n",
|
164 |
+
" <td>...</td>\n",
|
165 |
+
" <td>...</td>\n",
|
166 |
+
" </tr>\n",
|
167 |
+
" <tr>\n",
|
168 |
+
" <th>799</th>\n",
|
169 |
+
" <td>16507.070267</td>\n",
|
170 |
+
" <td>16229</td>\n",
|
171 |
+
" <td>Saturn</td>\n",
|
172 |
+
" <td>L Series</td>\n",
|
173 |
+
" <td>L300 Sedan 4D</td>\n",
|
174 |
+
" <td>Sedan</td>\n",
|
175 |
+
" <td>6</td>\n",
|
176 |
+
" <td>3.0</td>\n",
|
177 |
+
" <td>4</td>\n",
|
178 |
+
" <td>1</td>\n",
|
179 |
+
" <td>0</td>\n",
|
180 |
+
" <td>0</td>\n",
|
181 |
+
" </tr>\n",
|
182 |
+
" <tr>\n",
|
183 |
+
" <th>800</th>\n",
|
184 |
+
" <td>16175.957604</td>\n",
|
185 |
+
" <td>19095</td>\n",
|
186 |
+
" <td>Saturn</td>\n",
|
187 |
+
" <td>L Series</td>\n",
|
188 |
+
" <td>L300 Sedan 4D</td>\n",
|
189 |
+
" <td>Sedan</td>\n",
|
190 |
+
" <td>6</td>\n",
|
191 |
+
" <td>3.0</td>\n",
|
192 |
+
" <td>4</td>\n",
|
193 |
+
" <td>1</td>\n",
|
194 |
+
" <td>1</td>\n",
|
195 |
+
" <td>0</td>\n",
|
196 |
+
" </tr>\n",
|
197 |
+
" <tr>\n",
|
198 |
+
" <th>801</th>\n",
|
199 |
+
" <td>15731.132897</td>\n",
|
200 |
+
" <td>20484</td>\n",
|
201 |
+
" <td>Saturn</td>\n",
|
202 |
+
" <td>L Series</td>\n",
|
203 |
+
" <td>L300 Sedan 4D</td>\n",
|
204 |
+
" <td>Sedan</td>\n",
|
205 |
+
" <td>6</td>\n",
|
206 |
+
" <td>3.0</td>\n",
|
207 |
+
" <td>4</td>\n",
|
208 |
+
" <td>1</td>\n",
|
209 |
+
" <td>1</td>\n",
|
210 |
+
" <td>0</td>\n",
|
211 |
+
" </tr>\n",
|
212 |
+
" <tr>\n",
|
213 |
+
" <th>802</th>\n",
|
214 |
+
" <td>15118.893228</td>\n",
|
215 |
+
" <td>25979</td>\n",
|
216 |
+
" <td>Saturn</td>\n",
|
217 |
+
" <td>L Series</td>\n",
|
218 |
+
" <td>L300 Sedan 4D</td>\n",
|
219 |
+
" <td>Sedan</td>\n",
|
220 |
+
" <td>6</td>\n",
|
221 |
+
" <td>3.0</td>\n",
|
222 |
+
" <td>4</td>\n",
|
223 |
+
" <td>1</td>\n",
|
224 |
+
" <td>1</td>\n",
|
225 |
+
" <td>0</td>\n",
|
226 |
+
" </tr>\n",
|
227 |
+
" <tr>\n",
|
228 |
+
" <th>803</th>\n",
|
229 |
+
" <td>13585.636802</td>\n",
|
230 |
+
" <td>35662</td>\n",
|
231 |
+
" <td>Saturn</td>\n",
|
232 |
+
" <td>L Series</td>\n",
|
233 |
+
" <td>L300 Sedan 4D</td>\n",
|
234 |
+
" <td>Sedan</td>\n",
|
235 |
+
" <td>6</td>\n",
|
236 |
+
" <td>3.0</td>\n",
|
237 |
+
" <td>4</td>\n",
|
238 |
+
" <td>1</td>\n",
|
239 |
+
" <td>0</td>\n",
|
240 |
+
" <td>0</td>\n",
|
241 |
+
" </tr>\n",
|
242 |
+
" </tbody>\n",
|
243 |
+
"</table>\n",
|
244 |
+
"<p>804 rows × 12 columns</p>\n",
|
245 |
+
"</div>"
|
246 |
+
],
|
247 |
+
"text/plain": [
|
248 |
+
" Price Mileage Make Model Trim Type Cylinder \\\n",
|
249 |
+
"0 17314.103129 8221 Buick Century Sedan 4D Sedan 6 \n",
|
250 |
+
"1 17542.036083 9135 Buick Century Sedan 4D Sedan 6 \n",
|
251 |
+
"2 16218.847862 13196 Buick Century Sedan 4D Sedan 6 \n",
|
252 |
+
"3 16336.913140 16342 Buick Century Sedan 4D Sedan 6 \n",
|
253 |
+
"4 16339.170324 19832 Buick Century Sedan 4D Sedan 6 \n",
|
254 |
+
".. ... ... ... ... ... ... ... \n",
|
255 |
+
"799 16507.070267 16229 Saturn L Series L300 Sedan 4D Sedan 6 \n",
|
256 |
+
"800 16175.957604 19095 Saturn L Series L300 Sedan 4D Sedan 6 \n",
|
257 |
+
"801 15731.132897 20484 Saturn L Series L300 Sedan 4D Sedan 6 \n",
|
258 |
+
"802 15118.893228 25979 Saturn L Series L300 Sedan 4D Sedan 6 \n",
|
259 |
+
"803 13585.636802 35662 Saturn L Series L300 Sedan 4D Sedan 6 \n",
|
260 |
+
"\n",
|
261 |
+
" Liter Doors Cruise Sound Leather \n",
|
262 |
+
"0 3.1 4 1 1 1 \n",
|
263 |
+
"1 3.1 4 1 1 0 \n",
|
264 |
+
"2 3.1 4 1 1 0 \n",
|
265 |
+
"3 3.1 4 1 0 0 \n",
|
266 |
+
"4 3.1 4 1 0 1 \n",
|
267 |
+
".. ... ... ... ... ... \n",
|
268 |
+
"799 3.0 4 1 0 0 \n",
|
269 |
+
"800 3.0 4 1 1 0 \n",
|
270 |
+
"801 3.0 4 1 1 0 \n",
|
271 |
+
"802 3.0 4 1 1 0 \n",
|
272 |
+
"803 3.0 4 1 0 0 \n",
|
273 |
+
"\n",
|
274 |
+
"[804 rows x 12 columns]"
|
275 |
+
]
|
276 |
+
},
|
277 |
+
"execution_count": 3,
|
278 |
+
"metadata": {},
|
279 |
+
"output_type": "execute_result"
|
280 |
+
}
|
281 |
+
],
|
282 |
+
"source": [
|
283 |
+
"df=pd.read_excel(\"cars.xls\")\n",
|
284 |
+
"df"
|
285 |
+
]
|
286 |
+
},
|
287 |
+
{
|
288 |
+
"cell_type": "code",
|
289 |
+
"execution_count": 4,
|
290 |
+
"metadata": {},
|
291 |
+
"outputs": [],
|
292 |
+
"source": [
|
293 |
+
"X=df.drop(\"Price\",axis=1)\n",
|
294 |
+
"y=df[\"Price\"]"
|
295 |
+
]
|
296 |
+
},
|
297 |
+
{
|
298 |
+
"cell_type": "code",
|
299 |
+
"execution_count": 5,
|
300 |
+
"metadata": {},
|
301 |
+
"outputs": [],
|
302 |
+
"source": [
|
303 |
+
"X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2,random_state=42)"
|
304 |
+
]
|
305 |
+
},
|
306 |
+
{
|
307 |
+
"cell_type": "code",
|
308 |
+
"execution_count": 14,
|
309 |
+
"metadata": {},
|
310 |
+
"outputs": [
|
311 |
+
{
|
312 |
+
"data": {
|
313 |
+
"text/html": [
|
314 |
+
"<div>\n",
|
315 |
+
"<style scoped>\n",
|
316 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
317 |
+
" vertical-align: middle;\n",
|
318 |
+
" }\n",
|
319 |
+
"\n",
|
320 |
+
" .dataframe tbody tr th {\n",
|
321 |
+
" vertical-align: top;\n",
|
322 |
+
" }\n",
|
323 |
+
"\n",
|
324 |
+
" .dataframe thead th {\n",
|
325 |
+
" text-align: right;\n",
|
326 |
+
" }\n",
|
327 |
+
"</style>\n",
|
328 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
329 |
+
" <thead>\n",
|
330 |
+
" <tr style=\"text-align: right;\">\n",
|
331 |
+
" <th></th>\n",
|
332 |
+
" <th>Mileage</th>\n",
|
333 |
+
" <th>Make</th>\n",
|
334 |
+
" <th>Model</th>\n",
|
335 |
+
" <th>Trim</th>\n",
|
336 |
+
" <th>Type</th>\n",
|
337 |
+
" <th>Cylinder</th>\n",
|
338 |
+
" <th>Liter</th>\n",
|
339 |
+
" <th>Doors</th>\n",
|
340 |
+
" <th>Cruise</th>\n",
|
341 |
+
" <th>Sound</th>\n",
|
342 |
+
" <th>Leather</th>\n",
|
343 |
+
" </tr>\n",
|
344 |
+
" </thead>\n",
|
345 |
+
" <tbody>\n",
|
346 |
+
" <tr>\n",
|
347 |
+
" <th>344</th>\n",
|
348 |
+
" <td>20000</td>\n",
|
349 |
+
" <td>Chevrolet</td>\n",
|
350 |
+
" <td>Corvette</td>\n",
|
351 |
+
" <td>Conv 2D</td>\n",
|
352 |
+
" <td>Convertible</td>\n",
|
353 |
+
" <td>8</td>\n",
|
354 |
+
" <td>6.0</td>\n",
|
355 |
+
" <td>2</td>\n",
|
356 |
+
" <td>1</td>\n",
|
357 |
+
" <td>0</td>\n",
|
358 |
+
" <td>1</td>\n",
|
359 |
+
" </tr>\n",
|
360 |
+
" <tr>\n",
|
361 |
+
" <th>350</th>\n",
|
362 |
+
" <td>7054</td>\n",
|
363 |
+
" <td>Chevrolet</td>\n",
|
364 |
+
" <td>Corvette</td>\n",
|
365 |
+
" <td>Coupe 2D</td>\n",
|
366 |
+
" <td>Coupe</td>\n",
|
367 |
+
" <td>8</td>\n",
|
368 |
+
" <td>6.0</td>\n",
|
369 |
+
" <td>2</td>\n",
|
370 |
+
" <td>1</td>\n",
|
371 |
+
" <td>0</td>\n",
|
372 |
+
" <td>1</td>\n",
|
373 |
+
" </tr>\n",
|
374 |
+
" <tr>\n",
|
375 |
+
" <th>443</th>\n",
|
376 |
+
" <td>15903</td>\n",
|
377 |
+
" <td>Chevrolet</td>\n",
|
378 |
+
" <td>Malibu</td>\n",
|
379 |
+
" <td>Sedan 4D</td>\n",
|
380 |
+
" <td>Sedan</td>\n",
|
381 |
+
" <td>6</td>\n",
|
382 |
+
" <td>3.5</td>\n",
|
383 |
+
" <td>4</td>\n",
|
384 |
+
" <td>0</td>\n",
|
385 |
+
" <td>1</td>\n",
|
386 |
+
" <td>1</td>\n",
|
387 |
+
" </tr>\n",
|
388 |
+
" <tr>\n",
|
389 |
+
" <th>331</th>\n",
|
390 |
+
" <td>6709</td>\n",
|
391 |
+
" <td>Chevrolet</td>\n",
|
392 |
+
" <td>Cobalt</td>\n",
|
393 |
+
" <td>Sedan 4D</td>\n",
|
394 |
+
" <td>Sedan</td>\n",
|
395 |
+
" <td>4</td>\n",
|
396 |
+
" <td>2.2</td>\n",
|
397 |
+
" <td>4</td>\n",
|
398 |
+
" <td>1</td>\n",
|
399 |
+
" <td>1</td>\n",
|
400 |
+
" <td>1</td>\n",
|
401 |
+
" </tr>\n",
|
402 |
+
" <tr>\n",
|
403 |
+
" <th>290</th>\n",
|
404 |
+
" <td>13776</td>\n",
|
405 |
+
" <td>Chevrolet</td>\n",
|
406 |
+
" <td>Cobalt</td>\n",
|
407 |
+
" <td>Coupe 2D</td>\n",
|
408 |
+
" <td>Coupe</td>\n",
|
409 |
+
" <td>4</td>\n",
|
410 |
+
" <td>2.2</td>\n",
|
411 |
+
" <td>2</td>\n",
|
412 |
+
" <td>0</td>\n",
|
413 |
+
" <td>1</td>\n",
|
414 |
+
" <td>1</td>\n",
|
415 |
+
" </tr>\n",
|
416 |
+
" <tr>\n",
|
417 |
+
" <th>...</th>\n",
|
418 |
+
" <td>...</td>\n",
|
419 |
+
" <td>...</td>\n",
|
420 |
+
" <td>...</td>\n",
|
421 |
+
" <td>...</td>\n",
|
422 |
+
" <td>...</td>\n",
|
423 |
+
" <td>...</td>\n",
|
424 |
+
" <td>...</td>\n",
|
425 |
+
" <td>...</td>\n",
|
426 |
+
" <td>...</td>\n",
|
427 |
+
" <td>...</td>\n",
|
428 |
+
" <td>...</td>\n",
|
429 |
+
" </tr>\n",
|
430 |
+
" <tr>\n",
|
431 |
+
" <th>71</th>\n",
|
432 |
+
" <td>9795</td>\n",
|
433 |
+
" <td>Buick</td>\n",
|
434 |
+
" <td>Park Avenue</td>\n",
|
435 |
+
" <td>Special Ed Ultra 4D</td>\n",
|
436 |
+
" <td>Sedan</td>\n",
|
437 |
+
" <td>6</td>\n",
|
438 |
+
" <td>3.8</td>\n",
|
439 |
+
" <td>4</td>\n",
|
440 |
+
" <td>1</td>\n",
|
441 |
+
" <td>1</td>\n",
|
442 |
+
" <td>0</td>\n",
|
443 |
+
" </tr>\n",
|
444 |
+
" <tr>\n",
|
445 |
+
" <th>106</th>\n",
|
446 |
+
" <td>24415</td>\n",
|
447 |
+
" <td>Cadillac</td>\n",
|
448 |
+
" <td>Deville</td>\n",
|
449 |
+
" <td>DHS Sedan 4D</td>\n",
|
450 |
+
" <td>Sedan</td>\n",
|
451 |
+
" <td>8</td>\n",
|
452 |
+
" <td>4.6</td>\n",
|
453 |
+
" <td>4</td>\n",
|
454 |
+
" <td>1</td>\n",
|
455 |
+
" <td>1</td>\n",
|
456 |
+
" <td>1</td>\n",
|
457 |
+
" </tr>\n",
|
458 |
+
" <tr>\n",
|
459 |
+
" <th>270</th>\n",
|
460 |
+
" <td>4922</td>\n",
|
461 |
+
" <td>Chevrolet</td>\n",
|
462 |
+
" <td>Cavalier</td>\n",
|
463 |
+
" <td>Sedan 4D</td>\n",
|
464 |
+
" <td>Sedan</td>\n",
|
465 |
+
" <td>4</td>\n",
|
466 |
+
" <td>2.2</td>\n",
|
467 |
+
" <td>4</td>\n",
|
468 |
+
" <td>0</td>\n",
|
469 |
+
" <td>1</td>\n",
|
470 |
+
" <td>1</td>\n",
|
471 |
+
" </tr>\n",
|
472 |
+
" <tr>\n",
|
473 |
+
" <th>435</th>\n",
|
474 |
+
" <td>18721</td>\n",
|
475 |
+
" <td>Chevrolet</td>\n",
|
476 |
+
" <td>Malibu</td>\n",
|
477 |
+
" <td>MAXX Hback 4D</td>\n",
|
478 |
+
" <td>Hatchback</td>\n",
|
479 |
+
" <td>6</td>\n",
|
480 |
+
" <td>3.5</td>\n",
|
481 |
+
" <td>4</td>\n",
|
482 |
+
" <td>0</td>\n",
|
483 |
+
" <td>1</td>\n",
|
484 |
+
" <td>1</td>\n",
|
485 |
+
" </tr>\n",
|
486 |
+
" <tr>\n",
|
487 |
+
" <th>102</th>\n",
|
488 |
+
" <td>16041</td>\n",
|
489 |
+
" <td>Cadillac</td>\n",
|
490 |
+
" <td>Deville</td>\n",
|
491 |
+
" <td>DHS Sedan 4D</td>\n",
|
492 |
+
" <td>Sedan</td>\n",
|
493 |
+
" <td>8</td>\n",
|
494 |
+
" <td>4.6</td>\n",
|
495 |
+
" <td>4</td>\n",
|
496 |
+
" <td>1</td>\n",
|
497 |
+
" <td>0</td>\n",
|
498 |
+
" <td>1</td>\n",
|
499 |
+
" </tr>\n",
|
500 |
+
" </tbody>\n",
|
501 |
+
"</table>\n",
|
502 |
+
"<p>643 rows × 11 columns</p>\n",
|
503 |
+
"</div>"
|
504 |
+
],
|
505 |
+
"text/plain": [
|
506 |
+
" Mileage Make Model Trim Type \\\n",
|
507 |
+
"344 20000 Chevrolet Corvette Conv 2D Convertible \n",
|
508 |
+
"350 7054 Chevrolet Corvette Coupe 2D Coupe \n",
|
509 |
+
"443 15903 Chevrolet Malibu Sedan 4D Sedan \n",
|
510 |
+
"331 6709 Chevrolet Cobalt Sedan 4D Sedan \n",
|
511 |
+
"290 13776 Chevrolet Cobalt Coupe 2D Coupe \n",
|
512 |
+
".. ... ... ... ... ... \n",
|
513 |
+
"71 9795 Buick Park Avenue Special Ed Ultra 4D Sedan \n",
|
514 |
+
"106 24415 Cadillac Deville DHS Sedan 4D Sedan \n",
|
515 |
+
"270 4922 Chevrolet Cavalier Sedan 4D Sedan \n",
|
516 |
+
"435 18721 Chevrolet Malibu MAXX Hback 4D Hatchback \n",
|
517 |
+
"102 16041 Cadillac Deville DHS Sedan 4D Sedan \n",
|
518 |
+
"\n",
|
519 |
+
" Cylinder Liter Doors Cruise Sound Leather \n",
|
520 |
+
"344 8 6.0 2 1 0 1 \n",
|
521 |
+
"350 8 6.0 2 1 0 1 \n",
|
522 |
+
"443 6 3.5 4 0 1 1 \n",
|
523 |
+
"331 4 2.2 4 1 1 1 \n",
|
524 |
+
"290 4 2.2 2 0 1 1 \n",
|
525 |
+
".. ... ... ... ... ... ... \n",
|
526 |
+
"71 6 3.8 4 1 1 0 \n",
|
527 |
+
"106 8 4.6 4 1 1 1 \n",
|
528 |
+
"270 4 2.2 4 0 1 1 \n",
|
529 |
+
"435 6 3.5 4 0 1 1 \n",
|
530 |
+
"102 8 4.6 4 1 0 1 \n",
|
531 |
+
"\n",
|
532 |
+
"[643 rows x 11 columns]"
|
533 |
+
]
|
534 |
+
},
|
535 |
+
"execution_count": 14,
|
536 |
+
"metadata": {},
|
537 |
+
"output_type": "execute_result"
|
538 |
+
}
|
539 |
+
],
|
540 |
+
"source": [
|
541 |
+
"X_train"
|
542 |
+
]
|
543 |
+
},
|
544 |
+
{
|
545 |
+
"cell_type": "code",
|
546 |
+
"execution_count": 15,
|
547 |
+
"metadata": {},
|
548 |
+
"outputs": [
|
549 |
+
{
|
550 |
+
"data": {
|
551 |
+
"text/html": [
|
552 |
+
"<div>\n",
|
553 |
+
"<style scoped>\n",
|
554 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
555 |
+
" vertical-align: middle;\n",
|
556 |
+
" }\n",
|
557 |
+
"\n",
|
558 |
+
" .dataframe tbody tr th {\n",
|
559 |
+
" vertical-align: top;\n",
|
560 |
+
" }\n",
|
561 |
+
"\n",
|
562 |
+
" .dataframe thead th {\n",
|
563 |
+
" text-align: right;\n",
|
564 |
+
" }\n",
|
565 |
+
"</style>\n",
|
566 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
567 |
+
" <thead>\n",
|
568 |
+
" <tr style=\"text-align: right;\">\n",
|
569 |
+
" <th></th>\n",
|
570 |
+
" <th>Mileage</th>\n",
|
571 |
+
" <th>Make</th>\n",
|
572 |
+
" <th>Model</th>\n",
|
573 |
+
" <th>Trim</th>\n",
|
574 |
+
" <th>Type</th>\n",
|
575 |
+
" <th>Cylinder</th>\n",
|
576 |
+
" <th>Liter</th>\n",
|
577 |
+
" <th>Doors</th>\n",
|
578 |
+
" <th>Cruise</th>\n",
|
579 |
+
" <th>Sound</th>\n",
|
580 |
+
" <th>Leather</th>\n",
|
581 |
+
" </tr>\n",
|
582 |
+
" </thead>\n",
|
583 |
+
" <tbody>\n",
|
584 |
+
" <tr>\n",
|
585 |
+
" <th>192</th>\n",
|
586 |
+
" <td>14627</td>\n",
|
587 |
+
" <td>Chevrolet</td>\n",
|
588 |
+
" <td>AVEO</td>\n",
|
589 |
+
" <td>LT Sedan 4D</td>\n",
|
590 |
+
" <td>Sedan</td>\n",
|
591 |
+
" <td>4</td>\n",
|
592 |
+
" <td>1.6</td>\n",
|
593 |
+
" <td>4</td>\n",
|
594 |
+
" <td>0</td>\n",
|
595 |
+
" <td>1</td>\n",
|
596 |
+
" <td>0</td>\n",
|
597 |
+
" </tr>\n",
|
598 |
+
" <tr>\n",
|
599 |
+
" <th>717</th>\n",
|
600 |
+
" <td>21960</td>\n",
|
601 |
+
" <td>SAAB</td>\n",
|
602 |
+
" <td>9_5</td>\n",
|
603 |
+
" <td>Linear Wagon 4D</td>\n",
|
604 |
+
" <td>Wagon</td>\n",
|
605 |
+
" <td>4</td>\n",
|
606 |
+
" <td>2.3</td>\n",
|
607 |
+
" <td>4</td>\n",
|
608 |
+
" <td>1</td>\n",
|
609 |
+
" <td>0</td>\n",
|
610 |
+
" <td>1</td>\n",
|
611 |
+
" </tr>\n",
|
612 |
+
" <tr>\n",
|
613 |
+
" <th>168</th>\n",
|
614 |
+
" <td>27906</td>\n",
|
615 |
+
" <td>Chevrolet</td>\n",
|
616 |
+
" <td>AVEO</td>\n",
|
617 |
+
" <td>LS Hatchback 4D</td>\n",
|
618 |
+
" <td>Hatchback</td>\n",
|
619 |
+
" <td>4</td>\n",
|
620 |
+
" <td>1.6</td>\n",
|
621 |
+
" <td>4</td>\n",
|
622 |
+
" <td>0</td>\n",
|
623 |
+
" <td>0</td>\n",
|
624 |
+
" <td>0</td>\n",
|
625 |
+
" </tr>\n",
|
626 |
+
" <tr>\n",
|
627 |
+
" <th>522</th>\n",
|
628 |
+
" <td>11204</td>\n",
|
629 |
+
" <td>Pontiac</td>\n",
|
630 |
+
" <td>G6</td>\n",
|
631 |
+
" <td>Sedan 4D</td>\n",
|
632 |
+
" <td>Sedan</td>\n",
|
633 |
+
" <td>6</td>\n",
|
634 |
+
" <td>3.5</td>\n",
|
635 |
+
" <td>4</td>\n",
|
636 |
+
" <td>1</td>\n",
|
637 |
+
" <td>1</td>\n",
|
638 |
+
" <td>0</td>\n",
|
639 |
+
" </tr>\n",
|
640 |
+
" <tr>\n",
|
641 |
+
" <th>536</th>\n",
|
642 |
+
" <td>20917</td>\n",
|
643 |
+
" <td>Pontiac</td>\n",
|
644 |
+
" <td>Grand Am</td>\n",
|
645 |
+
" <td>GT Coupe 2D</td>\n",
|
646 |
+
" <td>Coupe</td>\n",
|
647 |
+
" <td>6</td>\n",
|
648 |
+
" <td>3.4</td>\n",
|
649 |
+
" <td>2</td>\n",
|
650 |
+
" <td>1</td>\n",
|
651 |
+
" <td>1</td>\n",
|
652 |
+
" <td>1</td>\n",
|
653 |
+
" </tr>\n",
|
654 |
+
" <tr>\n",
|
655 |
+
" <th>...</th>\n",
|
656 |
+
" <td>...</td>\n",
|
657 |
+
" <td>...</td>\n",
|
658 |
+
" <td>...</td>\n",
|
659 |
+
" <td>...</td>\n",
|
660 |
+
" <td>...</td>\n",
|
661 |
+
" <td>...</td>\n",
|
662 |
+
" <td>...</td>\n",
|
663 |
+
" <td>...</td>\n",
|
664 |
+
" <td>...</td>\n",
|
665 |
+
" <td>...</td>\n",
|
666 |
+
" <td>...</td>\n",
|
667 |
+
" </tr>\n",
|
668 |
+
" <tr>\n",
|
669 |
+
" <th>658</th>\n",
|
670 |
+
" <td>31655</td>\n",
|
671 |
+
" <td>SAAB</td>\n",
|
672 |
+
" <td>9_3 HO</td>\n",
|
673 |
+
" <td>Aero Conv 2D</td>\n",
|
674 |
+
" <td>Convertible</td>\n",
|
675 |
+
" <td>4</td>\n",
|
676 |
+
" <td>2.0</td>\n",
|
677 |
+
" <td>2</td>\n",
|
678 |
+
" <td>1</td>\n",
|
679 |
+
" <td>1</td>\n",
|
680 |
+
" <td>1</td>\n",
|
681 |
+
" </tr>\n",
|
682 |
+
" <tr>\n",
|
683 |
+
" <th>356</th>\n",
|
684 |
+
" <td>22740</td>\n",
|
685 |
+
" <td>Chevrolet</td>\n",
|
686 |
+
" <td>Corvette</td>\n",
|
687 |
+
" <td>Coupe 2D</td>\n",
|
688 |
+
" <td>Coupe</td>\n",
|
689 |
+
" <td>8</td>\n",
|
690 |
+
" <td>6.0</td>\n",
|
691 |
+
" <td>2</td>\n",
|
692 |
+
" <td>1</td>\n",
|
693 |
+
" <td>0</td>\n",
|
694 |
+
" <td>1</td>\n",
|
695 |
+
" </tr>\n",
|
696 |
+
" <tr>\n",
|
697 |
+
" <th>525</th>\n",
|
698 |
+
" <td>21702</td>\n",
|
699 |
+
" <td>Pontiac</td>\n",
|
700 |
+
" <td>G6</td>\n",
|
701 |
+
" <td>Sedan 4D</td>\n",
|
702 |
+
" <td>Sedan</td>\n",
|
703 |
+
" <td>6</td>\n",
|
704 |
+
" <td>3.5</td>\n",
|
705 |
+
" <td>4</td>\n",
|
706 |
+
" <td>1</td>\n",
|
707 |
+
" <td>0</td>\n",
|
708 |
+
" <td>0</td>\n",
|
709 |
+
" </tr>\n",
|
710 |
+
" <tr>\n",
|
711 |
+
" <th>748</th>\n",
|
712 |
+
" <td>14376</td>\n",
|
713 |
+
" <td>Saturn</td>\n",
|
714 |
+
" <td>Ion</td>\n",
|
715 |
+
" <td>Quad Coupe 2D</td>\n",
|
716 |
+
" <td>Coupe</td>\n",
|
717 |
+
" <td>4</td>\n",
|
718 |
+
" <td>2.2</td>\n",
|
719 |
+
" <td>2</td>\n",
|
720 |
+
" <td>0</td>\n",
|
721 |
+
" <td>0</td>\n",
|
722 |
+
" <td>0</td>\n",
|
723 |
+
" </tr>\n",
|
724 |
+
" <tr>\n",
|
725 |
+
" <th>517</th>\n",
|
726 |
+
" <td>26477</td>\n",
|
727 |
+
" <td>Pontiac</td>\n",
|
728 |
+
" <td>G6</td>\n",
|
729 |
+
" <td>GT Sedan 4D</td>\n",
|
730 |
+
" <td>Sedan</td>\n",
|
731 |
+
" <td>6</td>\n",
|
732 |
+
" <td>3.5</td>\n",
|
733 |
+
" <td>4</td>\n",
|
734 |
+
" <td>1</td>\n",
|
735 |
+
" <td>0</td>\n",
|
736 |
+
" <td>1</td>\n",
|
737 |
+
" </tr>\n",
|
738 |
+
" </tbody>\n",
|
739 |
+
"</table>\n",
|
740 |
+
"<p>161 rows × 11 columns</p>\n",
|
741 |
+
"</div>"
|
742 |
+
],
|
743 |
+
"text/plain": [
|
744 |
+
" Mileage Make Model Trim Type Cylinder \\\n",
|
745 |
+
"192 14627 Chevrolet AVEO LT Sedan 4D Sedan 4 \n",
|
746 |
+
"717 21960 SAAB 9_5 Linear Wagon 4D Wagon 4 \n",
|
747 |
+
"168 27906 Chevrolet AVEO LS Hatchback 4D Hatchback 4 \n",
|
748 |
+
"522 11204 Pontiac G6 Sedan 4D Sedan 6 \n",
|
749 |
+
"536 20917 Pontiac Grand Am GT Coupe 2D Coupe 6 \n",
|
750 |
+
".. ... ... ... ... ... ... \n",
|
751 |
+
"658 31655 SAAB 9_3 HO Aero Conv 2D Convertible 4 \n",
|
752 |
+
"356 22740 Chevrolet Corvette Coupe 2D Coupe 8 \n",
|
753 |
+
"525 21702 Pontiac G6 Sedan 4D Sedan 6 \n",
|
754 |
+
"748 14376 Saturn Ion Quad Coupe 2D Coupe 4 \n",
|
755 |
+
"517 26477 Pontiac G6 GT Sedan 4D Sedan 6 \n",
|
756 |
+
"\n",
|
757 |
+
" Liter Doors Cruise Sound Leather \n",
|
758 |
+
"192 1.6 4 0 1 0 \n",
|
759 |
+
"717 2.3 4 1 0 1 \n",
|
760 |
+
"168 1.6 4 0 0 0 \n",
|
761 |
+
"522 3.5 4 1 1 0 \n",
|
762 |
+
"536 3.4 2 1 1 1 \n",
|
763 |
+
".. ... ... ... ... ... \n",
|
764 |
+
"658 2.0 2 1 1 1 \n",
|
765 |
+
"356 6.0 2 1 0 1 \n",
|
766 |
+
"525 3.5 4 1 0 0 \n",
|
767 |
+
"748 2.2 2 0 0 0 \n",
|
768 |
+
"517 3.5 4 1 0 1 \n",
|
769 |
+
"\n",
|
770 |
+
"[161 rows x 11 columns]"
|
771 |
+
]
|
772 |
+
},
|
773 |
+
"execution_count": 15,
|
774 |
+
"metadata": {},
|
775 |
+
"output_type": "execute_result"
|
776 |
+
}
|
777 |
+
],
|
778 |
+
"source": [
|
779 |
+
"X_test"
|
780 |
+
]
|
781 |
+
},
|
782 |
+
{
|
783 |
+
"cell_type": "code",
|
784 |
+
"execution_count": 16,
|
785 |
+
"metadata": {},
|
786 |
+
"outputs": [
|
787 |
+
{
|
788 |
+
"name": "stdout",
|
789 |
+
"output_type": "stream",
|
790 |
+
"text": [
|
791 |
+
"Best params: {'colsample_bytree': 0.5, 'learning_rate': 0.09, 'max_depth': 6, 'n_estimators': 200}\n"
|
792 |
+
]
|
793 |
+
}
|
794 |
+
],
|
795 |
+
"source": [
|
796 |
+
"best_params = \"{'colsample_bytree': 0.5, 'learning_rate': 0.09, 'max_depth': 6, 'n_estimators': 200}\"\n",
|
797 |
+
"print(\"Best params: \",best_params)"
|
798 |
+
]
|
799 |
+
},
|
800 |
+
{
|
801 |
+
"cell_type": "code",
|
802 |
+
"execution_count": 6,
|
803 |
+
"metadata": {},
|
804 |
+
"outputs": [
|
805 |
+
{
|
806 |
+
"name": "stdout",
|
807 |
+
"output_type": "stream",
|
808 |
+
"text": [
|
809 |
+
"RMSE 835.1013862206736\n",
|
810 |
+
"R2 0.9912072687898575\n"
|
811 |
+
]
|
812 |
+
}
|
813 |
+
],
|
814 |
+
"source": [
|
815 |
+
"\n",
|
816 |
+
"preprocess=ColumnTransformer(\n",
|
817 |
+
" transformers=[\n",
|
818 |
+
" ('num',StandardScaler(),['Mileage', 'Cylinder','Liter','Doors']),\n",
|
819 |
+
" ('cat',OneHotEncoder(),['Make','Model','Trim','Type'])\n",
|
820 |
+
" ]\n",
|
821 |
+
")\n",
|
822 |
+
"my_model=LinearRegression()\n",
|
823 |
+
"\n",
|
824 |
+
"\n",
|
825 |
+
"pipe=Pipeline(steps=[('preprocessor',preprocess),('model',my_model)])\n",
|
826 |
+
"pipe.fit(X_train,y_train)\n",
|
827 |
+
"\n",
|
828 |
+
"y_pred=pipe.predict(X_test)\n",
|
829 |
+
"print('RMSE',mean_squared_error(y_test,y_pred)**0.5)\n",
|
830 |
+
"print('R2',r2_score(y_test,y_pred))"
|
831 |
+
]
|
832 |
+
},
|
833 |
+
{
|
834 |
+
"cell_type": "code",
|
835 |
+
"execution_count": 7,
|
836 |
+
"metadata": {},
|
837 |
+
"outputs": [
|
838 |
+
{
|
839 |
+
"name": "stdout",
|
840 |
+
"output_type": "stream",
|
841 |
+
"text": [
|
842 |
+
"Requirement already satisfied: streamlit in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (1.35.0)\n",
|
843 |
+
"Requirement already satisfied: altair<6,>=4.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (5.3.0)\n",
|
844 |
+
"Requirement already satisfied: blinker<2,>=1.0.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (1.7.0)\n",
|
845 |
+
"Requirement already satisfied: cachetools<6,>=4.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (5.3.3)\n",
|
846 |
+
"Requirement already satisfied: click<9,>=7.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (8.1.7)\n",
|
847 |
+
"Requirement already satisfied: numpy<2,>=1.19.3 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (1.26.2)\n",
|
848 |
+
"Requirement already satisfied: packaging<25,>=16.8 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (23.2)\n",
|
849 |
+
"Requirement already satisfied: pandas<3,>=1.3.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (2.1.4)\n",
|
850 |
+
"Requirement already satisfied: pillow<11,>=7.1.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (10.1.0)\n",
|
851 |
+
"Requirement already satisfied: protobuf<5,>=3.20 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (4.25.3)\n",
|
852 |
+
"Requirement already satisfied: pyarrow>=7.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (16.1.0)\n",
|
853 |
+
"Requirement already satisfied: requests<3,>=2.27 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (2.31.0)\n",
|
854 |
+
"Requirement already satisfied: rich<14,>=10.14.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (13.7.1)\n",
|
855 |
+
"Requirement already satisfied: tenacity<9,>=8.1.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (8.2.3)\n",
|
856 |
+
"Requirement already satisfied: toml<2,>=0.10.1 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (0.10.2)\n",
|
857 |
+
"Requirement already satisfied: typing-extensions<5,>=4.3.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (4.9.0)\n",
|
858 |
+
"Requirement already satisfied: gitpython!=3.1.19,<4,>=3.0.7 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (3.1.43)\n",
|
859 |
+
"Requirement already satisfied: pydeck<1,>=0.8.0b4 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (0.9.1)\n",
|
860 |
+
"Requirement already satisfied: tornado<7,>=6.0.3 in c:\\users\\acer\\appdata\\roaming\\python\\python312\\site-packages (from streamlit) (6.4)\n",
|
861 |
+
"Requirement already satisfied: watchdog>=2.1.5 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from streamlit) (4.0.1)\n",
|
862 |
+
"Requirement already satisfied: jinja2 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from altair<6,>=4.0->streamlit) (3.1.2)\n",
|
863 |
+
"Requirement already satisfied: jsonschema>=3.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from altair<6,>=4.0->streamlit) (4.22.0)\n",
|
864 |
+
"Requirement already satisfied: toolz in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from altair<6,>=4.0->streamlit) (0.12.1)\n",
|
865 |
+
"Requirement already satisfied: colorama in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from click<9,>=7.0->streamlit) (0.4.6)\n",
|
866 |
+
"Requirement already satisfied: gitdb<5,>=4.0.1 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from gitpython!=3.1.19,<4,>=3.0.7->streamlit) (4.0.11)\n",
|
867 |
+
"Requirement already satisfied: python-dateutil>=2.8.2 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2.8.2)\n",
|
868 |
+
"Requirement already satisfied: pytz>=2020.1 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2023.3.post1)\n",
|
869 |
+
"Requirement already satisfied: tzdata>=2022.1 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2023.3)\n",
|
870 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests<3,>=2.27->streamlit) (3.3.2)\n",
|
871 |
+
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests<3,>=2.27->streamlit) (3.6)\n",
|
872 |
+
"Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests<3,>=2.27->streamlit) (2.1.0)\n",
|
873 |
+
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests<3,>=2.27->streamlit) (2023.11.17)\n",
|
874 |
+
"Requirement already satisfied: markdown-it-py>=2.2.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from rich<14,>=10.14.0->streamlit) (3.0.0)\n",
|
875 |
+
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\users\\acer\\appdata\\roaming\\python\\python312\\site-packages (from rich<14,>=10.14.0->streamlit) (2.17.2)\n",
|
876 |
+
"Requirement already satisfied: smmap<6,>=3.0.1 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from gitdb<5,>=4.0.1->gitpython!=3.1.19,<4,>=3.0.7->streamlit) (5.0.1)\n",
|
877 |
+
"Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from jinja2->altair<6,>=4.0->streamlit) (2.1.3)\n",
|
878 |
+
"Requirement already satisfied: attrs>=22.2.0 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (23.1.0)\n",
|
879 |
+
"Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (2023.12.1)\n",
|
880 |
+
"Requirement already satisfied: referencing>=0.28.4 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (0.35.1)\n",
|
881 |
+
"Requirement already satisfied: rpds-py>=0.7.1 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (0.18.1)\n",
|
882 |
+
"Requirement already satisfied: mdurl~=0.1 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from markdown-it-py>=2.2.0->rich<14,>=10.14.0->streamlit) (0.1.2)\n",
|
883 |
+
"Requirement already satisfied: six>=1.5 in c:\\users\\acer\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from python-dateutil>=2.8.2->pandas<3,>=1.3.0->streamlit) (1.16.0)\n",
|
884 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
885 |
+
]
|
886 |
+
}
|
887 |
+
],
|
888 |
+
"source": [
|
889 |
+
"pip install streamlit"
|
890 |
+
]
|
891 |
+
},
|
892 |
+
{
|
893 |
+
"cell_type": "code",
|
894 |
+
"execution_count": 12,
|
895 |
+
"metadata": {},
|
896 |
+
"outputs": [],
|
897 |
+
"source": [
|
898 |
+
"#streamlit run C:\\Users\\Acer\\AppData\\Roaming\\Python\\Python312\\site-packages\\ipykernel_launcher.py "
|
899 |
+
]
|
900 |
+
},
|
901 |
+
{
|
902 |
+
"cell_type": "code",
|
903 |
+
"execution_count": 13,
|
904 |
+
"metadata": {},
|
905 |
+
"outputs": [],
|
906 |
+
"source": [
|
907 |
+
"import streamlit as st\n",
|
908 |
+
"def price(make,model,trim,mileage,car_type,cylinder,liter,doors,cruise,sound,leather):\n",
|
909 |
+
"\tinput_data=pd.DataFrame({\n",
|
910 |
+
"\t\t'Make':[make],\n",
|
911 |
+
"\t\t'Model':[model],\n",
|
912 |
+
"\t\t'Trim':[trim],\n",
|
913 |
+
"\t\t'Mileage':[mileage],\n",
|
914 |
+
"\t\t'Type':[car_type],\n",
|
915 |
+
"\t\t'Car_type':[car_type],\n",
|
916 |
+
"\t\t'Cylinder':[cylinder],\n",
|
917 |
+
"\t\t'Liter':[liter],\n",
|
918 |
+
"\t\t'Doors':[doors],\n",
|
919 |
+
"\t\t'Cruise':[cruise],\n",
|
920 |
+
"\t\t'Sound':[sound],\n",
|
921 |
+
"\t\t'Leather':[leather]\n",
|
922 |
+
"\t\t})\n",
|
923 |
+
"\tprediction=pipe.predict(input_data)[0]\n",
|
924 |
+
"\treturn prediction\n",
|
925 |
+
"st.title(\"Araba Fiyatı Tahmin :red_car: @drmurataltun\")\n",
|
926 |
+
"st.write(\"Arabanın özelliklerini seçin\")\n",
|
927 |
+
"make=st.selectbox(\"Marka\",df['Make'].unique())\n",
|
928 |
+
"model=st.selectbox(\"Model\",df[df['Make']==make]['Model'].unique())\n",
|
929 |
+
"trim=st.selectbox(\"Trim\",df[(df['Make']==make) & (df['Model']==model)]['Trim'].unique())\n",
|
930 |
+
"mileage=st.number_input(\"Kilometre\",200,60000)\n",
|
931 |
+
"car_type=st.selectbox(\"Tipi\",df[(df['Make']==make) & (df['Model']==model) & (df['Trim']==trim )]['Type'].unique())\n",
|
932 |
+
"cylinder=st.selectbox(\"Silindir\",df['Cylinder'].unique())\n",
|
933 |
+
"liter=st.number_input(\"Liter\",1,6)\n",
|
934 |
+
"doors=st.selectbox(\"Kapı\",df['Doors'].unique())\n",
|
935 |
+
"cruise=st.radio(\"Hız S.\",[True,False])\n",
|
936 |
+
"sound=st.radio(\"Ses Sistemi\",[True,False])\n",
|
937 |
+
"leather=st.radio(\"Deri döşeme\",[True,False])\n",
|
938 |
+
"if st.button(\"Tahmin\"):\n",
|
939 |
+
"\tpred=price(make,model,trim,mileage,car_type,cylinder,liter,doors,cruise,sound,leather)\n",
|
940 |
+
"\n",
|
941 |
+
"\tst.write(\"11062024:Predicted Price :red_car: $\",round(pred[0],2))\n"
|
942 |
+
]
|
943 |
+
},
|
944 |
+
{
|
945 |
+
"cell_type": "code",
|
946 |
+
"execution_count": null,
|
947 |
+
"metadata": {},
|
948 |
+
"outputs": [],
|
949 |
+
"source": []
|
950 |
+
}
|
951 |
+
],
|
952 |
+
"metadata": {
|
953 |
+
"kernelspec": {
|
954 |
+
"display_name": "Python 3",
|
955 |
+
"language": "python",
|
956 |
+
"name": "python3"
|
957 |
+
},
|
958 |
+
"language_info": {
|
959 |
+
"codemirror_mode": {
|
960 |
+
"name": "ipython",
|
961 |
+
"version": 3
|
962 |
+
},
|
963 |
+
"file_extension": ".py",
|
964 |
+
"mimetype": "text/x-python",
|
965 |
+
"name": "python",
|
966 |
+
"nbconvert_exporter": "python",
|
967 |
+
"pygments_lexer": "ipython3",
|
968 |
+
"version": "3.12.4"
|
969 |
+
}
|
970 |
+
},
|
971 |
+
"nbformat": 4,
|
972 |
+
"nbformat_minor": 2
|
973 |
+
}
|