Skip to content
Snippets Groups Projects
Commit cf34b931 authored by Baptiste Bauvin's avatar Baptiste Bauvin
Browse files

Corrected cross val multiview

parent 74ce73a8
No related branches found
No related tags found
No related merge requests found
Pipeline #3898 failed
# The base configuration of the benchmark # The base configuration of the benchmark
Base : Base :
log: True log: True
name: ["outliers_dset"] name: ["awa-tiger-wolf-all"]
label: "_" label: "_"
type: ".hdf5" type: ".hdf5"
views: views:
pathf: "/home/baptiste/Documents/Datasets/Generated/outliers_dset/" pathf: "/home/baptiste/Documents/Datasets/AWA/base/"
nice: 0 nice: 0
random_state: 42 random_state: 42
nb_cores: 1 nb_cores: 1
...@@ -18,16 +18,16 @@ Base : ...@@ -18,16 +18,16 @@ Base :
# All the classification-realted configuration options # All the classification-realted configuration options
Classification: Classification:
multiclass_method: "oneVersusOne" multiclass_method: "oneVersusOne"
split: 0.2 split: 0.9
nb_folds: 2 nb_folds: 2
nb_class: 2 nb_class: 2
classes: classes:
type: ["monoview", "multiview"] type: ["multiview", "monoview"]
algos_monoview: ["decision_tree", "adaboost", "svm_linear", "random_forest"] algos_monoview: ["decision_tree", "adaboost", "random_forest" ]
algos_multiview: ["weighted_linear_early_fusion", "difficulty_fusion", "double_fault_fusion"] algos_multiview: ["weighted_linear_early_fusion",]
stats_iter: 30 stats_iter: 1
metrics: ["accuracy_score", "f1_score"] metrics: ["accuracy_score", "f1_score"]
metric_princ: "accuracy_score" metric_princ: "f1_score"
hps_type: "randomized_search-equiv" hps_type: "randomized_search-equiv"
hps_iter: 5 hps_iter: 5
...@@ -65,7 +65,7 @@ adaboost_graalpy: ...@@ -65,7 +65,7 @@ adaboost_graalpy:
n_stumps: [1] n_stumps: [1]
decision_tree: decision_tree:
max_depth: [10] max_depth: [2]
criterion: ["gini"] criterion: ["gini"]
splitter: ["best"] splitter: ["best"]
......
...@@ -34,7 +34,7 @@ class WeightedLinearEarlyFusion(BaseMultiviewClassifier, BaseFusionClassifier): ...@@ -34,7 +34,7 @@ class WeightedLinearEarlyFusion(BaseMultiviewClassifier, BaseFusionClassifier):
super(WeightedLinearEarlyFusion, self).__init__(random_state=random_state) super(WeightedLinearEarlyFusion, self).__init__(random_state=random_state)
self.view_weights = view_weights self.view_weights = view_weights
self.monoview_classifier_name = monoview_classifier_name self.monoview_classifier_name = monoview_classifier_name
self.short_name = "early fusion " + monoview_classifier_name self.short_name = "early fusion " + self.monoview_classifier_name
if monoview_classifier_name in monoview_classifier_config: if monoview_classifier_name in monoview_classifier_config:
self.monoview_classifier_config = monoview_classifier_config[monoview_classifier_name] self.monoview_classifier_config = monoview_classifier_config[monoview_classifier_name]
self.monoview_classifier_config = monoview_classifier_config self.monoview_classifier_config = monoview_classifier_config
...@@ -59,6 +59,7 @@ class WeightedLinearEarlyFusion(BaseMultiviewClassifier, BaseFusionClassifier): ...@@ -59,6 +59,7 @@ class WeightedLinearEarlyFusion(BaseMultiviewClassifier, BaseFusionClassifier):
self.monoview_classifier = monoview_classifier_class() self.monoview_classifier = monoview_classifier_class()
self.init_monoview_estimator(monoview_classifier_name, self.init_monoview_estimator(monoview_classifier_name,
monoview_classifier_config) monoview_classifier_config)
self.short_name = "early fusion " + self.monoview_classifier_name
return self return self
def get_params(self, deep=True): def get_params(self, deep=True):
......
...@@ -4,6 +4,7 @@ import logging ...@@ -4,6 +4,7 @@ import logging
import os import os
import time import time
import yaml import yaml
import traceback
import matplotlib as mpl import matplotlib as mpl
from matplotlib.patches import Patch from matplotlib.patches import Patch
...@@ -162,6 +163,8 @@ def plot_metric_scores(train_scores, test_scores, names, nb_results, metric_name ...@@ -162,6 +163,8 @@ def plot_metric_scores(train_scores, test_scores, names, nb_results, metric_name
)) ))
fig.update_layout(title=metric_name + "\n" + tag + " scores for each classifier") fig.update_layout(title=metric_name + "\n" + tag + " scores for each classifier")
fig.update_layout(paper_bgcolor = 'rgba(0,0,0,0)',
plot_bgcolor = 'rgba(0,0,0,0)')
plotly.offline.plot(fig, filename=file_name + ".html", auto_open=False) plotly.offline.plot(fig, filename=file_name + ".html", auto_open=False)
del fig del fig
...@@ -232,7 +235,8 @@ def plot_2d(data, classifiers_names, nbClassifiers, nbExamples, ...@@ -232,7 +235,8 @@ def plot_2d(data, classifiers_names, nbClassifiers, nbExamples,
reversescale=True), row=row_index+1, col=1) reversescale=True), row=row_index+1, col=1)
fig.update_yaxes(title_text="Label "+str(row_index), showticklabels=False, ticks='', row=row_index+1, col=1) fig.update_yaxes(title_text="Label "+str(row_index), showticklabels=False, ticks='', row=row_index+1, col=1)
fig.update_xaxes(showticklabels=False, row=row_index+1, col=1) fig.update_xaxes(showticklabels=False, row=row_index+1, col=1)
fig.update_layout(paper_bgcolor = 'rgba(0,0,0,0)',
plot_bgcolor = 'rgba(0,0,0,0)')
fig.update_xaxes(showticklabels=True, row=len(label_index_list), col=1) fig.update_xaxes(showticklabels=True, row=len(label_index_list), col=1)
plotly.offline.plot(fig, filename=file_name + "error_analysis_2D.html", auto_open=False) plotly.offline.plot(fig, filename=file_name + "error_analysis_2D.html", auto_open=False)
del fig del fig
...@@ -629,6 +633,8 @@ def publish_feature_importances(feature_importances, directory, database_name, l ...@@ -629,6 +633,8 @@ def publish_feature_importances(feature_importances, directory, database_name, l
fig.update_layout( fig.update_layout(
xaxis={"showgrid": False, "showticklabels": False, "ticks": ''}, xaxis={"showgrid": False, "showticklabels": False, "ticks": ''},
yaxis={"showgrid": False, "showticklabels": False, "ticks": ''}) yaxis={"showgrid": False, "showticklabels": False, "ticks": ''})
fig.update_layout(paper_bgcolor = 'rgba(0,0,0,0)',
plot_bgcolor = 'rgba(0,0,0,0)')
plotly.offline.plot(fig, filename=file_name + ".html", auto_open=False) plotly.offline.plot(fig, filename=file_name + ".html", auto_open=False)
del fig del fig
...@@ -724,7 +730,7 @@ def analyze_biclass(results, benchmark_argument_dictionaries, stats_iter, metric ...@@ -724,7 +730,7 @@ def analyze_biclass(results, benchmark_argument_dictionaries, stats_iter, metric
logging.debug("Srart:\t Analzing all biclass resuls") logging.debug("Srart:\t Analzing all biclass resuls")
biclass_results = {} biclass_results = {}
flagged_tracebacks_list = [] flagged_tracebacks_list = []
fig_errors = []
for flag, result, tracebacks in results: for flag, result, tracebacks in results:
iteridex, [classifierPositive, classifierNegative] = flag iteridex, [classifierPositive, classifierNegative] = flag
...@@ -739,14 +745,13 @@ def analyze_biclass(results, benchmark_argument_dictionaries, stats_iter, metric ...@@ -739,14 +745,13 @@ def analyze_biclass(results, benchmark_argument_dictionaries, stats_iter, metric
labels_names = [arguments["labels_dictionary"][0], labels_names = [arguments["labels_dictionary"][0],
arguments["labels_dictionary"][1]] arguments["labels_dictionary"][1]]
flagged_tracebacks_list += publish_tracebacks(directory, database_name, labels_names, tracebacks, flag)
results = publishMetricsGraphs(metrics_scores, directory, database_name, results = publishMetricsGraphs(metrics_scores, directory, database_name,
labels_names) labels_names)
publishExampleErrors(example_errors, directory, database_name, publishExampleErrors(example_errors, directory, database_name,
labels_names, example_ids, arguments["labels"]) labels_names, example_ids, arguments["labels"])
publish_feature_importances(feature_importances, directory, database_name, labels_names) publish_feature_importances(feature_importances, directory, database_name, labels_names)
flagged_tracebacks_list += publish_tracebacks(directory, database_name, labels_names, tracebacks, flag)
if not str(classifierPositive) + str(classifierNegative) in biclass_results: if not str(classifierPositive) + str(classifierNegative) in biclass_results:
biclass_results[str(classifierPositive) + str(classifierNegative)] = {} biclass_results[str(classifierPositive) + str(classifierNegative)] = {}
......
...@@ -180,12 +180,12 @@ class MultiviewCompatibleRandomizedSearchCV(RandomizedSearchCV): ...@@ -180,12 +180,12 @@ class MultiviewCompatibleRandomizedSearchCV(RandomizedSearchCV):
def fit_multiview(self, X, y=None, groups=None, **fit_params): def fit_multiview(self, X, y=None, groups=None, **fit_params):
n_splits = self.cv.get_n_splits(self.available_indices, y[self.available_indices]) n_splits = self.cv.get_n_splits(self.available_indices, y[self.available_indices])
folds = self.cv.split(self.available_indices, y[self.available_indices]) folds = list(self.cv.split(self.available_indices, y[self.available_indices]))
if self.equivalent_draws:
self.n_iter = self.n_iter*X.nb_view
candidate_params = list(self._get_param_iterator()) candidate_params = list(self._get_param_iterator())
base_estimator = clone(self.estimator) base_estimator = clone(self.estimator)
results = {} results = {}
if self.equivalent_draws:
self.n_iter = self.n_iter*X.nb_view
self.cv_results_ = dict(("param_"+param_name, []) for param_name in candidate_params[0].keys()) self.cv_results_ = dict(("param_"+param_name, []) for param_name in candidate_params[0].keys())
self.cv_results_["mean_test_score"] = [] self.cv_results_["mean_test_score"] = []
for candidate_param_idx, candidate_param in enumerate(candidate_params): for candidate_param_idx, candidate_param in enumerate(candidate_params):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment