# crossvalscore

For the given estimator and dataset, it automatically applies cross validation and returns the cross validation score and corresponding model parameters.

## Syntax

scores = crossvalscore(fit_func,pred_func,X,y,options)

[scores, model_parameters] = crossvalscore(...)

## Inputs

`fit_func`- Fit method of the estimator.
`pred_func`- Prediction method of the estimator.
`X`- Input dataset which need to be splitted.
`y`- Target labels.
`options`- Type: struct

## Outputs

- scores
- Cross validation scores.
- model_parameters
- Each trained model's parameters corresponding to each score, if return_models is set to true.

## Example

Usage of crossvalscore

```
data = dlmread('data_banknote_authentication.txt', ',');
X = data(:, 1:2);
y = data(:, end);
options = struct;
options.scorer = @accuracy;
options.return_models = true;
[scores, model_params] = crossvalscore(@logisticfit, @logisticpredict, X, y, options);
printf('Validation Scores (4) Accuracy: '); printf('%f ', scores);
```

`Validation Scores (4) Accuracy: 0.883721 0.860465 0.903509 0.888889`

## Comments

If return_models is set to true in options, then multiple model parameters are returned. Among those the best model parameters can be chosen using it's corresponding score. Such chosen parameters can be passed to predict function.