From 8a48325e2ee29c447a870723fa2d514af4341afa Mon Sep 17 00:00:00 2001
From: Baptiste Bauvin <baptiste.bauvin@lis-lab.fr>
Date: Thu, 17 Oct 2019 08:07:33 -0400
Subject: [PATCH] Removed canprobas

---
 .../monoview_classifiers/adaboost.py          | 18 +++++------
 .../monoview_classifiers/adaboost_graalpy.py  | 18 +++++------
 .../monoview_classifiers/adaboost_pregen.py   | 18 +++++------
 .../monoview_classifiers/cb_boost.py          | 20 ++++++------
 .../monoview_classifiers/cg_desc.py           |  6 ++--
 .../monoview_classifiers/cq_boost.py          |  6 ++--
 .../monoview_classifiers/decision_tree.py     |  6 ++--
 .../decision_tree_pregen.py                   |  6 ++--
 .../monoview_classifiers/gradient_boosting.py |  6 ++--
 .../monoview_classifiers/knn.py               |  6 ++--
 .../monoview_classifiers/lasso.py             | 18 +++++------
 .../monoview_classifiers/min_cq.py            |  6 ++--
 .../monoview_classifiers/min_cq_graalpy.py    | 16 +++++-----
 .../min_cq_graalpy_tree.py                    | 18 +++++------
 .../monoview_classifiers/random_forest.py     | 16 +++++-----
 .../monoview_classifiers/scm.py               | 18 +++++------
 .../monoview_classifiers/scm_pregen.py        | 18 +++++------
 .../monoview_classifiers/sgd.py               | 20 ++++++------
 .../multiview/multiview_utils.py              |  5 +--
 .../utils/configuration.py                    |  4 ---
 .../utils/dataset.py                          | 32 +++++++++++++++++++
 21 files changed, 155 insertions(+), 126 deletions(-)

diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost.py
index 2b3d6423..6fa78da0 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost.py
@@ -99,15 +99,15 @@ class Adaboost(AdaBoostClassifier, BaseMonoviewClassifier):
                                  self.staged_predict(X)])
         return self
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        True
-        """
-        return True
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     True
+    #     """
+    #     return True
 
     def predict(self, X):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost_graalpy.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost_graalpy.py
index f298906b..3ea72675 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost_graalpy.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost_graalpy.py
@@ -225,15 +225,15 @@ class AdaboostGraalpy(AdaBoostGP, BaseMonoviewClassifier):
         else:
             self.nbCores = kwargs["nbCores"]
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        True in any case
-        """
-        return True
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     True in any case
+    #     """
+    #     return True
 
     def getInterpret(self, directory, y_test):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost_pregen.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost_pregen.py
index b2949535..cc23071d 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost_pregen.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/adaboost_pregen.py
@@ -130,15 +130,15 @@ class AdaboostPregen(AdaBoostClassifier, BaseMonoviewClassifier,
                                 for i in
                                 range(self.estimator_errors_.shape[0])])
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        True
-        """
-        return True
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     True
+    #     """
+    #     return True
 
     def predict(self, X):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cb_boost.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cb_boost.py
