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

Numpy is now monocore

parent 02c3748f
No related branches found
No related tags found
No related merge requests found
...@@ -444,6 +444,8 @@ def execClassif(arguments): ...@@ -444,6 +444,8 @@ def execClassif(arguments):
os.nice(args.nice) os.nice(args.nice)
nbCores = args.nbCores nbCores = args.nbCores
if nbCores == 1:
os.environ['OPENBLAS_NUM_THREADS'] = '1'
statsIter = args.CL_statsiter statsIter = args.CL_statsiter
hyperParamSearch = args.CL_HPS_type hyperParamSearch = args.CL_HPS_type
multiclassMethod = args.CL_multiclassMethod multiclassMethod = args.CL_multiclassMethod
......
...@@ -13,7 +13,6 @@ from .BoostUtils import StumpsClassifiersGenerator, sign, BaseBoost, \ ...@@ -13,7 +13,6 @@ from .BoostUtils import StumpsClassifiersGenerator, sign, BaseBoost, \
getInterpretBase, get_accuracy_graph getInterpretBase, get_accuracy_graph
from ... import Metrics from ... import Metrics
# Used for QarBoost and CGreed # Used for QarBoost and CGreed
class ColumnGenerationClassifierQar(BaseEstimator, ClassifierMixin, BaseBoost): class ColumnGenerationClassifierQar(BaseEstimator, ClassifierMixin, BaseBoost):
...@@ -155,8 +154,8 @@ class ColumnGenerationClassifierQar(BaseEstimator, ClassifierMixin, BaseBoost): ...@@ -155,8 +154,8 @@ class ColumnGenerationClassifierQar(BaseEstimator, ClassifierMixin, BaseBoost):
X = np.array(X.todense()) X = np.array(X.todense())
classification_matrix = self._binary_classification_matrix(X) classification_matrix = self._binary_classification_matrix(X)
self.step_predict(classification_matrix) self.step_predict(classification_matrix)
margins = np.squeeze( margins = np.sum(classification_matrix * self.weights_, axis=1)
np.asarray(np.matmul(classification_matrix, self.weights_))) # print(margins)
signs_array = np.array([int(x) for x in sign(margins)]) signs_array = np.array([int(x) for x in sign(margins)])
signs_array[signs_array == -1] = 0 signs_array[signs_array == -1] = 0
end = time.time() end = time.time()
...@@ -167,8 +166,8 @@ class ColumnGenerationClassifierQar(BaseEstimator, ClassifierMixin, BaseBoost): ...@@ -167,8 +166,8 @@ class ColumnGenerationClassifierQar(BaseEstimator, ClassifierMixin, BaseBoost):
if classification_matrix.shape != self.train_shape: if classification_matrix.shape != self.train_shape:
self.step_decisions = np.zeros(classification_matrix.shape) self.step_decisions = np.zeros(classification_matrix.shape)
for weight_index in range(self.weights_.shape[0]-1): for weight_index in range(self.weights_.shape[0]-1):
margins = np.squeeze( margins = np.sum(classification_matrix[:, :weight_index+1]* self.weights_[:weight_index+1], axis=1)
np.asarray(np.matmul(classification_matrix[:, :weight_index+1], self.weights_[:weight_index+1]))) # print(margins)
signs_array = np.array([int(x) for x in sign(margins)]) signs_array = np.array([int(x) for x in sign(margins)])
signs_array[signs_array == -1] = 0 signs_array[signs_array == -1] = 0
self.step_decisions[:, weight_index] = signs_array self.step_decisions[:, weight_index] = signs_array
...@@ -176,10 +175,8 @@ class ColumnGenerationClassifierQar(BaseEstimator, ClassifierMixin, BaseBoost): ...@@ -176,10 +175,8 @@ class ColumnGenerationClassifierQar(BaseEstimator, ClassifierMixin, BaseBoost):
def update_info_containers(self, y, voter_perf, k): def update_info_containers(self, y, voter_perf, k):
"""Is used at each iteration to compute and store all the needed quantities for later analysis""" """Is used at each iteration to compute and store all the needed quantities for later analysis"""
self.example_weights_.append(self.example_weights) self.example_weights_.append(self.example_weights)
self.previous_vote = np.matmul( self.previous_vote += self.q * self.new_voter
self.classification_matrix[:, self.chosen_columns_],
np.array(self.weights_).reshape((k + 2, 1))).reshape(
(self.n_total_examples, 1))
self.previous_votes.append(self.previous_vote) self.previous_votes.append(self.previous_vote)
self.previous_margins.append( self.previous_margins.append(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment