Skip to content

Commit

Permalink
Add encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
mirand863 committed Apr 23, 2024
1 parent 6f37990 commit 097a58e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions hiclass/LocalClassifierPerLevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"""

import hashlib
import numpy as np
import pickle
from copy import deepcopy
from os.path import exists

import numpy as np
from joblib import Parallel, delayed
from os.path import exists
from sklearn.base import BaseEstimator
from sklearn.preprocessing import LabelEncoder
from sklearn.utils.validation import check_array, check_is_fitted

from hiclass.ConstantClassifier import ConstantClassifier
Expand Down Expand Up @@ -273,6 +273,9 @@ def _fit_classifier(self, level, separator):
classifier = ConstantClassifier()
if not self.bert:
try:
label_encoder = LabelEncoder()
label_encoder.fit(y)
y = label_encoder.transform(y)
classifier.fit(X, y, sample_weight)
except TypeError:
classifier.fit(X, y)
Expand Down
9 changes: 6 additions & 3 deletions hiclass/LocalClassifierPerParentNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"""

import hashlib
import networkx as nx
import numpy as np
import pickle
from copy import deepcopy
from os.path import exists

import networkx as nx
import numpy as np
from sklearn.base import BaseEstimator
from sklearn.preprocessing import LabelEncoder
from sklearn.utils.validation import check_array, check_is_fitted

from hiclass.ConstantClassifier import ConstantClassifier
Expand Down Expand Up @@ -231,6 +231,9 @@ def _fit_classifier(self, node):
classifier = ConstantClassifier()
if not self.bert:
try:
label_encoder = LabelEncoder()
label_encoder.fit(y)
y = label_encoder.transform(y)
classifier.fit(X, y, sample_weight)
except TypeError:
classifier.fit(X, y)
Expand Down

0 comments on commit 097a58e

Please sign in to comment.