php-ml/docs/machine-learning/cross-validation/random-split.md

30 lines
792 B
Markdown
Raw Normal View History

2016-07-10 22:07:07 +00:00
# Random Split
2016-04-08 22:36:48 +00:00
One of the simplest methods from Cross-validation is implemented as `RandomSpilt` class. Samples are split to two groups: train group and test group. You can adjust the number of samples in each group.
2016-04-08 22:36:48 +00:00
### Constructor Parameters
* $dataset - object that implements `Dataset` interface
* $testSize - a fraction of test split (float, from 0 to 1, default: 0.3)
2016-07-10 22:07:07 +00:00
* $seed - seed for random generator (e.g. for tests)
2016-04-08 22:36:48 +00:00
```
$randomSplit = new RandomSplit($dataset, 0.2);
```
### Samples and labels groups
To get samples or labels from test and train group, you can use getters:
2016-04-08 22:36:48 +00:00
```
$dataset = new RandomSplit($dataset, 0.3, 1234);
// train group
$dataset->getTrainSamples();
$dataset->getTrainLabels();
// test group
$dataset->getTestSamples();
$dataset->getTestLabels();
```