Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/AI-DataPreProcessing-Encoders/DataFrame.extension.st
Original file line number Diff line number Diff line change
@@ -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
]