forked from moreo/QuaPy
showing experiments
This commit is contained in:
parent
1f3b1597dc
commit
21d052313c
|
@ -52,7 +52,7 @@ methods = [f'{q_name}-cat' for q_name in q_names]
|
||||||
table = Table(name='adjacentconcat', benchmarks=benchmarks, methods=methods, stat_test=None, color_mode='local')
|
table = Table(name='adjacentconcat', benchmarks=benchmarks, methods=methods, stat_test=None, color_mode='local')
|
||||||
table.format.mean_prec = 4
|
table.format.mean_prec = 4
|
||||||
table.format.show_std = False
|
table.format.show_std = False
|
||||||
table.format.sta = False
|
# table.format = False
|
||||||
table.format.remove_zero = True
|
table.format.remove_zero = True
|
||||||
|
|
||||||
for q_name, q in quantifiers():
|
for q_name, q in quantifiers():
|
||||||
|
|
|
@ -14,9 +14,11 @@ from copy import deepcopy
|
||||||
|
|
||||||
np.set_printoptions(linewidth=np.inf)
|
np.set_printoptions(linewidth=np.inf)
|
||||||
|
|
||||||
|
|
||||||
def classifier():
|
def classifier():
|
||||||
return LogisticRegression()
|
return LogisticRegression()
|
||||||
|
|
||||||
|
|
||||||
def quantifiers():
|
def quantifiers():
|
||||||
cls = classifier()
|
cls = classifier()
|
||||||
# yield 'MLPE', MLPE()
|
# yield 'MLPE', MLPE()
|
||||||
|
@ -26,7 +28,7 @@ def quantifiers():
|
||||||
yield 'PACC', PACC(cls)
|
yield 'PACC', PACC(cls)
|
||||||
yield 'MS', MS(cls)
|
yield 'MS', MS(cls)
|
||||||
# yield 'MS2', MS2(cls)
|
# yield 'MS2', MS2(cls)
|
||||||
# yield 'SLD', EMQ(cls)
|
yield 'SLD', EMQ(cls)
|
||||||
|
|
||||||
|
|
||||||
survey_y = './data/survey_y.csv'
|
survey_y = './data/survey_y.csv'
|
||||||
|
|
|
@ -12,9 +12,11 @@ import quapy as qp
|
||||||
|
|
||||||
np.set_printoptions(linewidth=np.inf)
|
np.set_printoptions(linewidth=np.inf)
|
||||||
|
|
||||||
|
|
||||||
def classifier():
|
def classifier():
|
||||||
return LogisticRegressionCV()
|
return LogisticRegressionCV()
|
||||||
|
|
||||||
|
|
||||||
def quantifiers():
|
def quantifiers():
|
||||||
cls = classifier()
|
cls = classifier()
|
||||||
yield 'MLPE', MLPE()
|
yield 'MLPE', MLPE()
|
||||||
|
@ -50,7 +52,7 @@ methods = [f'{q_name}-cat' for q_name in q_names]
|
||||||
table = Table(name='allconcat', benchmarks=benchmarks, methods=methods, stat_test=None, color_mode='local')
|
table = Table(name='allconcat', benchmarks=benchmarks, methods=methods, stat_test=None, color_mode='local')
|
||||||
table.format.mean_prec = 4
|
table.format.mean_prec = 4
|
||||||
table.format.show_std = False
|
table.format.show_std = False
|
||||||
table.format.sta = False
|
table.format.stat_test = False
|
||||||
table.format.remove_zero = True
|
table.format.remove_zero = True
|
||||||
|
|
||||||
for q_name, q in quantifiers():
|
for q_name, q in quantifiers():
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from sklearn.svm import SVC
|
from sklearn.linear_model import LogisticRegressionCV, LogisticRegression
|
||||||
|
from sklearn.svm import SVC, LinearSVC
|
||||||
|
|
||||||
from commons import *
|
from commons import *
|
||||||
from table import Table
|
from table import Table
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
|
||||||
np.set_printoptions(linewidth=np.inf)
|
np.set_printoptions(linewidth=np.inf)
|
||||||
|
|
||||||
def classifiers():
|
def classifiers():
|
||||||
yield 'LR-opt', LogisticRegressionCV(class_weight='balanced', Cs=10)
|
yield 'LR-opt', LogisticRegressionCV(Cs=10)
|
||||||
yield 'LR-def', LogisticRegressionCV()
|
yield 'LR-opt-bal', LogisticRegressionCV(class_weight='balanced', Cs=10)
|
||||||
|
yield 'LR-def', LogisticRegression()
|
||||||
yield 'SVM-linear', LinearSVC()
|
yield 'SVM-linear', LinearSVC()
|
||||||
yield 'SVM-rbf', SVC(kernel='rbf')
|
yield 'SVM-rbf', SVC(kernel='rbf')
|
||||||
|
|
||||||
|
@ -37,7 +40,7 @@ for cls_name, c in classifiers():
|
||||||
table = Table(name=cls_name, benchmarks=benchmarks, methods=methods, stat_test=None, color_mode='local', lower_is_better=False)
|
table = Table(name=cls_name, benchmarks=benchmarks, methods=methods, stat_test=None, color_mode='local', lower_is_better=False)
|
||||||
table.format.mean_prec = 4
|
table.format.mean_prec = 4
|
||||||
table.format.show_std = False
|
table.format.show_std = False
|
||||||
table.format.sta = False
|
table.format.stat_test = False
|
||||||
table.format.remove_zero = True
|
table.format.remove_zero = True
|
||||||
|
|
||||||
for i, (Ai, Xi, yi) in tqdm(enumerate(trains), total=n_areas):
|
for i, (Ai, Xi, yi) in tqdm(enumerate(trains), total=n_areas):
|
||||||
|
|
|
@ -18,8 +18,8 @@ def load_csv(file, use_yhat=True):
|
||||||
X = df[covariates].values
|
X = df[covariates].values
|
||||||
A = df[cod_area].values
|
A = df[cod_area].values
|
||||||
|
|
||||||
# for i, cov in enumerate(covariates):
|
for i, cov in enumerate(covariates):
|
||||||
# print(f'values of col {i} "{cov}" {np.unique(X[:,i])}')
|
print(f'values of col {i} "{cov}" {np.unique(X[:,i])}')
|
||||||
|
|
||||||
if y_true in df.columns:
|
if y_true in df.columns:
|
||||||
y = df[y_true].values
|
y = df[y_true].values
|
||||||
|
|
|
@ -3,7 +3,7 @@ from sklearn.linear_model import LogisticRegressionCV
|
||||||
|
|
||||||
from quapy.data import LabelledCollection
|
from quapy.data import LabelledCollection
|
||||||
from quapy.method.non_aggregative import MaximumLikelihoodPrevalenceEstimation as MLPE
|
from quapy.method.non_aggregative import MaximumLikelihoodPrevalenceEstimation as MLPE
|
||||||
from quapy.method.aggregative import CC, PCC, ACC, PACC, EMQ
|
from quapy.method.aggregative import CC, PCC, ACC, PACC, EMQ, SLD
|
||||||
from commons import *
|
from commons import *
|
||||||
from table import Table
|
from table import Table
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
@ -22,6 +22,7 @@ def quantifiers():
|
||||||
yield 'PCC', PCC(cls)
|
yield 'PCC', PCC(cls)
|
||||||
yield 'ACC', ACC(cls)
|
yield 'ACC', ACC(cls)
|
||||||
yield 'PACC', PACC(cls)
|
yield 'PACC', PACC(cls)
|
||||||
|
yield 'SLD', SLD(cls)
|
||||||
|
|
||||||
|
|
||||||
survey_y = './data/survey_y.csv'
|
survey_y = './data/survey_y.csv'
|
||||||
|
@ -69,6 +70,8 @@ for q_name, q in quantifiers():
|
||||||
for test in benchmarks:
|
for test in benchmarks:
|
||||||
values = table.get_benchmark_values(test)
|
values = table.get_benchmark_values(test)
|
||||||
table.add(benchmark=test, method='Best', v=min(values))
|
table.add(benchmark=test, method='Best', v=min(values))
|
||||||
|
table.add(benchmark=test, method='Worst', v=max(values))
|
||||||
|
table.add(benchmark=test, method='AVE', v=np.mean(values))
|
||||||
|
|
||||||
tables.append(table)
|
tables.append(table)
|
||||||
|
|
||||||
|
|
|
@ -430,7 +430,7 @@ class Table:
|
||||||
return Table.LatexPDF(pdf_path, tables=[self], tabular_dir=tabular_dir, *args, **kwargs)
|
return Table.LatexPDF(pdf_path, tables=[self], tabular_dir=tabular_dir, *args, **kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def Document(self, tex_path, tables:List['Table'], tabular_dir='tables', *args, **kwargs):
|
def Document(self, tex_path, tables:List['Table'], tabular_dir='tables', landscape=True, *args, **kwargs):
|
||||||
lines = []
|
lines = []
|
||||||
lines.append('\\documentclass[10pt,a4paper]{article}')
|
lines.append('\\documentclass[10pt,a4paper]{article}')
|
||||||
lines.append('\\usepackage[utf8]{inputenc}')
|
lines.append('\\usepackage[utf8]{inputenc}')
|
||||||
|
@ -440,11 +440,14 @@ class Table:
|
||||||
lines.append('\\usepackage{graphicx}')
|
lines.append('\\usepackage{graphicx}')
|
||||||
lines.append('\\usepackage{xcolor}')
|
lines.append('\\usepackage{xcolor}')
|
||||||
lines.append('\\usepackage{colortbl}')
|
lines.append('\\usepackage{colortbl}')
|
||||||
|
if landscape:
|
||||||
|
lines.append('\\usepackage[landscape]{geometry}')
|
||||||
lines.append('')
|
lines.append('')
|
||||||
lines.append('\\begin{document}')
|
lines.append('\\begin{document}')
|
||||||
for table in tables:
|
for table in tables:
|
||||||
lines.append('')
|
lines.append('')
|
||||||
lines.append(table.table(os.path.join(Path(tex_path).parent, tabular_dir, table.name + '_table.tex'), *args, **kwargs))
|
lines.append(table.table(os.path.join(Path(tex_path).parent, tabular_dir, table.name + '_table.tex'), *args, **kwargs))
|
||||||
|
lines.append('\n\\newpage\n')
|
||||||
lines.append('\\end{document}')
|
lines.append('\\end{document}')
|
||||||
|
|
||||||
document = '\n'.join(lines)
|
document = '\n'.join(lines)
|
||||||
|
@ -472,5 +475,6 @@ class Table:
|
||||||
os.chdir(dir)
|
os.chdir(dir)
|
||||||
os.system('pdflatex ' + Path(tex_path).name)
|
os.system('pdflatex ' + Path(tex_path).name)
|
||||||
basename = Path(tex_path).name.replace('.tex', '')
|
basename = Path(tex_path).name.replace('.tex', '')
|
||||||
os.system(f'rm {basename}.aux {basename}.bbl {basename}.blg {basename}.log {basename}.out {basename}.dvi')
|
os.system(f'rm {basename}.aux {basename}.log')
|
||||||
os.chdir(pwd)
|
os.chdir(pwd)
|
||||||
|
print('[Done]')
|
Loading…
Reference in New Issue