[R] randomForest: How to append ID column along with predictions
Dennis Duro
dennis.duro at gmail.com
Tue Dec 7 18:10:08 CET 2010
Thanks for the confirmation Andy. It would be great if one could
specify a specific column as the unique ID to be returned and/or
display the input row, along with the predictions. Thanks for the
quick reply and looking forward to the patch!
Cheers,
Dennis
On Tue, Dec 7, 2010 at 12:00 PM, Liaw, Andy <andy_liaw at merck.com> wrote:
> The order in the output correspond to the order of the input. I will
> patch the code so that it grabs the row names of the input (if exist).
> If you specify type="prob", it already labels the rows by the input row
> names.
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org
>> [mailto:r-help-bounces at r-project.org] On Behalf Of Dennis Duro
>> Sent: Tuesday, December 07, 2010 11:46 AM
>> To: r-help at r-project.org
>> Subject: [R] randomForest: How to append ID column along with
>> predictions
>>
>> Hi all,
>>
>> When running a prediction using RF on another data, I get two columns
>> returned: row number(?) and predicted class. Is there a way of
>> appending the unique row value from an ID column in the dataframe to
>> the predictions instead of the row number? I'm assuming that the
>> returned results follow the data frame in that the first result
>> returned equals the first entry in the dataframe.
>>
>> i.e., instead of a prediction output like this:
>>
>> 1, ants
>> 2, ants
>> 3, bees
>> 4, ants
>>
>> I'd like the first column to pull IDs from the dataframe associated
>> with each row (row number in parenthesis for illustration):
>>
>> (1) 1130, ants
>> (2) 1130, ants
>> (3) 2139, bees
>> (4) 1130, ants
>>
>> This is likely a simple procedure, but I haven't been able to get
>> anything to work. Any help would be appreciated!
>>
>> Cheers,
>>
>> Dennis
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> Notice: This e-mail message, together with any attachments, contains
> information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
> New Jersey, USA 08889), and/or its affiliates Direct contact information
> for affiliates is available at
> http://www.merck.com/contact/contacts.html) that may be confidential,
> proprietary copyrighted and/or legally privileged. It is intended solely
> for the use of the individual or entity named on this message. If you are
> not the intended recipient, and have received this message in error,
> please notify us immediately by reply e-mail and then delete it from
> your system.
>
>
More information about the R-help
mailing list