# Survival Analysis for predicting next car's maintenance

I am working on a predictive maintenance project. To simplify I want to predict for a car the next time it will have to change for example the oil filter (and then extend to other parts like wipers).

In facts, cars manufacturers used to give a predefined maintenance plan like "change oil filter every 15.000 kilometers". But it is not always the case. (We want to know if there is a big chance that a part will drop out soon, to replace it by anticipation, rather than having to be faced with the facts).

I have a complete database about a lot of cars including features like energy, brand, rolling law(number of kilometers used to do per month), etc. I also have historical data about the car: I know when it changes his oil filter (durations of oil filter)

I look for machine learning concepts that can be applied to my project and then I find Survival Analysis.

I have three questions :

1) Can I use Survival Analysis for my project? Because in general we look to ONE individual and this individual has one birth event and one death event if it is not censored. But here as you can see a car can have multiple oil filters change. But I see that sometimes we can apply to like "how many times between two pregnancies?"

2) Is adding time features or maybe for a given oil filter the number of times it has been changing before will improve my model? Because if I want to do survival regression and want to predict death event for censored individuals (like for example car A has changed 3 time his oil filter and duration of oil filters are 12, 11 and 10 months and I want to predict in how many time it will have to change again), I think it will give me same durations as previous oil filters for the same car as it is same features vector

3) Is there other machine learning which will be suitable for my project?

EDIT : for example this is the Andersen-Gill format for my project's data. The first two rows concern car A, the third and fourth car B and the last 2 car C.

• start_event : oil filter in place
• end_event : oil filter changed
• observed for censorship

1) Yes. All survival analysis is doing is estimating a probability distribution over failure times, possibly conditional on some covariates. That's exactly your situation.

2) Number of previous oil changes seems like a good thing to include. There are ways to deal with time-varying covariates too, which a simple Google search should help you with.

3) You could try something like random survival forests if you have lots of data. But Cox proportional hazards will probably be fine. The c-index is the canonical way to evaluate survival models, so you might compare various approaches using the c-index on held-out data.

• Thanks you for your answer. Can I add static features about the car or it will be not relevant (like energy, brand)? As you can see on my data I can have rows which represent the same car. May 28, 2020 at 10:38
• Yes, I'd use a few static covariates -- presumably different models of car require oil changes at different frequencies so it's definitely worth including. Things like number of previous oil changes and kilometers driven per month/year are also likely to be important, as you say.
– Will
May 28, 2020 at 11:06
• Ok Thanks. But there is one thing I don't get is that for exemple if a car A of model m_a and kilometers driven per month k_a has change 3 times, it will no be a problem to predict next change for this car as I already have 3 rows in my dataset concerning this car? With just the features "number of previous oil change" different. I don't think but should I only include time-varying covariates? May 28, 2020 at 11:16
• I don't think that's a problem as long as the event times are independent given the covariates, i.e., it's fine if you can assume that a different car of the same type & same usage with the same number of previous changes has the same failure time distribution. I think that's reasonable in this case. It corresponds to the Andersen-Gill model for recurrent events. If you're very concerned about, say, the way the car is driven by a particular driver (which would violate the independence assumption), there are other methods (see academic.oup.com/ije/article/44/1/324/654595 for example)
– Will
May 28, 2020 at 12:35
• Yes thanks you for your explanations. Yet we don't have data about the driver. Also for the time-varying covariates, I should use a covariable for each oil filter of the car, I think I can use for example age of the car; but can i use features times like season (people drive less some seasons), month, etc.? May 28, 2020 at 12:51

If you expect maintenance to be a recurring event, which generally speaking it is, think about using frailty models. Frailty models can be used for time to event analysis, and make the assumption that some participants in your population are more "frail" then other. For example, someone who is more "frail" may require more frequent hospitalizations than an otherwise comparable person.

Frailty models work with reccurent event survival data, and can also make the assumption that you are seeing data that has been arbitrarily censored. So as opposed to, say, a drug trial where you observe the start of the period of interest (first does of medication) it works with data where the event may have happened before data collection and you just gathered data at an arbitrary point in the cars life cycle. I don't think this needs to be the case though, you could also probably use them in the case of the drug study.

In R there is a package called "frailty pack" :https://www.jstatsoft.org/article/view/v047i04. Even if you don't use R, the explanation of the different paramaterizations etc are very clear and well written

• Thanks you for your help. Gonna look for python equivalent May 28, 2020 at 11:42