Created
March 14, 2021 07:43
-
-
Save shubham0204/45ff7ae1a6e66d9eae8bf9d01aca8cf5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return samples ( in form of DataFrame object ) given their indices. | |
fun getEntries( indices : IntArray ) : DataFrame { | |
val dataFrame = DataFrame() | |
data.map { column -> | |
// `column` represent a Map -> ( String , ArrayList<String> ) | |
// column.key -> Name of the column as in the training datasets. | |
// column.value -> ArrayList<String> containing the column's data. | |
val columnData = ArrayList<String>() | |
val values = column.value | |
// Add the feature values corresponding to each index in `indices`. | |
for ( index in indices ) { | |
columnData.add( values[ index ] ) | |
} | |
println( "column data ${columnData.toTypedArray().contentToString()} , ${indices.size}") | |
// Append the column to the data frame. | |
dataFrame.addColumn( columnData , column.key ) | |
} | |
return dataFrame | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment