Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.9K Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Avoid error "Predict::bdfmt: Argument ... should be a rule..." in Predict?

Consider the following code:

Y = {5.85045`, 5.35694`, 4.19746`, 4.69639`, 4.88179`, 3.78133`, 
       3.96397`, 4.15864`, 3.37441`, 3.81259`};

X1 = {646.414`, 500.501`, 413.395`, 394.156`, 346.996`, 344.835`, 
   377.928`, 377.465`, 282.401`, 284.568`};

X2 = {1041.35`, 992.418`, 768.296`, 849.538`, 872.931`, 668.548`, 
   693.117`, 719.303`, 577.481`, 645.698`};

tuples1 = Thread[Transpose[{X1, X2}] \[RightArrow] Y];

train = Take[tuples1, 7];
test = Take[tuples1, -3];

cfunc = Predict[train, Method -> "LinearRegression", 
  PerformanceGoal -> "Quality"]

Predict::bdfmt: Argument {{646.414,1041.35}\[RightArrow]5.85045,{500.501,992.418}\[RightArrow]5.35694,{413.395,768.296}\[RightArrow]4.19746,{394.156,849.538}\[RightArrow]4.69639,{346.996,872.931}\[RightArrow]4.88179,{344.835,668.548}\[RightArrow]3.78133,{377.928,693.117}\[RightArrow]3.96397} should be a rule or a list of rules.

Predict::bdfmt: Argument {{646.414,1041.35}\[RightArrow]5.85045,{500.501,992.418}\[RightArrow]5.35694,{413.395,768.296}\[RightArrow]4.19746,{394.156,849.538}\[RightArrow]4.69639,{346.996,872.931}\[RightArrow]4.88179,{344.835,668.548}\[RightArrow]3.78133,{377.928,693.117}\[RightArrow]3.96397} should be a rule or a list of rules.

Predict[{{646.414, 1041.35} \[RightArrow] 
   5.85045, {500.501, 992.418} \[RightArrow] 
   5.35694, {413.395, 768.296} \[RightArrow] 
   4.19746, {394.156, 849.538} \[RightArrow] 
   4.69639, {346.996, 872.931} \[RightArrow] 
   4.88179, {344.835, 668.548} \[RightArrow] 
   3.78133, {377.928, 693.117} \[RightArrow] 3.96397}, 
 Method -> "LinearRegression", PerformanceGoal -> "Quality"]
POSTED BY: M.A. Ghorbani
4 Replies

Dear Rohit, I deeply appreciate your help.

Kind regards, Mohammad

POSTED BY: M.A. Ghorbani
Posted 6 years ago

Hi Mohammed,

It is the same issue, an input of \[RightArrow] is not the same as an input of ->.

cfunc = Predict[train, Method \[RightArrow] "LinearRegression", PerformanceGoal \[RightArrow] "Quality"]

should be

cfunc = Predict[train, Method -> "LinearRegression", PerformanceGoal -> "Quality"]

I have attached a file with that fix and some other suggestions.

Rohit

Attachments:
POSTED BY: Rohit Namjoshi

Thank you so much, Rohit.

I used your rule for my real data. Could you please have a look at the enclosed notebook!

Where am I wrong?

Regards,

Attachments:
POSTED BY: M.A. Ghorbani
Posted 6 years ago

Hello,

The Rule construction is incorrect. Try

tuples1 = Thread[Rule[Transpose[{X1, X2}], Y]]

or

tuples1 = Thread[Transpose[{X1, X2}] -> Y]

You should also randomize the training and testing datasets

SeedRandom[123];
{train, test} = TakeDrop[RandomSample[tuples1], 7]
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