Message Boards Message Boards

0
|
4279 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to use Classify[] with a DateObject[] ?

Posted 3 years ago

Hello,

I am learning about ML, and trying to do some predictions. I am using DateObject, but it doesn't seem to work with Classify, perhaps I have some other error? The DateObject is pointing to categorical labels that represent geographical locations.

Best regards, Andrew

POSTED BY: Andrew Skipor
4 Replies

Hello Rohit,

Thanks very much for the clarifications and suggestions on how to improve the modeling. I have some more work to do, but in the long run get more tools under my belt.

Best and thanks again,

Andrew

POSTED BY: Andrew Skipor
Posted 3 years ago

Hi Andrew,

It is best to avoid applying formatting to expressions that are used for computation. If the data has logical groupings, use a separate list for each group. e.g.

dataGWB = {
 DateObject[{2020, 8, 16}, "Day"] -> "GWB", 
 DateObject[{2020, 8, 18}, "Day"] -> "GWB", 
 DateObject[{2020, 8, 19}, "Day"] -> "GWB", 
 DateObject[{2020, 8, 20}, "Day"] -> "GWB"}

Then combine them for further analysis

dataAll = Join[dataGWB, dataBynB, ...]

Classify accepts input in several forms, one of them is a list of Rule. Some of the elements in the datesclassify list are not rules of the form date -> label, they are just date. The code I posted earlier identifies them

Cases[datesclassify, Except[_Rule]]

To visually identify them

datesclassify // Column
POSTED BY: Rohit Namjoshi

Thanks very much for the suggestions. They are colored lines, since this helps me to keep the categories sorted in the original data set. I think I would be able to combine the different values for the same data.

I'm not yet clear on this: " There are several elements in the list that are not rules." Can you elaborate please?

Thanks again Andrew

POSTED BY: Andrew Skipor
Posted 3 years ago

Hi Andrew,

Remove the color formatting then evaluate the datesclassify expression. There are several elements in the list that are not rules.

Cases[datesclassify, Except[_Rule]]

Remove them and then classify

Cases[datesclassify, _Rule] // Classify

Note that the data has several cases where the same date is associated with different values. This is unlikely to result in a good classifier. e.g.

Cases[datesclassify, _Rule] // 
 Select[First@# == DateObject[{2020, 8, 20}, "Day", "Gregorian", -5.`] &]
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract