Skip to content

Commit

Permalink
will fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jdey4 committed Sep 10, 2020
1 parent 0dc3501 commit 883f509
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions proglearn/deciders.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ def fit(
transformer_id_to_voters,
classes=None,
):
if self.classes == None and len(y) == 0:
raise ValueError("Classification Decider classes undefined with no class labels fed to fit")
try:
self.classes = list(self.classes)
except TypeError:
if len(y) == 0:
raise ValueError("Classification Decider classes undefined with no class labels fed to fit")
else:
self.classes = np.unique(y)
self.classes = self.classes if self.classes != None else np.unique(y)
self.transformer_id_to_transformers = transformer_id_to_transformers
self.transformer_id_to_voters = transformer_id_to_voters

return self

def predict_proba(self, X, transformer_ids=None):
Expand Down
5 changes: 3 additions & 2 deletions proglearn/forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .transformers import TreeClassificationTransformer
from .voters import TreeClassificationVoter
from .deciders import SimpleAverage
import numpy as np

class LifelongClassificationForest:
def __init__(self, n_estimators=100, tree_construction_proportion=0.67, finite_sample_correction=False):
Expand All @@ -26,7 +27,7 @@ def add_task(
X,
y,
task_id=task_id,
transformer_voter_decider_split=[self.tree_construction_proportion, 1-tree_construction_proportion, 0],
transformer_voter_decider_split=[self.tree_construction_proportion, 1-self.tree_construction_proportion, 0],
num_transformers=self.n_estimators,
decider_kwargs = {"classes" : np.unique(y)}
)
Expand Down Expand Up @@ -60,7 +61,7 @@ def fit(self, X, y):
n_estimators=self.n_estimators,
finite_sample_correction=self.finite_sample_correction,
)
self.lf.add_task(X, y, task_id=0, decider_kwargs = {"classes" : np.unique(y)})
self.lf.add_task(X, y, task_id=0)
return self

def predict(self, X):
Expand Down

0 comments on commit 883f509

Please sign in to comment.