Tests
This commit is contained in:
parent
44cec7a046
commit
8f284e540a
|
@ -6,13 +6,27 @@ from quapy.data.datasets import REVIEWS_SENTIMENT_DATASETS, TWITTER_SENTIMENT_DA
|
|||
|
||||
@pytest.mark.parametrize('dataset_name', REVIEWS_SENTIMENT_DATASETS)
|
||||
def test_fetch_reviews(dataset_name):
|
||||
fetch_reviews(dataset_name)
|
||||
dataset = fetch_reviews(dataset_name)
|
||||
print(dataset.n_classes, len(dataset.training), len(dataset.test))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('dataset_name', TWITTER_SENTIMENT_DATASETS_TEST + TWITTER_SENTIMENT_DATASETS_TRAIN)
|
||||
def test_fetch_twitter(dataset_name):
|
||||
fetch_twitter(dataset_name)
|
||||
try:
|
||||
dataset = fetch_twitter(dataset_name)
|
||||
except ValueError as ve:
|
||||
if dataset_name == 'semeval' and ve.args[0].startswith(
|
||||
'dataset "semeval" can only be used for model selection.'):
|
||||
dataset = fetch_twitter(dataset_name, for_model_selection=True)
|
||||
print(dataset.n_classes, len(dataset.training), len(dataset.test))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('dataset_name', UCI_DATASETS)
|
||||
def test_fetch_UCIDataset(dataset_name):
|
||||
fetch_UCIDataset(dataset_name)
|
||||
try:
|
||||
dataset = fetch_UCIDataset(dataset_name)
|
||||
except FileNotFoundError as fnfe:
|
||||
if dataset_name == 'pageblocks.5' and fnfe.args[0].find(
|
||||
'If this is the first time you attempt to load this dataset') > 0:
|
||||
return
|
||||
print(dataset.n_classes, len(dataset.training), len(dataset.test))
|
||||
|
|
|
@ -5,20 +5,23 @@ from sklearn.naive_bayes import MultinomialNB
|
|||
from sklearn.svm import LinearSVC
|
||||
|
||||
import quapy as qp
|
||||
from quapy.method import AGGREGATIVE_METHODS
|
||||
|
||||
datasets = [qp.datasets.fetch_twitter('semeval16')]
|
||||
|
||||
aggregative_methods = [qp.method.aggregative.CC, qp.method.aggregative.ACC, qp.method.aggregative.ELM]
|
||||
datasets = [pytest.param(qp.datasets.fetch_twitter('hcr'), id='hcr'),
|
||||
pytest.param(qp.datasets.fetch_UCIDataset('ionosphere'), id='ionosphere')]
|
||||
|
||||
learners = [LogisticRegression, MultinomialNB, LinearSVC]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('dataset', datasets)
|
||||
@pytest.mark.parametrize('aggregative_method', aggregative_methods)
|
||||
@pytest.mark.parametrize('aggregative_method', AGGREGATIVE_METHODS)
|
||||
@pytest.mark.parametrize('learner', learners)
|
||||
def test_aggregative_methods(dataset, aggregative_method, learner):
|
||||
model = aggregative_method(learner())
|
||||
|
||||
if model.binary and not dataset.binary:
|
||||
return
|
||||
|
||||
model.fit(dataset.training)
|
||||
|
||||
estim_prevalences = model.quantify(dataset.test.instances)
|
||||
|
|
Loading…
Reference in New Issue