Skip to content

Commit

Permalink
Fixed: pharo-ai#3 Copied method from DataFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
jodz4k committed Apr 23, 2024
1 parent 162743f commit 816db25
Showing 1 changed file with 17 additions and 0 deletions.
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
]

0 comments on commit 816db25

Please sign in to comment.