Skip to content

Commit

Permalink
bugfix in preprocessing standardize
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMoreo committed Jul 10, 2024
1 parent 2034845 commit b4571d9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions quapy/data/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,17 @@ def standardize(dataset: Dataset, inplace=False):
:class:`quapy.data.base.Dataset` is to be returned
:return: an instance of :class:`quapy.data.base.Dataset`
"""
s = StandardScaler(copy=not inplace)
training = s.fit_transform(dataset.training.instances)
test = s.transform(dataset.test.instances)
s = StandardScaler()
train, test = dataset.train_test
std_train_X = s.fit_transform(train.X)
std_test_X = s.transform(test.X)
if inplace:
dataset.training.instances = std_train_X
dataset.test.instances = std_test_X
return dataset
else:
training = LabelledCollection(std_train_X, train.labels, classes=train.classes_)
test = LabelledCollection(std_test_X, test.labels, classes=test.classes_)
return Dataset(training, test, dataset.vocabulary, dataset.name)


Expand Down

0 comments on commit b4571d9

Please sign in to comment.