kiudee / cs-ranking

Context-sensitive ranking and choice in Python with PyTorch
https://cs-ranking.readthedocs.io
Apache License 2.0
66 stars 15 forks source link

ChoiceDatasetGenerator can not be instantiated #166

Closed kiudee closed 4 years ago

kiudee commented 4 years ago

Trying to instantiate the ChoiceDatasetGenerator as described in our tutorial:

from csrank import ChoiceDatasetGenerator
seed = 12
n_train = 10000
n_test = 10000
n_features = 2
n_objects = 40
gen = ChoiceDatasetGenerator(dataset_type='pareto', random_state=seed,
                                n_train_instances=n_train,
                                n_test_instances=n_test,
                                n_objects=n_objects,
                                n_features=n_features)

fails with the error:

TypeError: Can't instantiate abstract class ChoiceDatasetGenerator with abstract methods get_train_test_datasets
timokau commented 4 years ago

get_train_test_datasets is marked as abstract in DatasetReader and is not overriden in ChoiceDatasetGenerator (or its superclass SyntheticDatasetGenerator).

DatasetReader does provide a default implementaiton for it though, based on the splitter function which is implemented in SyntheticDatasetGenerator. So it should be sufficient to just remove the abstractmethod marker for get_train_test_datasets.

timokau commented 4 years ago

Done in https://github.com/kiudee/cs-ranking/pull/167.