From e9fd7770bd8fe1b7f7cb80d6a572539586ffc1a7 Mon Sep 17 00:00:00 2001 From: Richard Townsend Date: Sat, 26 Jul 2014 05:29:30 -0700 Subject: [PATCH] Updated Instances (markdown) --- Instances.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Instances.md b/Instances.md index 878497f..3d92bc3 100644 --- a/Instances.md +++ b/Instances.md @@ -1,5 +1,21 @@ Golearn's model for machine learning problems will be familiar if you've used SciPy, WEKA or R. Data is represented as a flat table, analogous to a spreadsheet, and used for training and prediction. The structure which implements this table is called `Instances`. +Sorting Instances +----------------- +`Sort` implements an in-place radix sort. It accepts a sort direction (Ascending or Descending) and a slice of integer Attribute positions. + +**Code excerpt: sorting instances** +````go +inst, _ := base.ParseCSVToInstances +attrs := make([]int, 4) +attrs[0] = 3 +attrs[1] = 2 +attrs[2] = 1 +attrs[3] = 0 +inst.Sort(Descending, attrs) +```` +Because radix sort isn't stable (maintaining the original order of sorted elements is not guaranteed), sort by all of the Attributes available to get a consistent result. + Sample application ------------------