Ejemplo n.º 1
0
def test_create_clusters(dat, len_d, n_clust):
    d = DataPreparation(dat)
    pcs = PSC(d)
    clust = pcs._create_clusters(d.data_all, n_clust)
    # poss_clus = range(0,n_clust)
    assert len(clust) == len_d
    for i in clust:
        assert (i in range(0, n_clust)) == True
Ejemplo n.º 2
0
def test_n_classes(dataset, n_classes):
    """
    Check if number of classes in prepared data is apriopriate
    """
    n_cl = DataPreparation(dataset).n_classes
    assert n_cl == n_classes
Ejemplo n.º 3
0
from InstanceReduction.Raport import Raport
from InstanceReduction.DataPreparation import DataPreparation
from InstanceReduction.Reduction.ENN import ENN
from InstanceReduction.Reduction.DROP1 import DROP1
from InstanceReduction.Reduction.PSC import PSC
from InstanceReduction.Reduction.MSS import MSS
from InstanceReduction.Reduction.ICF import ICF

# filepath="D:\Studia\inz\datasets_csv\glass.csv", class_col='Type')#'iris')
data = DataPreparation('iris')
alg = DROP1(data)
print(alg.reduce_instances(return_time=True))

rap = Raport(data, alg.red_data, alg.red_lab)
# rap.draw_plots('Aattr', 'Battr', show = True, save = True) #,'sepallength','sepalwidth' 'Aattr', 'Battr' 'width', 'high'

# rap.draw_plots('mcv','drinks', show = True, save = True) #liver
# rap.draw_plots('sepallength','sepalwidth', show = True, save = True)

# rap.draw_plots('mcg','gvh', show = True, save = True) #yeast

# rap.draw_plots('x-box', 'y-box', show = True, save = True) #letter
# , norm=True) #c_type = 'all',show_cf_matrix = True, path ='', save_plots = False)
rap.print_raport(show_cf_matrix=False, save_cf_matrix=True)
Ejemplo n.º 4
0
def reduction_alg_iris(request):
    return request.param(DataPreparation('iris'))
Ejemplo n.º 5
0
def test_missing_values():
    with pytest.raises(Exception, match="Nan"):
        DataPreparation(filepath="tests\\test_csv\\missed.csv", sep = ";")
Ejemplo n.º 6
0
def data_iris():
    return DataPreparation('iris')
def test_load_file_rel_wd():
    """Check if load with absolute filepath with apriopriate other parameters (no missing values, existing class name etc.)
    """
    d = DataPreparation(filepath="InstanceReduction\datasets_csv\iris.csv")
    assert len(d.dataset) == 150
Ejemplo n.º 8
0
def test_empty(empty_csv):
    with pytest.raises(Exception, match="empty"):
        DataPreparation(filepath=empty_csv, sep = ";")
def test_load_named_wrong_name_types(wrong_name_types):
    with pytest.raises(TypeError):
        wg = DataPreparation(wrong_name_types)
def test_load_named_more():
    """Check loading data with apriopriate name of dataset and different args. Should take into account dataset name.
    Even if there is selected apriopriate filepath.
    """
    d= DataPreparation('iris', "D:\Studia\inz\Repos\DataReduction\InstanceReduction\datasets_csv\pendigits.csv")
    assert len(d.data_all) == 150
def test_load_named_wrong_name(wrong_names):
    with pytest.raises(ValueError):
        wg = DataPreparation(wrong_names)
Ejemplo n.º 12
0
def data_preparation_ok():
    return DataPreparation('iris')
Ejemplo n.º 13
0
def test_create_clusters_wrong_ncl(dat, len_d, n_clust):
    d = DataPreparation(dat)
    pcs = PSC(d)
    with pytest.raises(Exception):
        clust = pcs._create_clusters(d.data_all, n_clust)
Ejemplo n.º 14
0
def test_len_data_all(dataset_names, lenn):
    d = DataPreparation(dataset_names)
    assert len(d.data_all) == lenn
def test_load_empty():
    """Check raising Exception when no parameters select
    """
    with pytest.raises(Exception, match="without name or filepath"):
        d = DataPreparation()
Ejemplo n.º 16
0
def test_len_data_all(dataset_names, n_features):
    """ Check if number of fetutures is apriopriate
    """
    d = DataPreparation(dataset_names)
    assert len(d.features) == n_features
def test_load_file_not_found():
    """Check raising FileNotFoundError
    """
    with pytest.raises(FileNotFoundError):
        d = DataPreparation(filepath="InstanceReduction\datasets_csv\notexisting.csv")
Ejemplo n.º 18
0
def test_not_enough_cols():
    with pytest.raises(Exception, match="minimum 2 columns"):
        DataPreparation(filepath="tests\\test_csv\\one_col.csv", sep = ";")
def test_load_file_os():
    """Check raising OSError
    """
    with pytest.raises(OSError):
        d = DataPreparation(filepath="InstanceReduction")
Ejemplo n.º 20
0
def test_non_numeric():
    with pytest.raises(Exception, match="non numeric"):
        DataPreparation(filepath="tests\\test_csv\\non_numeric.csv", sep = ";")
def test_load_file_notcsv():
    """Check raising ValueError
    """
    with pytest.raises(ValueError):
        d = DataPreparation(filepath="D:\Studia\inz\download.pdf")
Ejemplo n.º 22
0
def data_prepar_iris(request):
    return DataPreparation('iris')
def test_load_file_wrong_sep(wrong_sep_types):
    """Check raising TypeError when wrong separator
    """
    with pytest.raises(TypeError):
        d = DataPreparation(filepath="InstanceReduction\datasets_csv\iris.csv", sep = wrong_sep_types)
Ejemplo n.º 24
0
def data(request):
    return DataPreparation(request.param)
Ejemplo n.º 25
0
def tmp_pcs(request):
    d = DataPreparation('iris')
    return PSC(d)