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

Corrected an early fusion issue due tothe dictionnary usage in monoview classifiers

parent e78c4e02
Branches
Tags
No related merge requests found
Showing
with 24 additions and 17 deletions
......@@ -35,8 +35,8 @@ def paramsToSet(nIter, randomState):
"""Used for weighted linear early fusion to generate random search sets"""
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.randint(1, 15),
DecisionTreeClassifier()])
paramsSet.append({"n_estimators": randomState.randint(1, 15),
"base_estimator": DecisionTreeClassifier()})
return paramsSet
......
......@@ -29,8 +29,9 @@ def fit(DATASET, CLASS_LABELS, randomState, NB_CORES=1, **kwargs):
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.randint(1, 300), randomState.choice(["gini", "entropy"]),
randomState.choice(["best", "random"])])
paramsSet.append({"max_depth": randomState.randint(1, 300),
"criterion": randomState.choice(["gini", "entropy"]),
"splitter": randomState.choice(["best", "random"])})
return paramsSet
......
......@@ -29,8 +29,10 @@ def fit(DATASET, CLASS_LABELS, randomState, NB_CORES=1, **kwargs):
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.randint(1, 20), randomState.choice(["uniform", "distance"]),
randomState.choice(["auto", "ball_tree", "kd_tree", "brute"]), randomState.choice([1, 2])])
paramsSet.append({"n_neighbors": randomState.randint(1, 20),
"weights": randomState.choice(["uniform", "distance"]),
"algorithm": randomState.choice(["auto", "ball_tree", "kd_tree", "brute"]),
"p": randomState.choice([1, 2])})
return paramsSet
......
......@@ -30,8 +30,9 @@ def fit(DATASET, CLASS_LABELS, randomState, NB_CORES=1, **kwargs):
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.randint(1, 300), randomState.randint(1, 300),
randomState.choice(["gini", "entropy"])])
paramsSet.append({"n_estimators": randomState.randint(1, 300),
"max_depth": randomState.randint(1, 300),
"criterion": randomState.choice(["gini", "entropy"])})
return paramsSet
......
......@@ -63,7 +63,9 @@ def fit(DATASET, CLASS_LABELS, randomState, NB_CORES=1, **kwargs):
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.choice(["conjunction", "disjunction"]), randomState.randint(1, 15), randomState.random_sample()])
paramsSet.append({"model_type": randomState.choice(["conjunction", "disjunction"]),
"max_rules": randomState.randint(1, 15),
"p": randomState.random_sample()})
return paramsSet
......
......@@ -28,8 +28,9 @@ def fit(DATASET, CLASS_LABELS, randomState, NB_CORES=1, **kwargs):
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.choice(['log', 'modified_huber']),
randomState.choice(["l1", "l2", "elasticnet"]), randomState.random_sample()])
paramsSet.append({"loss": randomState.choice(['log', 'modified_huber']),
"penalty": randomState.choice(["l1", "l2", "elasticnet"]),
"alpha": randomState.random_sample()})
return paramsSet
......
......@@ -26,7 +26,7 @@ def fit(DATASET, CLASS_LABELS, randomState, NB_CORES=1, **kwargs):
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.randint(1, 10000), ])
paramsSet.append({"C": randomState.randint(1, 10000), })
return paramsSet
......
......@@ -26,7 +26,7 @@ def fit(DATASET, CLASS_LABELS, randomState, NB_CORES=1, **kwargs):
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.randint(1, 10000), randomState.randint(1, 30)])
paramsSet.append({"C": randomState.randint(1, 10000), "degree": randomState.randint(1, 30)})
return paramsSet
......
......@@ -26,7 +26,7 @@ def fit(DATASET, CLASS_LABELS, randomState, NB_CORES=1, **kwargs):
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append([randomState.randint(1, 10000), ])
paramsSet.append({"C": randomState.randint(1, 10000), })
return paramsSet
......
......@@ -87,7 +87,7 @@ class WeightedLinear(EarlyFusionClassifier):
def setParams(self, paramsSet):
self.weights = paramsSet[0]
self.monoviewClassifiersConfig = dict((str(index), param) for index, param in enumerate(paramsSet[1]))
self.monoviewClassifiersConfig = paramsSet[1]
def predict_hdf5(self, DATASET, usedIndices=None, viewsIndices=None):
if type(viewsIndices) == type(None):
......
......@@ -54,11 +54,11 @@ def intersect(allClassifersNames, directory, viewsIndices, resultsMonoview, clas
if resultMonoview[1][0] in classifiersNames[resultMonoview[0]]:
classifierIndex = classifiersNames.index(resultMonoview[1][0])
wrongSets[resultMonoview[0]][classifierIndex] = np.where(
trainLabels + resultMonoview[1][3][classificationIndices[0]] == 1)
trainLabels + resultMonoview[1][3][classificationIndices[0]] == 1)[0]
else:
classifiersNames[resultMonoview[0]].append(resultMonoview[1][0])
wrongSets[resultMonoview[0]].append(
np.where(trainLabels + resultMonoview[1][3][classificationIndices[0]] == 1))
np.where(trainLabels + resultMonoview[1][3][classificationIndices[0]] == 1)[0])
combinations = itertools.combinations_with_replacement(range(len(classifiersNames[0])), nbViews)
bestLen = length
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment