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

Added distrib to utils

parent 38625746
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ import sys ...@@ -3,7 +3,7 @@ import sys
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from scipy.stats import randint from scipy.stats import randint, uniform
from sklearn.model_selection import RandomizedSearchCV from sklearn.model_selection import RandomizedSearchCV
...@@ -38,6 +38,23 @@ def grid_search(dataset, classifier_name, views_indices=None, k_folds=None, n_it ...@@ -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""" """Used to perfom gridsearch on the classifiers"""
pass 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: class CustomRandint:
"""Used as a distribution returning a integer between low and high-1. """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 It can be used with a multiplier agrument to be able to perform more complex generation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment