Message Boards Message Boards

2
|
6491 Views
|
1 Reply
|
5 Total Likes
View groups...
Share
Share this post:

Proper use of PredictorMeasurements[]?

Posted 7 years ago
POSTED BY: Michael Stern

Your testset supposed to have "weight" information too, in the way the trainingset set has it, because with the testset your not only predicting but also testing against a known result. So I would setup your problem in the following way.

Have some general data:

data=Dataset@{
<|"age"->47,"sex"->"M","height"->100,"weight"->60|>,
<|"age"->22,"sex"->"M","height"->90,"weight"->55|>,
<|"age"->43,"sex"->"M","height"->110,"weight"->61|>,
<|"age"->23,"sex"->"F","height"->100,"weight"->41|>,
<|"age"->33,"sex"->"F","height"->80,"weight"->50|>,
<|"age"->43,"sex"->"F","height"->70,"weight"->51|>,
<|"age"->37,"sex"->"M","height"->100,"weight"->53|>,
<|"age"->22,"sex"->"M","height"->90,"weight"->51|>,
<|"age"->43,"sex"->"F","height"->80,"weight"->51|>,
<|"age"->33,"sex"->"F","height"->70,"weight"->52|>};

Split your data in test and training sets:

leng=Length[data];
split=Round[.6 leng] (* take 60% of your data for trainig *)
trainingset=data[;;split]
testset=data[split-leng;;]

Choose variable to predict and train:

p=Predict[trainingset->"weight",PerformanceGoal->"Quality",Method->"RandomForest"]

and setup the PredictorMeasurements in the same way:

pm = PredictorMeasurements[p, testset -> "weight"]

Now you can extract various measurements:

pm["ComparisonPlot"]

enter image description here

POSTED BY: Vitaliy Kaurov
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