Package classifier

Class GroupMeans

java.lang.Object
classifier.GroupMeans
All Implemented Interfaces:
Serializable, Cloneable

public class GroupMeans extends Object implements Serializable, Cloneable
Many classification functions need the mean values of each parameter from a group of training data.

This class provides a set of functions which will get the means by group, and also return larger matrixes of the mean values repeated by a grouping index or repeated for a single group which can be used in classifier training and classifier application

Author:
Doug Gillespie
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    GroupMeans(Jama.Matrix data, int[] group)
    Constructor works out the number of unique groups in group and then constructs a smaller matrix of means of each parameter by group.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    static int
    getGroupIndex(int[] uniqueGroups, int iD)
    Gets the index of a group id (these will often be the same !)
    static int[]
    getGroupIndex(int[] uniqueGroups, int[] iD)
    Gets the index of a group id (these will often be the same !)
    Jama.Matrix
     
    Jama.Matrix
    getGroupMeans(int[] groups)
    Create a matrix of means, repeated multiple times (e.g.
    Jama.Matrix
    getGroupMeans(int group, int n)
    Create a matrix of means for a single group.
    int[]
     
    int
     
    int[]
    Get list of unique groups in the data
    static int[]
    unique(int[] groups)
    Get a unique list of items in the training group

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GroupMeans

      public GroupMeans(Jama.Matrix data, int[] group)
      Constructor works out the number of unique groups in group and then constructs a smaller matrix of means of each parameter by group.
      Parameters:
      data - matrix of training data
      group - group indexes
  • Method Details

    • getGroupMeans

      public Jama.Matrix getGroupMeans()
      Returns:
      matrix of means by training group
    • getUniqueGroups

      public int[] getUniqueGroups()
      Get list of unique groups in the data
      Returns:
      list of unique groups in the data
    • getGroupSize

      public int[] getGroupSize()
      Returns:
      the number of entries in each group.
    • getNumGroups

      public int getNumGroups()
      Returns:
      The number of unique groups in the data
    • getGroupMeans

      public Jama.Matrix getGroupMeans(int[] groups)
      Create a matrix of means, repeated multiple times (e.g. so it can be subtracted off a set of training data).
      Parameters:
      groups - grouping to apply. Must contain only the same entries as in the group parameter passed to the constructor.
      Returns:
      matrix of grouped means.
    • getGroupMeans

      public Jama.Matrix getGroupMeans(int group, int n)
      Create a matrix of means for a single group.
      Parameters:
      group - index of group
      n - number of rows of data to create
      Returns:
      matrix with n identical rows of group
    • getGroupIndex

      public static int getGroupIndex(int[] uniqueGroups, int iD)
      Gets the index of a group id (these will often be the same !)
      Parameters:
      uniqueGroups - list of unique groups (sorted)
      iD - group ID to find
      Returns:
      index in group list.
    • getGroupIndex

      public static int[] getGroupIndex(int[] uniqueGroups, int[] iD)
      Gets the index of a group id (these will often be the same !)
      Parameters:
      uniqueGroups - sorted list of unique groups
      iD - list of group id's to find indexes of
      Returns:
      list of indexes.
    • unique

      public static int[] unique(int[] groups)
      Get a unique list of items in the training group

      e.g. if group was {1, 9, 3, 1, 4, 9, 4} then the return value would be {1, 3, 4, 9}

      Parameters:
      groups - group data which will contain many instances of few different values.
      Returns:
      a shorter array of unique values sorted by size.
    • clone

      public GroupMeans clone()