# How to perform prediction on a mixed type label (i.e. continuous but optional)

I have a set of simulations in which an event may or may not happen. I recorded the time the event occurs and whether it does.

I would like to perform regression on the time variable, including whether the event happens at all. I suppose the easiest approach is to encode the missing value as NaN, but that opens a can of worms.

I imagine Linear Regression is out of the question, because there is no way it could generate a NaN.

I suppose a Decision Tree would also not work, because when establishing the value of a leaf it would calculate the average, which would be NaN if even one of the values is a NaN. Similar deal with Random Forests.

Question: are there techniques to deal with this situation? In particular, I am using Python.

No matter how you structure the problem, you have to have a numerical representation of the NaN (no occurrence of the event). Regression is a lot harder problem by default and thus having a value such as 0 to encode the NaN may be tough to address (and it doesn't make much sense, either). What I would do is treat the problem as both classification (a binary classifier to determine whether the event occurs or not) and regression (if it occurs, what is the value).
{"ft_lang_label":"__label__en","ft_lang_prob":0.9673531,"math_prob":0.885503,"size":756,"snap":"2020-10-2020-16","text_gpt3_token_len":158,"char_repetition_ratio":0.10239362,"word_repetition_ratio":0.0,"special_character_ratio":0.20634921,"punctuation_ratio":0.10828026,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9654733,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-03-30T11:24:37Z\",\"WARC-Record-ID\":\"<urn:uuid:4f1523d6-66b5-4104-b717-f41a673af96d>\",\"Content-Length\":\"139828\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3f4d0d92-2c50-4712-b69b-37ff7d07b9d5>\",\"WARC-Concurrent-To\":\"<urn:uuid:b9703ade-5dd8-4cc6-9531-b3bd58cdf52f>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://stats.stackexchange.com/questions/383842/how-to-perform-prediction-on-a-mixed-type-label-i-e-continuous-but-optional\",\"WARC-Payload-Digest\":\"sha1:3U33VZ3RKGOM5GJVDJBECFO65ULWRTJ7\",\"WARC-Block-Digest\":\"sha1:I76NENRWUG7EVYTMU6KUQ7BTTZAAPIAM\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-16/CC-MAIN-2020-16_segments_1585370496901.28_warc_CC-MAIN-20200330085157-20200330115157-00092.warc.gz\"}"}