index 4f094aac..640b57f1 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cb_boost.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cb_boost.py
@@ -36,7 +36,7 @@ class CBBoost(CBBoostClassifier, BaseMonoviewClassifier):
         super(CBBoost, self).__init__(n_max_iterations=n_max_iterations,
                                      random_state=random_state,
                                      self_complemented=True,
-                                     twice_the_same=True,
+                                     twice_the_same=False,
                                      random_start=False,
                                      n_stumps=n_stumps,
                                      c_bound_sol=True,
@@ -49,15 +49,15 @@ class CBBoost(CBBoostClassifier, BaseMonoviewClassifier):
         self.classed_params = []
         self.weird_strings = {}
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        True
-        """
-        return True
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     True
+    #     """
+    #     return True
 
 
     def getInterpret(self, directory, y_test):
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cg_desc.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cg_desc.py
index e0d8cac9..6f5424db 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cg_desc.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cg_desc.py
@@ -43,9 +43,9 @@ class CGDesc(ColumnGenerationClassifierQar, BaseMonoviewClassifier):
         self.classed_params = []
         self.weird_strings = {}
 
-    def canProbas(self):
-        """Used to know if the classifier can return label probabilities"""
-        return False
+    # def canProbas(self):
+    #     """Used to know if the classifier can return label probabilities"""
+    #     return False
 
     def getInterpret(self, directory, y_test):
         return self.getInterpretQar(directory, y_test)
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cq_boost.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cq_boost.py
index 8d8d6e56..fc9b44ed 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cq_boost.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/cq_boost.py
@@ -35,9 +35,9 @@ class CQBoost(ColumnGenerationClassifier, BaseMonoviewClassifier):
         else:
             self.nbCores = kwargs["nbCores"]
 
-    def canProbas(self):
-        """Used to know if the classifier can return label probabilities"""
-        return False
+    # def canProbas(self):
+    #     """Used to know if the classifier can return label probabilities"""
+    #     return False
 
     def getInterpret(self, directory, y_test):
         np.savetxt(directory + "train_metrics.csv", self.train_metrics,
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/decision_tree.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/decision_tree.py
index 7684d579..0e3e2f3e 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/decision_tree.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/decision_tree.py
@@ -27,9 +27,9 @@ class DecisionTree(DecisionTreeClassifier, BaseMonoviewClassifier):
                          ["best", "random"], [random_state]]
         self.weird_strings = {}
 
-    def canProbas(self):
-        """Used to know if the classifier can return label probabilities"""
-        return True
+    # def canProbas(self):
+    #     """Used to know if the classifier can return label probabilities"""
+    #     return True
 
     def getInterpret(self, directory, y_test):
         interpretString = ""
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/decision_tree_pregen.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/decision_tree_pregen.py
index 4b67520e..0c157daf 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/decision_tree_pregen.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/decision_tree_pregen.py
@@ -59,9 +59,9 @@ class DecisionTreePregen(DecisionTreeClassifier, BaseMonoviewClassifier,
         self.pred_time = end - begin
         return change_label_to_zero(pred)
 
-    def canProbas(self):
-        """Used to know if the classifier can return label probabilities"""
-        return False
+    # def canProbas(self):
+    #     """Used to know if the classifier can return label probabilities"""
+    #     return False
 
     def getInterpret(self, directory, y_test):
         interpretString = ""
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/gradient_boosting.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/gradient_boosting.py
index 14d2670b..654142fb 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/gradient_boosting.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/gradient_boosting.py
@@ -69,9 +69,9 @@ class GradientBoosting(GradientBoostingClassifier, BaseMonoviewClassifier):
                 [step_pred for step_pred in self.staged_predict(X)])
         return pred
 
-    def canProbas(self):
-        """Used to know if the classifier can return label probabilities"""
-        return False
+    # def canProbas(self):
+    #     """Used to know if the classifier can return label probabilities"""
+    #     return False
 
     def getInterpret(self, directory, y_test):
         interpretString = ""
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/knn.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/knn.py
index e95be5ac..197b9a7c 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/knn.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/knn.py
@@ -42,9 +42,9 @@ class KNN(KNeighborsClassifier, BaseMonoviewClassifier):
         self.weird_strings = {}
         self.random_state = random_state
 
-    def canProbas(self):
-        """Used to know if the classifier can return label probabilities"""
-        return True
+    # def canProbas(self):
+    #     """Used to know if the classifier can return label probabilities"""
+    #     return True
 
     def getInterpret(self, directory, y_test):
         interpretString = ""
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/lasso.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/lasso.py
index 5f1361bf..0af82bc6 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/lasso.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/lasso.py
@@ -71,15 +71,15 @@ class Lasso(LassoSK, BaseMonoviewClassifier):
         signed[np.where(signed == -1)] = 0
         return signed
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        False
-        """
-        return False
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     False
+    #     """
+    #     return False
 
     def getInterpret(self, directory, y_test):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq.py
index 6956a855..ec0bd7e7 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq.py
@@ -610,9 +610,9 @@ class MinCQ(MinCqLearner, BaseMonoviewClassifier):
         else:
             self.nbCores = kwargs["nbCores"]
 
-    def canProbas(self):
-        """Used to know if the classifier can return label probabilities"""
-        return True
+    # def canProbas(self):
+    #     """Used to know if the classifier can return label probabilities"""
+    #     return True
 
     def set_params(self, **params):
         self.mu = params["mu"]
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq_graalpy.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq_graalpy.py
index ddae76cb..8355dffc 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq_graalpy.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq_graalpy.py
@@ -60,14 +60,14 @@ class MinCQGraalpy(RegularizedBinaryMinCqClassifier, BaseMonoviewClassifier):
         else:
             self.nbCores = kwargs["nbCores"]
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-        Returns
-        -------
-        False
-        """
-        return False
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #     Returns
+    #     -------
+    #     False
+    #     """
+    #     return False
 
     def set_params(self, **params):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq_graalpy_tree.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq_graalpy_tree.py
index 3e0f370a..ac7a409d 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq_graalpy_tree.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/min_cq_graalpy_tree.py
@@ -65,15 +65,15 @@ class MinCQGraalpyTree(RegularizedBinaryMinCqClassifier,
         else:
             self.nbCores = kwargs["nbCores"]
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        True
-        """
-        return True
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     True
+    #     """
+    #     return True
 
     def set_params(self, **params):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/random_forest.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/random_forest.py
index 95c16e92..a8290870 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/random_forest.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/random_forest.py
@@ -64,14 +64,14 @@ class RandomForest(RandomForestClassifier, BaseMonoviewClassifier):
                          ["gini", "entropy"], [random_state]]
         self.weird_strings = {}
 
-    def canProbas(self):
-        """Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        True
-        """
-        return True
+    # def canProbas(self):
+    #     """Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     True
+    #     """
+    #     return True
 
     def getInterpret(self, directory, y_test):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/scm.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/scm.py
index 8cae0d38..eb829fb9 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/scm.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/scm.py
@@ -92,15 +92,15 @@ class SCM(scm, BaseMonoviewClassifier):
         self.classed_params = []
         self.weird_strings = {}
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        return False in any case
-        """
-        return False
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     return False in any case
+    #     """
+    #     return False
 
     def getInterpret(self, directory, y_test):
         interpretString = "Model used : " + str(self.model_)
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/scm_pregen.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/scm_pregen.py
index 36357707..4b7ea990 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/scm_pregen.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/scm_pregen.py
@@ -158,15 +158,15 @@ class SCMPregen(BaseMonoviewClassifier, PregenClassifier, scm):
         os.remove(file_name)
         return self.classes_[self.model_.predict(place_holder)]
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-        Returns
-        -------
-        False in any case
-        """
-
-        return False
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #     Returns
+    #     -------
+    #     False in any case
+    #     """
+    #
+    #     return False
 
     def getInterpret(self, directory, y_test):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/sgd.py b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/sgd.py
index 2418b13f..4d77b7fd 100644
--- a/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/sgd.py
+++ b/multiview_platform/mono_multi_view_classifiers/monoview_classifiers/sgd.py
@@ -52,16 +52,16 @@ class SGD(SGDClassifier, BaseMonoviewClassifier):
                          CustomUniform(loc=0, state=1), [random_state]]
         self.weird_strings = {}
 
