1
0
Fork 0

showing experiments

This commit is contained in:
Alejandro Moreo Fernandez 2024-04-03 16:24:55 +02:00
parent 1f3b1597dc
commit 21d052313c
7 changed files with 27 additions and 13 deletions

View File

@ -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.format.mean_prec = 4
table.format.show_std = False
table.format.sta = False
# table.format = False
table.format.remove_zero = True
for q_name, q in quantifiers():

View File

@ -14,9 +14,11 @@ from copy import deepcopy
np.set_printoptions(linewidth=np.inf)
def classifier():
return LogisticRegression()
def quantifiers():
cls = classifier()
# yield 'MLPE', MLPE()
@ -26,7 +28,7 @@ def quantifiers():
yield 'PACC', PACC(cls)
yield 'MS', MS(cls)
# yield 'MS2', MS2(cls)
# yield 'SLD', EMQ(cls)
yield 'SLD', EMQ(cls)
survey_y = './data/survey_y.csv'

View File

@ -12,9 +12,11 @@ import quapy as qp
np.set_printoptions(linewidth=np.inf)
def classifier():
return LogisticRegressionCV()
def quantifiers():
cls = classifier()
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.format.mean_prec = 4
table.format.show_std = False
table.format.sta = False
table.format.stat_test = False
table.format.remove_zero = True
for q_name, q in quantifiers():

View File

@ -1,15 +1,18 @@
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 table import Table
from tqdm import tqdm
np.set_printoptions(linewidth=np.inf)
def classifiers():
yield 'LR-opt', LogisticRegressionCV(class_weight='balanced', Cs=10)
yield 'LR-def', LogisticRegressionCV()
yield 'LR-opt', LogisticRegressionCV(Cs=10)
yield 'LR-opt-bal', LogisticRegressionCV(class_weight='balanced', Cs=10)
yield 'LR-def', LogisticRegression()
yield 'SVM-linear', LinearSVC()
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.format.mean_prec = 4
table.format.show_std = False
table.format.sta = False
table.format.stat_test = False
table.format.remove_zero = True
for i, (Ai, Xi, yi) in tqdm(enumerate(trains), total=n_areas):

View File

@ -18,8 +18,8 @@ def load_csv(file, use_yhat=True):
X = df[covariates].values
A = df[cod_area].values
# for i, cov in enumerate(covariates):
# print(f'values of col {i} "{cov}" {np.unique(X[:,i])}')
for i, cov in enumerate(covariates):
print(f'values of col {i} "{cov}" {np.unique(X[:,i])}')
if y_true in df.columns:
y = df[y_true].values

View File

@ -3,7 +3,7 @@ from sklearn.linear_model import LogisticRegressionCV
from quapy.data import LabelledCollection
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 table import Table
from tqdm import tqdm
@ -22,6 +22,7 @@ def quantifiers():
yield 'PCC', PCC(cls)
yield 'ACC', ACC(cls)
yield 'PACC', PACC(cls)
yield 'SLD', SLD(cls)
survey_y = './data/survey_y.csv'
@ -69,6 +70,8 @@ for q_name, q in quantifiers():
for test in benchmarks:
values = table.get_benchmark_values(test)
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)

View File

@ -430,7 +430,7 @@ class Table:
return Table.LatexPDF(pdf_path, tables=[self], tabular_dir=tabular_dir, *args, **kwargs)
@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.append('\\documentclass[10pt,a4paper]{article}')
lines.append('\\usepackage[utf8]{inputenc}')
@ -440,11 +440,14 @@ class Table:
lines.append('\\usepackage{graphicx}')
lines.append('\\usepackage{xcolor}')
lines.append('\\usepackage{colortbl}')
if landscape:
lines.append('\\usepackage[landscape]{geometry}')
lines.append('')
lines.append('\\begin{document}')
for table in tables:
lines.append('')
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}')
document = '\n'.join(lines)
@ -472,5 +475,6 @@ class Table:
os.chdir(dir)
os.system('pdflatex ' + Path(tex_path).name)
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)
print('[Done]')