nordlys.core.ml.cross_validation module¶
Cross Validation¶
Cross-validation support.
We assume that instances (i) are uniquely identified by an instance ID and (ii) they have id and score properties. We access them using the Instances class.
Authors: | Faegheh Hasibi, Krisztian Balog |
---|
-
class
nordlys.core.ml.cross_validation.
CrossValidation
(k, instances, callback_train, callback_test)[source]¶ Bases:
object
- Class attributes:
- fold: dict of folds (1..k) with a dict
- {“training”: [list of instance_ids]}, {“testing”: [list of instance_ids]}
Parameters: - k – number of folds
- instances – Instances object
- callback_train – Callback function for training model
- callback_test – Callback function for applying model
-
create_folds
(group_by=None)[source]¶ Creates folds for the data set.
Parameters: group_by – property to group by (instance_id by default)
-
get_folds
(filename=None, group_by=None)[source]¶ Loads folds from file or generates them if the file doesn’t exist.
Parameters: - filename –
- k – number of folds
Returns: