Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 507655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:49:36+00:00 2026-05-13T06:49:36+00:00

I saw the help in Matlab, but they have provided an example without explaining

  • 0

I saw the help in Matlab, but they have provided an example without explaining how to use the parameters in the ‘classregtree’ function. Any help to explain the use of ‘classregtree’ with its parameters will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:49:37+00:00Added an answer on May 13, 2026 at 6:49 am

    The documentation page of the function classregtree is self-explanatory…

    Lets go over some of the most common parameters of the classification tree model:

    • x: data matrix, rows are instances, cols are predicting attributes
    • y: column vector, class label for each instance
    • categorical: specify which attributes are discrete type (as opposed to continuous)
    • method: whether to produce classification or regression tree (depend on the class type)
    • names: gives names to the attributes
    • prune: enable/disable reduced-error pruning
    • minparent/minleaf: allows to specify min number of instances in a node if it is to be further split
    • nvartosample: used in random trees (consider K randomly chosen attributes at each node)
    • weights: specify weighted instances
    • cost: specify cost matrix (penalty of the various errors)
    • splitcriterion: criterion used to select the best attribute at each split. I’m only familiar with the Gini index which is a variation of the Information Gain criterion.
    • priorprob: explicitly specify prior class probabilities, instead of being calculated from the training data

    A complete example to illustrate the process:

    %# load data
    load carsmall
    
    %# construct predicting attributes and target class
    vars = {'MPG' 'Cylinders' 'Horsepower' 'Model_Year'};
    x = [MPG Cylinders Horsepower Model_Year];  %# mixed continous/discrete data
    y = cellstr(Origin);                        %# class labels
    
    %# train classification decision tree
    t = classregtree(x, y, 'method','classification', 'names',vars, ...
                    'categorical',[2 4], 'prune','off');
    view(t)
    
    %# test
    yPredicted = eval(t, x);
    cm = confusionmat(y,yPredicted);           %# confusion matrix
    N = sum(cm(:));
    err = ( N-sum(diag(cm)) ) / N;             %# testing error
    
    %# prune tree to avoid overfitting
    tt = prune(t, 'level',3);
    view(tt)
    
    %# predict a new unseen instance
    inst = [33 4 78 NaN];
    prediction = eval(tt, inst)    %# pred = 'Japan'
    

    tree


    Update:

    The above classregtree class was made obsolete, and is superseded by ClassificationTree and RegressionTree classes in R2011a (see the fitctree and fitrtree functions, new in R2014a).

    Here is the updated example, using the new functions/classes:

    t = fitctree(x, y, 'PredictorNames',vars, ...
        'CategoricalPredictors',{'Cylinders', 'Model_Year'}, 'Prune','off');
    view(t, 'mode','graph')
    
    y_hat = predict(t, x);
    cm = confusionmat(y,y_hat);
    
    tt = prune(t, 'Level',3);
    view(tt)
    
    predict(tt, [33 4 78 NaN])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw there was a __format__ method but help( int.__format__ ) doesn't provide any
I saw the other questions regarding similar/same issues but they did not help me
Hi i saw a post explaining how to send emails in python. But my
I did a search, but nothing I saw was the same or could help.
I have a problem that I hope you can help/guide me. I saw a
Generally i saw any registration form the textboxes are filled with for example Enter
Could I get some help on configuring Jenkins to use yslow? I saw on
I Need help on browser close event. I saw a tutorial but it is
I saw a similar question being posted here, yet it did not help me
I saw some websites that (for example): if you want to view your message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.