From 647f3189b58ae33a11c8f8974f49a41216ac1995 Mon Sep 17 00:00:00 2001
From: Baptiste Bauvin <baptiste.bauvin@lis-lab.fr>
Date: Thu, 24 Oct 2019 09:51:24 -0400
Subject: [PATCH] Added distrib to utils

---
 .../utils/hyper_parameter_search.py           | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/multiview_platform/mono_multi_view_classifiers/utils/hyper_parameter_search.py b/multiview_platform/mono_multi_view_classifiers/utils/hyper_parameter_search.py
index 8e3c1042..ad2282b2 100644
--- a/multiview_platform/mono_multi_view_classifiers/utils/hyper_parameter_search.py
+++ b/multiview_platform/mono_multi_view_classifiers/utils/hyper_parameter_search.py
@@ -3,7 +3,7 @@ import sys
 
 import matplotlib.pyplot as plt
 import numpy as np
-from scipy.stats import  randint
+from scipy.stats import randint, uniform
 from sklearn.model_selection import RandomizedSearchCV
 
 
@@ -38,6 +38,23 @@ def grid_search(dataset, classifier_name, views_indices=None, k_folds=None, n_it
     """Used to perfom gridsearch on the classifiers"""
     pass
 
+class CustomUniform:
+    """Used as a distribution returning a float between loc and loc + scale..
+        It can be used with a multiplier agrument to be able to perform more complex generation
+        for example 10 e -(float)"""
+
+    def __init__(self, loc=0, state=1, multiplier=""):
+        self.uniform = uniform(loc, state)
+        self.multiplier = multiplier
+
+    def rvs(self, random_state=None):
+        unif = self.uniform.rvs(random_state=random_state)
+        if self.multiplier == 'e-':
+            return 10 ** -unif
+        else:
+            return unif
+
+
 class CustomRandint:
     """Used as a distribution returning a integer between low and high-1.
     It can be used with a multiplier agrument to be able to perform more complex generation
-- 
GitLab