Splitting data to training and test sets in Ruby

I’m trying to implement a few simple machine learning techniques to a Ruby on Rails project. Before I get started, I need to have the tools in place to extract relevant data from the application, then splitting the data to a training and a test set. The code below is my first crack at a method for splitting the data as inspired by SciKit Learn’s train_test_split.

For now, this works for my purposes but I recognize that it might not be the optimal solution. How could I improve my code?

Leave a Reply

Your email address will not be published. Required fields are marked *