Car Price Detection Based On The Travelling Distance

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

Car Price Detection based on

the travelling distance


Done by
Adithya.R
III year CSE J
RA2011003020093
Under the guidance of
Mrs.G.Gangadevi AP/CSE
Introduction:
Nowadays prices of vehicles are getting increased based on the demand such as distance covered by the car. Longer the distance, greater the price.
Apart from distance we have several factors like type of fuel used (for example Petrol,Diesel,CNG ),brand of car used( for example
Ford,Hyundai),location( for example Delhi,Chennai).So determining the price of the car by manual ways is a little bit difficult. We don’t know how
much benefit it will give eventhough if we do computerised(digital)methods. Also in Foreign countries cost of cars will be in dollars.so for people
who want to buy cars especially for long distances,this will be a little bit complicated.Also people who have migrated from village to city find
difficult to buy cars as their price in city is greater than that of villages.So for the easy prediction of car prices, and help people to buy their desired
car in their desired model,we do this project.
Domain and languages:
The domain we use here for this project is data science and machine learning.
Machine Learning is the process of making the machine learn the dataset and
train it using different algorithms.Once we collect the data,we can process the
data using algorithms and predict the output of the algorithms.
For this project,the languages , frameworks and libraries used are:
1.python
2.jupyter
3.pandas
4.matplotlib.pyplot
5.linear regression
6.metrics
7.train_test_split.
Abstract:
• A car price prediction has been a high-interest research area, as it needed recognizable effort and knowledge of
the field expert. In this project, We have Considered number of distinct attributes which are examined for the
reliable and accurate prediction. To build a model for predicting the price of used cars we have used linear
regression algorithm and python libraries and some other machine learning related libraries like Numpy, Pandas,
Sklearn etc.We have plotted a graph between distance travelled and price of used cars to predict how much the
price will be in future in accordance with the distance travelled.Steps followed are :
• 1.data processing
• 2.data model fitting and splitting as train data and test data
• 3.predict the outcomes using both datasets.
• 4.visualize the dataset using scatter plot
• 5.find r squared metrics to find closeness of train and test data.
• 6.if values are somehow close ,our prediction is almost correct.
]

Source code:

import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn import metrics
d=pd.read_csv("CAR DETAILS FROM CAR DEKHO.csv")
d[0:10]
X=d.drop(['name','km_driven','fuel','transmission',’owner','seller_type’],axis=1)
Y=d['km_driven’]
Y[0:10]
X[0:10]
X_train,X_test,Y_train,Y_test=train_test_split(X,Y,test_size=0.1,random_state=2)
lin_mod_reg=LinearRegression()
lin_mod_reg.fit(X_train,Y_train)
)

