Skip to content

Instantly share code, notes, and snippets.

@a-agmon
Created February 26, 2023 12:28
Show Gist options
  • Save a-agmon/8bd32a296ba7b2b5adb12051d9f375d0 to your computer and use it in GitHub Desktop.
Save a-agmon/8bd32a296ba7b2b5adb12051d9f375d0 to your computer and use it in GitHub Desktop.
implicit class DMatrixConverter(seq: Seq[FeaturesRecord]) {
def toDMatrix: DMatrix = {
val labeledPoints = seq.map { case FeaturesRecord(_, _, features, label) =>
LabeledPoint(label, features.size, null, features.toArray)
}
new DMatrix(labeledPoints.iterator)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment