vDataFrame.train_test_split¶
In [ ]:
vDataFrame.train_test_split(test_size: float = 0.33,
order_by: (list, dict) = {},
random_state: int = None)
Creates two vDataFrames (train/test) that can be to use to evaluate a model. The intersection between the train and the test sets will only be empty if you specify a unique order_by.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
test_size | float | ✓ | Proportion of the test set compare to the training set. |
order_by | dict / list | ✓ | List of the vColumns to use to sort the data using ascending/descending order or a dictionary of all the sorting methods. Use this parameter to avoid collisions with the seeded random number used to split the data into train and test sets. For example, to sort by "column1" ASC and "column2" DESC, use {"column1": "asc", "column2": "desc"}. |
random_state | int | ✓ | Integer used to initialize the random number generator. |
Returns¶
tuple : (train vDataFrame, test vDataFrame)
Example¶
In [1]:
from verticapy.datasets import load_titanic
titanic = load_titanic()
display(titanic)
In [2]:
train, test = titanic.train_test_split()
In [5]:
test.shape()
Out[5]:
In [4]:
train.shape()
Out[4]:
