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 2b3d6423b56e60d7727609af9e42963fe5250b67..6fa78da0ce33f2b53ee2f80fecfe7f59efcad83d 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 f298906be826e769406d30fe75bf0e48cfd74a13..3ea726756552ef3a00f3feb4944e8301c73b28be 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 b29495352ce8a69edeff51d0f30e68b7db835288..cc23071d62dc49bf287eb3d4fb3f7b4e7723b7c6 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 4f094aac6f5e715c15d2f4fc2ec4d53f5b390bf0..640b57f1dad47790366640bb79dd7e0b36743406 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 e0d8cac9bf54fe4d5efa2c6e14f778220ca2461d..6f5424db597f38e0f8a0ef5831ab971acd2128d5 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 8d8d6e5601ac42e48486f607452c8dc849b26b13..fc9b44ed7d608d61b084d1915a6ee6084dbea05a 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 7684d579508564fe9570ad048edf410528f91946..0e3e2f3e5ca55311c49a6f95a9535bf2045c6ce8 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 4b67520ec79f2617bf68c0923facbddbb0686ea8..0c157daffbb7792991cc75aa45c85acb067b71ce 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 14d2670bec0f84c50c6c0afdd023d8f1c93274fe..654142fb080cacdbaec8804c07690abb265bd343 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 e95be5ac9b45442ad4880f437ae04a12d96ed6d5..197b9a7cd1d4d53dcbf9ff47bbfec4defe97600d 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 5f1361bf6652112da8bc8a3d8a1b4f06628d3d8f..0af82bc6ba94876281c42c6579e89937f8dfe53b 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 6956a8553ec0899bf1dbe69524f5bada8796d44a..ec0bd7e7c56b46720afd2e759cec7a65957d6acd 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 ddae76cb8b7400d56fc5335138b917dedad2f431..8355dffc1a47dda9290a6cd57bbede64890d3454 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 3e0f370a6ebe906278d980ecfb0e3b075381a305..ac7a409d82e0b0698f1af913b4c1f2f41b9114d6 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 95c16e923136a2f984547fc453a2a03515de71e0..a829087041dcce3d9b120dc6bf85eda45eb56426 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 8cae0d38380bd850efc454dd13d4dc04b470a2df..eb829fb97321b974951aa0802661050f3af59c54 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 363577077cc0a6a22ad577dfa8c0eb891597c160..4b7ea990f2f5fd0b3d09acc14952e98770509fd7 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 2418b13f781ee907e7e9f87d616669bf8ecb3f6b..4d77b7fd460fe3295a72d5384c9a1eca2894269e 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 5a2deaa365bbab9cd1bf7796f6a550f7e837ea3f..8006f46e71ba3c90d4f5626d765045750cfe13bf 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 04b38548557a4c5810e13e25a9df12d219022de5..a492aff70e93e2a0a27e3c3576c8344562194c58 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 7a4cb476135799607048a343b5f222cf82b4c773..e5f204a99c853a46364fb7cd37ffb9abd43c5d7f 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