2
$\begingroup$

I was reading this answer and thought I would ask a question since it had been asked ~5 years ago. Now there is a line in the answer where it states that to train the classifier, you can use the code:

cfun = titUnclass["Train", Classify @* Values, #Features -> #Objective &];

I had never seen this "at star" notation before, so I looked it up, and discovered it was called Composition (@*). Now I know for Classify that it can specify several methods, however, written like this, it seems that Mathematica goes through several methods before determining the best to use.

My issue is this: I would like to specify the method, however I do not know enough to figure out how to rewrite this line to do so. I tried

cfun = titUnclass["Train", Classify[Values, Method -> "DecisionTree"], #Features -> #Objective &];

and

Composition[Classify][Values]

but received the error (for both)

Classify::bdfmt: Argument Values should be a rule, a list of rules, or an association. 

If someone could point me in the right direction for tackling this, it would be greatly appreciated.

$\endgroup$
8
  • $\begingroup$ You misread the notation. Look at the result of FullForm[Classify @* Values]. Then, look at the result of (f @* g)[x]. $\endgroup$ – J. M.'s torpor Apr 25 '20 at 4:33
  • $\begingroup$ Oh! I see! My mistake. I wrote work around where I use //Normal, but I'm still curious to see how Composition[Classify,Values] would be re-written to include Method. $\endgroup$ – Illari Apr 25 '20 at 4:36
  • $\begingroup$ Normally, the function concerned would be something like Classify[Values[stuff]], which you want to modify to Classify[Values[stuff], Method -> "DecisionTree"]. Since you're calling it inside a Dataset[], you'd need to use # and & somewhere in there. $\endgroup$ – J. M.'s torpor Apr 25 '20 at 4:39
  • $\begingroup$ Thanks for taking the time to comment. $\endgroup$ – Illari Apr 25 '20 at 4:46
  • 2
    $\begingroup$ does cfun = titUnclass["Train", (Classify[#,Method->"DecisionTree"]&)@*Values, #Features -> #Objective &]; work? $\endgroup$ – kglr Apr 25 '20 at 4:52
3
$\begingroup$

You can try

cfun = titUnclass["Train", (Classify[#, Method->"DecisionTree"]&) @* Values,
   #Features -> #Objective &];
$\endgroup$
1
  • 1
    $\begingroup$ titUnclass["Train", Classify[Values[#], Method -> "DecisionTree"] &, #Features -> #Objective &] was the result I was hoping OP would think up, but oh well. $\endgroup$ – J. M.'s torpor Apr 25 '20 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.