Suppose I have a dataset that looks like this:

alert_id  hour  feature_1  feature_2
1234      0     00         0.06
1234      1     12         1.15
1234      2     15         0.98
1234      3     12         0.00
1234      4     00         0.00
1234      5     00         0.00
5678      0     00         0.00
5678      1     00         0.00
5678      2     00         0.00
5678      3     18         1.32
5678      4     34         -1.05
5678      5     12         0.52
9123      0     00         0.00

This dataset represents the state (aka what the feature values were at each hour) of my system for the past i-th hour whenever an alert was created. I believe that it is important for my logistic regression model to see that state of my system in order for it to correctly classify each alert into either events A, B, or C.

I was thinking I can transpose each alert record into a nest list feature that will look like this:

[[hour 0, feature1, feature2], [[hour 1, feature1, feature2], ... [[hour H, feature1, feature2]]

OR do I use 10 features (meaning that the feature at every hour become its own unique feature?) That looks like this:

feature_1_at_0_hour, feature_2_at_0_hour, feature_1_at_1_hour, feature_2_at_1_hour... etc.

I feel that the former representation makes more sense in the event that number of hours is not exactly 5

  • $\begingroup$ There are two ways. One is by looping and another is by using lapply(). How will the alerts be categorized into events (A, B, C)? $\endgroup$ Apr 12, 2020 at 20:27
  • $\begingroup$ @Mohanasundaram so we actually that specialists that manually label each alert (they look at the overall state of the system during the past couple of hours before they make their evaluation), so I already have each datapoint labeled for my training set. My concern is whether what I am trying to do is actually "correct" or even possible $\endgroup$ Apr 12, 2020 at 20:30
  • $\begingroup$ you can subset the data categorize the alerts in a loop. I understand that you are labeling the events based on the states of the system. I'll update you the code, if that will help you. $\endgroup$ Apr 12, 2020 at 20:47
  • $\begingroup$ @Mohanasundaram So it is valid to use a nested list structure as a feature? $\endgroup$ Apr 12, 2020 at 21:01

1 Answer 1


You can convert the dataset into list of subsets and carryout the classification.

datalist <- split(data, data$alert_id)

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.