Message Boards Message Boards

0
|
5008 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Import data with column items given as Quantity units and use Predict?

Posted 4 years ago

In the column I import as xlsx or CSV I get this Quantity[1.35, "Kilograms"], I have tried flatten which works on one item but feeding in a full column does not work for me. QuantityMagnatude only works for me if I put the item directly into this function but it does not work when I put a variable in i.e. to process the whole column I am using the import Sample-Data-Animal-Weights.xlsx. This form of the import is also in Boston Home data main file. I have spent a lot of time trying to sort this. If I use Excel to extract the number I can run Predict, but because of inconsistency of decimal places this is time consuming.

Attachments:
POSTED BY: Declan Flynn
3 Replies
Posted 4 years ago

Thank you so much for this help, also you are correct "I don't think Predict can deal with numeric -> nominal data. You will have to encode the animal names to integers.", I have it running now.

POSTED BY: Declan Flynn
Posted 4 years ago

Hi Declan,

The problem is that the quantities are imported as strings, see InputForm @ info. To extract the quantity magnitudes and generate the rules

data2 = Thread[Rule[QuantityMagnitude@*ToExpression /@ info, animal]]

I don't think Predict can deal with numeric -> nominal data. You will have to encode the animal names to integers.

POSTED BY: Rohit Namjoshi
Posted 4 years ago

Sorry, here is the Data file that I am using.

POSTED BY: Declan Flynn
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