-    def canProbas(self):
-        """
-        Used to know if the classifier can return label probabilities
-
-        Returns
-        -------
-        return True in all case
-        """
-
-        return True
+    # def canProbas(self):
+    #     """
+    #     Used to know if the classifier can return label probabilities
+    #
+    #     Returns
+    #     -------
+    #     return True in all case
+    #     """
+    #
+    #     return True
 
     def getInterpret(self, directory, y_test):
         """
diff --git a/multiview_platform/mono_multi_view_classifiers/multiview/multiview_utils.py b/multiview_platform/mono_multi_view_classifiers/multiview/multiview_utils.py
index 5a2deaa3..8006f46e 100644
--- a/multiview_platform/mono_multi_view_classifiers/multiview/multiview_utils.py
+++ b/multiview_platform/mono_multi_view_classifiers/multiview/multiview_utils.py
@@ -148,8 +148,9 @@ def get_available_monoview_classifiers(need_probas=False):
         proba_classifiers = []
         for module_name in available_classifiers:
             module = getattr(monoview_classifiers, module_name)
-            can_probas = getattr(module, module.classifier_class_name)().canProbas()
-            if can_probas:
+            classifier_class = getattr(module, module.classifier_class_name)()
+            proba_prediction = getattr(classifier_class, "predict_proba", None)
+            if callable(proba_prediction):
                 proba_classifiers.append(module_name)
         available_classifiers = proba_classifiers
     return available_classifiers
diff --git a/multiview_platform/mono_multi_view_classifiers/utils/configuration.py b/multiview_platform/mono_multi_view_classifiers/utils/configuration.py
index 04b38548..a492aff7 100644
--- a/multiview_platform/mono_multi_view_classifiers/utils/configuration.py
+++ b/multiview_platform/mono_multi_view_classifiers/utils/configuration.py
@@ -6,10 +6,6 @@ import os
 
 def get_the_args(path_to_config_file="../config_files/config.yml"):
     """This is the main function for extracting the args for a '.yml' file"""
-    # config_path = os.path.dirname(os.path.abspath(__file__))
-    # config_path = os.path.join(config_path, "../..")
-    # path_to_config_file = os.path.join(config_path, path_to_config_file)
-
     with open(path_to_config_file, 'r') as stream:
         yaml_config = yaml.safe_load(stream)
     return yaml_config
diff --git a/multiview_platform/mono_multi_view_classifiers/utils/dataset.py b/multiview_platform/mono_multi_view_classifiers/utils/dataset.py
index 7a4cb476..e5f204a9 100644
--- a/multiview_platform/mono_multi_view_classifiers/utils/dataset.py
+++ b/multiview_platform/mono_multi_view_classifiers/utils/dataset.py
@@ -12,12 +12,44 @@ from scipy import sparse
 
 
 class Dataset():
+    """
+    Dataset
+
+    This class
+
+
+    Parameters
+    ----------
+    views
+    labels
+    are_sparse
+    file_name
+    view_names
+    path
+    hdf5_file
+    labels_names
+    is_temp
+    """
 
     # The following methods use hdf5
 
     def __init__(self, views=None, labels=None, are_sparse=False,
                  file_name="dataset.hdf5", view_names=None, path="",
                  hdf5_file=None, labels_names=None, is_temp=False):
+        """
+
+        Parameters
+        ----------
+        views
+        labels
+        are_sparse
+        file_name
+        view_names
+        path
+        hdf5_file
+        labels_names
+        is_temp
+        """
         self.is_temp = False
         if hdf5_file is not None:
             self.dataset=hdf5_file
-- 
GitLab