I am working on a classification problem for predicting whether the shipment is going to be late or not.

I would say the classifier is mediocre at predicting the positive class at the moment. But the ambition is to improve it.

However, after doing some analysis, I have found out that there is an important component (Customs) that has appeared as the cause of shipment delay in majority of FN.

Currently, I don't have a feature that would directly be associated to customs and be used in the model. Moreover, I think because of the product we are shipping, custom process may vary.

My original problem was at a shipment level, because of which I had to exclude the products in the shipment. But, now I want to include the products. It is a many to many relation -> Shipment can have multiple products and Vice a versa.

Following is my thought:

To have a separate predictor in addition to the original one that would predict if the product in the shipment is going to be late/not based on planned days for customs.

This is where I am struggling, if this is a right approach how do I consolidate the predictions for both the models to come up with a single prediction as Late or No Late?

In addition to this I need to understand if there is another way to tackle this?


1 Answer 1


My intuition would be to try to integrate the information about the products directly in the original model. Typically the possible products in a shipment can be represented as boolean features (one hot encoding), but this part might need some feature engineering if there are too many different products:

  • simple option: only a small set of features representing types of products (I'm assuming that it's not the specific product which causes custom delays, it's the type of product)
  • advanced option: feature selection/extraction to reduce the number of features

Generally a joint model (a single model which deals with all the information at once) tends to perform better, in particular because in the other option errors in the first model propagate to the second one. Also the two models option doesn't allow the second model to leverage any specific feature from the first one.

Note that this is just my intuition, I could be wrong.

Side note: probably this is already taken into account but I guess that the value of the shipment is also an important factor for customs delays.

  • $\begingroup$ I think it would hard to define the type/family of product at the moment. There are 34,000 unique products. I have looked into feature engineering, one hot encoding is not going to be the best option here merely because of the cardinality of the feature. The other options are WOE and Perlich Ratio, but again there's a risk of data leakage. Fusion is another option. However, I am not sure how to apply it. Can you please advise the best way to proceed with this? $\endgroup$
    – Jas999
    Mar 25, 2021 at 10:50
  • $\begingroup$ @Jas999 I was assuming that there would be at least a general category like "electronics", "clothing", "chemicals"... In this case I'm not sure that the product would be a good indicator for custom delays, because it's unlikely that customs services themselves distinguish and process differently 34000 products. Can you check if there is any indication of a correlation between product and delay? There's a good chance that the delays are simply random, in which case any attempt at predicting them is pointless. $\endgroup$
    – Erwan
    Mar 25, 2021 at 11:07
  • $\begingroup$ I have carried out a chi-squared test and the conclusion is that there is an association between product and delay (p<0.001). However, going back to the analysis we carried out - Custom process is delayed due to error in paperwork , so looking at who's responsible for the paperwork rather than the product might be the right approach. $\endgroup$
    – Jas999
    Mar 25, 2021 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.