From 816db251b04872afd313d55aca692a649075d2fc Mon Sep 17 00:00:00 2001 From: jodz4k Date: Tue, 23 Apr 2024 16:59:21 +0200 Subject: [PATCH] Fixed: #3 Copied method from DataFrame --- .../DataFrame.extension.st | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/AI-DataPreProcessing-Encoders/DataFrame.extension.st diff --git a/src/AI-DataPreProcessing-Encoders/DataFrame.extension.st b/src/AI-DataPreProcessing-Encoders/DataFrame.extension.st new file mode 100644 index 0000000..20c1e55 --- /dev/null +++ b/src/AI-DataPreProcessing-Encoders/DataFrame.extension.st @@ -0,0 +1,17 @@ +Extension { #name : #DataFrame } + +{ #category : #'*AI-DataPreProcessing-Encoders' } +DataFrame >> dataPreProcessingEncodeWith: anEncoder [ + "This method is here to speed up pharo-ai/data-preprocessing algos without coupling both projects." + + | copy cache | + copy := self copy. + cache := IdentityDictionary new. + self columns doWithIndex: [ :dataSerie :columnIndex | + | category | + category := cache at: columnIndex ifAbsentPut: [ ((anEncoder categories at: columnIndex) collectWithIndex: [ :elem :index | elem -> index ]) asDictionary ]. + dataSerie doWithIndex: [ :element :rowIndex | + copy at: rowIndex at: columnIndex put: (category at: element ifAbsent: [ AIMissingCategory signalFor: element ]) ] ]. + + ^ copy +]