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

pre_cluster

parent 7b49f93f
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ from ... import Metrics ...@@ -14,7 +14,7 @@ from ... import Metrics
class ColumnGenerationClassifier(BaseEstimator, ClassifierMixin, BaseBoost): class ColumnGenerationClassifier(BaseEstimator, ClassifierMixin, BaseBoost):
def __init__(self, mu=0.01, epsilon=1e-06, n_max_iterations=100, estimators_generator=None, dual_constraint_rhs=0, save_iteration_as_hyperparameter_each=None, random_state=None): def __init__(self, mu=0.01, epsilon=1e-06, n_max_iterations=None, estimators_generator=None, dual_constraint_rhs=0, save_iteration_as_hyperparameter_each=None, random_state=None):
super(ColumnGenerationClassifier, self).__init__() super(ColumnGenerationClassifier, self).__init__()
self.epsilon = epsilon self.epsilon = epsilon
self.n_max_iterations = n_max_iterations self.n_max_iterations = n_max_iterations
......
...@@ -80,6 +80,7 @@ def ExecMonoview(directory, X, Y, name, labelsNames, classificationIndices, KFol ...@@ -80,6 +80,7 @@ def ExecMonoview(directory, X, Y, name, labelsNames, classificationIndices, KFol
logging.debug("Start:\t Predicting") logging.debug("Start:\t Predicting")
y_train_pred = classifier.predict(X_train) y_train_pred = classifier.predict(X_train)
y_test_pred = classifier.predict(X_test) y_test_pred = classifier.predict(X_test)
print(np.unique(y_test_pred))
full_labels_pred = np.zeros(Y.shape, dtype=int)-100 full_labels_pred = np.zeros(Y.shape, dtype=int)-100
for trainIndex, index in enumerate(classificationIndices[0]): for trainIndex, index in enumerate(classificationIndices[0]):
full_labels_pred[index] = y_train_pred[trainIndex] full_labels_pred[index] = y_train_pred[trainIndex]
......
from sklearn.linear_model import Lasso
import numpy as np
from ..Monoview.MonoviewUtils import CustomRandint, CustomUniform, BaseMonoviewClassifier
# Author-Info
__author__ = "Baptiste Bauvin"
__status__ = "Prototype" # Production, Development, Prototype
class Lasso(Lasso, BaseMonoviewClassifier):
def __init__(self, random_state=None, alpha=1.0,
max_iter=10, warm_start=False, **kwargs):
super(Lasso, self).__init__(
alpha=alpha,
max_iter=max_iter,
warm_start=warm_start,
random_state=random_state
)
self.param_names = ["max_iter", "alpha",]
self.classed_params = []
self.distribs = [CustomRandint(low=1, high=300),
CustomUniform(),]
self.weird_strings = {}
def fit(self, X, y, check_input=True):
neg_y = np.copy(y)
neg_y[np.where(neg_y==0)] = -1
super(Lasso, self).fit(X, neg_y)
return self
def predict(self, X):
prediction = super(Lasso, self).predict(X)
signed = np.sign(prediction)
signed[np.where(signed==-1)] = 0
return signed
def canProbas(self):
"""Used to know if the classifier can return label probabilities"""
return False
def getInterpret(self, directory, y_test):
interpretString = ""
return interpretString
def formatCmdArgs(args):
"""Used to format kwargs for the parsed args"""
kwargsDict = {"alpha": args.LA_alpha,
"max_iter": args.LA_n_iter}
return kwargsDict
def paramsToSet(nIter, randomState):
paramsSet = []
for _ in range(nIter):
paramsSet.append({"max_iter": randomState.randint(1, 300),
"alpha": randomState.uniform(0,1.0),})
return paramsSet
\ No newline at end of file
...@@ -200,6 +200,16 @@ def parseTheArgs(arguments): ...@@ -200,6 +200,16 @@ def parseTheArgs(arguments):
help='Set the n_max_iterations parameter for CGreed', help='Set the n_max_iterations parameter for CGreed',
default=100) default=100)
groupLasso = parser.add_argument_group('Lasso arguments')
groupLasso.add_argument('--LA_n_iter', metavar='INT', type=int,
action='store',
help='Set the max_iter parameter for Lasso',
default=1)
groupLasso.add_argument('--LA_alpha', metavar='FLOAT', type=float,
action='store',
help='Set the alpha parameter for Lasso',
default=1.0)
groupGradientBoosting = parser.add_argument_group('Gradient Boosting arguments') groupGradientBoosting = parser.add_argument_group('Gradient Boosting arguments')
groupGradientBoosting.add_argument('--GB_n_est', metavar='INT', type=int, groupGradientBoosting.add_argument('--GB_n_est', metavar='INT', type=int,
action='store', action='store',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment