Example of Markov Chain With Python
Example of Markov Chain With Python
The idea for my project started after our Singapour Module. I returned to Paris, where I live
with my wife and two young daughters. After March, the weather improved, and I considered
buying a car to leave the city for weekends and vacations. In the meantime, I noticed that
many companies and start-ups propose rental cars in Paris.
I noticed that each company and each offer by the same company has a different approach to
pricing. Some have a monthly fee; others don't; some include fuel in the price per km, others
don't; Some give a discount after a certain nb of rentals etc.
I tried to do a rough calculation to make my choice and shortly understood that it was too
complicated.
I tried to ask a popular AI to help me, but they failed to consider all variables.
Consequently, I thought about using what I learned in Python to help me compare all services
available. It was my first coding experience, and I was excited to have an opportunity to be
involved in a problem-solving situation.
Data Collection:
I looked for my track record for rental cars and extracted the following data in an Excel file
Excel file: CarRental_Paris
Sheet: Consumption
Then I looked for prices online and deducted average costs for 10 options, including buying a
car.
Monthly_Fee
Tarif_before_limit
Tarif_after_limit
Sheet: Tarifs
Service Monthly Tarif Tarif Free Price per km before Price per Km after Delive
Name fee J1 JX Kms limit limit ry
Getaround 0 93 93 200 0,102 0,262 NO
CC liberté 0 37,5 27,5 50 0 0,29 NO
CC
Economique 3 27,5 27,5 50 0,47 0,29 NO
CC plus 9 23,5 23,5 50 0,42 0,29 NO
CC Extra 18 19,5 19,5 50 0,32 0,29 NO
Acquisition 518 0 0 0 0,102 0,102 YES
Ubeeqo 0 72 50 30 0,102 0,302 NO
Hertz 0 150 150 0 0,102 0,102 NO
Virtuo 0 100 100 100 0,102 0,302 YES
Carlili 0 137 137 200 0,102 0,452 YES
Assumptions:
I consider :
• a client who is not a car fan but wants to drive his family safely.
• a medium-range car for families type Peugot 2008 or Duster
Coding:
Using what we learned in the Python class with Loops, functions, and plotting technics, I
built a basic code to:
To complement this analysis, I added a value proposal map to include my experience with
these services in the process.
NB: the diagonal did not get printed on the picture as expected.
Other profile
In addition, I modified and built a simplified code to make it easily available for anyone with
the same question. Python will only ask for
Conclusion
Acquisition is not the cheapest solution, but it offers significant advantages, around 1000 km
per month.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
RentalCarServices = np.array(df)
Consuption = np.array(df2)
return Monthly_Cost
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
RentalCarServices = np.array(df)
return Monthly_Cost
# User input for average rental days and average kilometers driven per month
avg_rental_days = int(input("Enter your average number of rental days per month: "))
avg_km_per_month = int(input("Enter your average number of kilometers driven with a rental car per month: "))
# Calculate the yearly cost for each service based on user input
yearly_costs = []
for service in services:
yearly_cost, _ = Calculate_Yearly_Cost(service, avg_rental_days, avg_km_per_month)
yearly_costs.append(yearly_cost)