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 7748519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:48:22+00:00 2026-06-01T10:48:22+00:00

I cannot follow crossval() & cvpartition() function given in MATLAB documentation crossval() . What

  • 0

I cannot follow crossval() & cvpartition() function given in MATLAB documentation crossval(). What goes in the parameter and how would it help to compare performance and accuracy of different classifiers. Would be obliged if a simpler version of it is provided here.

  • 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-06-01T10:48:23+00:00Added an answer on June 1, 2026 at 10:48 am

    Let’s work on Example 2 from CROSSVAL documentation.

    load('fisheriris');
    y = species;
    X = meas;
    

    Here we loaded the data from example mat-file and assigned variable to X and y. meas amtrix contains different measurements of iris flowers and species are tree classes of iris, what we are trying to predict with the data.

    Cross-validation is used to train a classifier on the same data set many times. Basically at each iteration you split the data set to training and test data. The proportion is determined by k-fold. For example, if k is 10, 90% of the data will be used for training, and the rest 10% – for test, and you will have 10 iterations. This is done by CVPARTITION function.

    cp = cvpartition(y,'k',10); % Stratified cross-validation
    

    You can explore cp object if you type cp. and press Tab. You will see different properties and methods. For example, find(cp.test(1)) will show indices of the test set for 1st iteration.

    Next step is to prepare prediction function. This is probably where you had the main problem. This statement create function handle using anonymous function. @(XTRAIN, ytrain,XTEST) part declare that this function has 3 input arguments. Next part (classify(XTEST,XTRAIN,ytrain)) defines the function, which gets training data XTRAIN with known ytrain classes and predicts classes for XTEST data with generated model. (Those data are from cp, remember?)

    classf = @(XTRAIN, ytrain,XTEST)(classify(XTEST,XTRAIN,ytrain));
    

    Then we are running CROSSVAL function to estimate missclassification rate (mcr) passing the complete data set, prediction function handle and partitioning object cp.

    cvMCR = crossval('mcr',X,y,'predfun',classf,'partition',cp)
    cvMCR =
        0.0200
    

    Still have questions?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my curl function cannot follow the redirection of Facebook external link redirector, l.php and
I'm trying to follow this tutorial http://eloquentjavascript.net/chapter8.html It mentions a function inPlacePrinter . I
When I follow the instructions in ZS documentation to create a phpunit test case,
In follow up to this question , it appears that some numbers cannot be
I am trying to follow the instructions here: http://honza.ca/2011/06/install-ruby-gems-into-virtualenv However, I cannot find the
The follow is bad code. Please help me achieve what I'm trying to achieve,
OK, I just cannot get java to run my .class files: I follow steps
As a follow-up to cannot-bind-to-address-after-socket-program-crashes , I was receiving this error after my program
Can someone tell me why I cannot write a class as follows <?php class
Hello fellow StackOverflowers. I'm have a brain fart right now, and I cannot seem

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.