t=lin_mod_reg.predict(X_train)
t
e=metrics.r2_score(Y_train,t)
e
plt.scatter(Y_train,t)
plt.xlabel("Price")
plt.ylabel("Kilometre")
plt.title("detection of car price and kilometre using training set “)
plt.show()
s=lin_mod_reg. predict(X_test)
s
f=metrics.r2_score(Y_test,s)
f
plt.scatter(Y_test,s)
plt.xlabel("Price")
plt.ylabel("Kilometre")
plt.title("detection of car price and kilometre using training set ") plt.show()
Result:

selling_pri km_drive seller_typ transmissi


1.name year fuel owner
ce n e on
Maruti First
0 2007 60000 70000 Petrol Individual Manual
800 AC Owner
Maruti
First
1 Wagon R 2007 135000 50000 Petrol Individual Manual
Owner
LXI Minor
Hyundai
First
2 Verna 1.6 2012 600000 100000 Diesel Individual Manual
Owner
SX
Datsun
First
3 RediGO T 2017 250000 46000 Petrol Individual Manual
Owner
Option
Honda
Second
4 Amaze VX 2014 450000 141000 Diesel Individual Manual
Owner
i-DTEC
Maruti
First
5 Alto LX 2007 140000 125000 Petrol Individual Manual
Owner
BSIII
Hyundai
First
6 Xcent 1.2 2016 550000 25000 Petrol Individual Manual
Owner
Kappa S

Tata
Indigo Second
7 2014 240000 60000 Petrol Individual Manual
Grand Owner
Petrol

Hyundai
First
8 Creta 1.6 2015 850000 25000 Petrol Individual Manual
Owner
VTVT S
Maruti
First
9 Celerio 2017 365000 78000 CNG Individual Manual
Owne
Green VXI
2. 0 70000
1 50000 3.
2 100000 year selling_pric
3 46000 e
4 141000
5 125000 0 2007 60000
6 25000
7 60000 1 2007 135000
8 25000
9 78000
2 2012 600000

3 2017 250000

4 2014 450000

5 2007 140000

6 2016 550000

7 2014 240000

8 2015 850000

9 2017 365000
4.LinearRegression()

5.array([43434.959638, 76016.0180313 ,
38997.35759478, ..., 66762.70975555,
80563.97583328, 49030.39278483])
0.1744417476529282
6.array([ 52807.66922836, 48469.56832211, 99009.08441412, 59376.25652771, 43603.2069542 , 48686.66166252, 75764.55157866, 99038.02838372, 71634.50026608, 48234.38387 , 71507.86067506,
85182.48897089, 52690.0770023 , 61791.41993977, 112676.47445615, 50048.77469399, 71534.99734261, 57171.09769099, 42213.80957558, 53395.63035863, 48840.43611198, 85345.3089762 ,
80654.43139178, 85164.39785919, 44163.88373732, 48596.20610402, 64826.96080356, 57625.18459468, 58158.87238985, 39811.45762131, 57923.68793774, 94464.74302536, 48180.1105349 ,
66916.484205 , 103602.26818623, 42213.80957558, 66871.25642575, 85092.03341239, 47555.96718122, 39721.00206281, 39178.26871178, 48053.47275299, 60914.00102228, 52880.03367516,
44706.61708835, 62560.29218705, 66527.52530344, 62053.74105943, 62243.69773229, 66889.34753745, 44095.28700157, 57742.77682073, 48489.46854498, 52509.1658853 , 80835.34250879,
71643.54401282, 39748.13873036, 48288.6572051 , 44393.78853552, 39268.72427029, 47478.17540091, 53424.57613736, 48939.93722633, 51676.97474706, 57923.68793774, 99124.86571989,
53505.98614001, 71724.95401547, 53505.98614001, 57471.41014522, 80705.08650455, 76216.82937118, 66491.34308003, 43467.52361644, 52418.71032679, 80518.74805403, 57064.36013195,
44104.33074831, 48469.56832211, 57200.04346971, 34706.29357895, 48641.43388327, 66437.06974493, 48010.05408491, 71670.68068037, 71914.91068833, 67124.53198956, 61728.10104882,
41761.53178306, 57335.72680746, 62451.74551685, 76280.14826213, 53395.63035863, 48324.8394285 , 54486.37671459, 66437.06974493, 38183.25756824, 61999.46772433, 62632.65663386,
80627.29472423, 35373.85560071, 103584.17707453, 57625.18459468, 71381.22289316, 62424.6088493 , 76338.03981957, 33962.74888805, 80473.52027478, 89737.68321755, 48324.8394285 ,
66753.66419969, 44706.61708835, 67124.53198956, 57833.23237924, 80591.11250083, 76126.37381268, 43753.36318131, 56926.86768303, 76035.91825417, 71643.54401282, 57507.59236862,
52807.66922836, 53458.94924959, 47420.28384346, 48053.47275299, 57878.46015849, 66871.25642575, 85092.03341239, 76325.37604138, 47601.19496047, 80563.97583328, 57650.51215106,
43163.59293987, 52943.35256612, 57109.58791121, 70919.89954479, 103538.95110439, 71806.36401813, 83644.74447632, 52671.9858906 , 70965.12732404, 57091.4967995 , 89801.0021085 ,
62361.28995834, 43434.95961538, 48777.11722102, 62451.74551685, 47963.01719449, 94437.60635781, 66862.2108699 , 53169.49146237, 43322.79653195, 52762.44144911, 39359.17982879,
112694.56556785, 57471.41014522, 71634.50026608, 80383.06471627, 62126.10550623, 57399.04569842, 48324.8394285 , 42620.85958884, 62457.02517076, 75764.55157866, 48659.52499497,
48740.93499762, 44068.14852491, 47917.78941524, 38635.53536076, 57561.86570372, 71507.86067506, 52889.07923101, 76189.69270363, 53449.90369374, 43724.41740259, 48958.02833803,
48053.47275299, 80744.88695029, 76153.51048023, 61909.01216582, 85408.62786715, 71688.77179207, 66165.70306942, 61999.46772433, 71263.63247621, 57290.49902821, 48053.47275299,
48460.52276626, 94374.28746686, 57760.86793243, 75945.46269567, 108076.05243024, 62524.10996365, 71516.90623091, 76108.28270097, 48415.29498701, 76171.60159193, 66889.34753745,
67354.6509304 , 89837.1843319 , 47999.19941789, 66844.1197582 , 85363.4000879 , 47963.01719449, 85182.48897089, 71761.13623887, 43621.1503863 , 71596.50893151, 62705.02108066,
70764.31598416, 76307.28492968, 47854.47052428, 48234.38387 , 35446.22004751, 49021.34722898, 76262.05715043, 62614.56552215, 71824.45512983, 90045.23211646, 48460.52276626,
89900.50322285, 47890.65274769, 94591.38080727, 76162.55784519, 52860.13345229, 76262.05715043, 76307.28492968, 33926.56666465, 76361.55826478, 57788.00459998, 80636.34028008,
43988.25227422, 99047.07393957, 80853.43362049, 48469.56832211, 107858.96089894, 59828.53432023, 48415.29498701, 52679.22233528, 44230.96853022, 49012.30167313, 38192.30312409,
66891.15664862, 80790.11472954, 71462.63289581, 76077.52781108, 53151.40215979, 58059.3712755 , 66753.66419969, 57127.67902291, 85399.5823113 , 66627.02641779, 57598.04792713,
70965.12732404, 66798.89197895, 31399.09068044, 67070.25865446, 108085.09798609, 94401.42413441, 108085.09798609, 64944.55302962, 85363.4000879 , 75882.14380471, 98857.11726672,
75855.00713716, 48234.38387 , 62632.65663386, 53079.03590387, 112703.6111237 , 61909.01216582, 52690.0770023 , 53305.17480013, 90018.09544891, 44366.65186797, 57652.32126223,
39449.6353873 , 99056.11949543, 43706.32629089, 85092.03341239, 71634.50026608, 53666.99703415, 57706.59459733, 58014.14349625, 83373.37780081, 35469.59081312, 39811.45762131,
43706.32629089, 52581.5303321 , 66708.43642044, 62089.92328283, 58014.14349625, 67214.98754807, 71598.31623357, 85426.72078796, 44321.42408872, 66165.70306942, 34476.53646035,
99124.86571989, 89963.82211381, 71182.22066445, 71724.95401547, 53395.63035863, 71326.94955806, 103584.17707453, 48659.52499497, 103566.08596283, 76162.55784519, 52726.25922571,
103629.40485378, 48505.75054551, 57923.68793774, 66925.52976085, 130833.93255183, 89945.73100211, 76218.63848235, 43543.50628559, 99119.43838638, 44435.25041283, 80952.93473485,
85381.4911996 , 85182.48897089, 64664.14079825, 58267.41906006, 58258.37531332, 63904.31410682, 38906.90203627, 37828.52409931, 57507.59236862, 67126.34110073, 80817.25139709,
47964.82630566, 65894.33639391, 98911.39060182, 80808.20584124, 53558.45036394, 48903.75500293, 57109.58791121, 80925.79806729, 76361.55826478, 76035.91825417, 80636.34028008,
94455.69746951, 44551.18120732, 76361.55826478, 53305.17480013, 85137.26119164, 48324.8394285 , 60823.54546378, 42439.94847184, 75674.09602015, 65894.33639391, 43706.32629089,
57064.36013195, 71354.08622561, 43163.59293987, 65170.69192588, 112676.47445615, 66473.25196833, 80799.16028539, 67251.16977147, 53486.08591714, 52147.34365128, 71354.08622561,
57742.77682073, 80744.88695029, 112622.20112105, 71345.04066976, 43434.95961538, 71263.63247621, 57704.78548616, 70874.67176554, 89972.86766966, 62424.6088493 , 135367.41746445,
61909.01216582, 57959.87016114, 64664.14079825, 44339.51520042, 39087.81315328, 33801.73799391, 66835.07420235, 71236.49399955, 67214.98754807, 57561.86570372, 71507.86067506,
80726.79583859, 85209.62563844, 62451.74551685, 112667.4289003 , 61999.46772433, 80518.74805403, 53486.08591714, 103620.35929793, 48777.11722102, 53359.44813523, 56765.85678889,
80672.52250348, 57290.49902821, 52671.9858906 , 89763.01077393, 53033.80812462, 103538.95110439, 43887.2374079 , 66617.98086194, 43163.59293987, 94546.15302802, 71571.17956602,
56973.90457345, 66862.2108699 , 47239.37272646, 66898.3930933 , 89900.50322285, 62044.69550358, 61909.01216582, 71281.7217788 , 47872.56163598, 71055.58288254, 48777.11722102,
66708.43642044, 98947.57282522, 53341.35702353, 71507.86067506, 94491.87969292, 52174.48031883, 44339.51520042, 57335.72680746, 94446.65191366, 57760.86793243, 76016.0180313 ,
38110.89312144, 67025.03087521, 98314.38391569, 66762.70975555, 70720.89731608])
7.0.1993550534897911
References:
1.Raghav K car price prediction objective and statement
Conclusion

• Our project has been simulated by using python libraries and


frameworks.
• We have done our best by predicting the datasets to approximately
estimate the output.
• In future we will also do bar graphs,histograms etc to find a better
solution.
THANK YOU

You might also like