Class Classes
Methods for operating with categorical data.
Inheritance
Namespace: ISynergy.Framework.Mathematics.Statistics
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public static class Classes : object
Methods
View SourceDecide(Double)
Hyperplane decision function. Return true if distance is higher than zero, and false otherwise.
Declaration
public static bool Decide(double distance)
Parameters
Type | Name | Description |
---|---|---|
System.Double | distance |
Returns
Type | Description |
---|---|
System.Boolean |
Decide(Double[])
Hyperplane decision function. Return true if distance is higher than zero, and false otherwise.
Declaration
public static bool[] Decide(double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values |
Returns
Type | Description |
---|---|
System.Boolean[] |
Decide(Double[][])
Hyperplane decision function. Return true if distance is higher than zero, and false otherwise.
Declaration
public static bool[][] Decide(double[][] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | values |
Returns
Type | Description |
---|---|
System.Boolean[][] |
Decide(Int32)
Hyperplane decision function. Return true if distance is higher than zero, and false otherwise.
Declaration
public static bool Decide(int label)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | label |
Returns
Type | Description |
---|---|
System.Boolean |
Decide(Int32[])
Hyperplane decision function. Return true if distance is higher than zero, and false otherwise.
Declaration
public static bool[] Decide(int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values |
Returns
Type | Description |
---|---|
System.Boolean[] |
Decide(Int32[][])
Hyperplane decision function. Return true if distance is higher than zero, and false otherwise.
Declaration
public static bool[][] Decide(int[][] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[][] | values |
Returns
Type | Description |
---|---|
System.Boolean[][] |
Expand(Int32[], Int32[], Int32[])
Extends a grouped data into a full observation matrix.
Declaration
public static int[][] Expand(this int[] data, int[] positives, int[] negatives)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | data | The group labels. |
System.Int32[] | positives | An array containing he occurrence of the positive class for each of the groups. |
System.Int32[] | negatives | An array containing he occurrence of the negative class for each of the groups. |
Returns
Type | Description |
---|---|
System.Int32[][] | A full sized observation matrix. |
Expand(Int32[][], Int32, Int32, Int32)
Expands a grouped data into a full observation matrix.
Declaration
public static int[][] Expand(this int[][] data, int labelColumn, int positiveColumn, int negativeColumn)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[][] | data | The grouped data matrix. |
System.Int32 | labelColumn | Index of the column which contains the labels in the grouped data matrix. |
System.Int32 | positiveColumn | Index of the column which contains the occurrences for the first class. |
System.Int32 | negativeColumn | Index of the column which contains the occurrences for the second class. |
Returns
Type | Description |
---|---|
System.Int32[][] | A full sized observation matrix. |
GetRatio(Boolean[], out Int32, out Int32)
Gets the percentage of positive samples in a set of class labels.
Declaration
public static double GetRatio(this bool[] y, out int positives, out int negatives)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean[] | y | The class labels. |
System.Int32 | positives | The number of positive samples in |
System.Int32 | negatives | The number of negatives samples in |
Returns
Type | Description |
---|---|
System.Double | The percentage of positive samples in |
GetRatio(Int32[], out Int32, out Int32)
Gets the percentage of positive samples in a set of class labels.
Declaration
public static double GetRatio(int[] y, out int positives, out int negatives)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | y | The class labels. |
System.Int32 | positives | The number of positive samples in |
System.Int32 | negatives | The number of negatives samples in |
Returns
Type | Description |
---|---|
System.Double | The percentage of positive samples in |
GetRatio(Int32[], Int32[])
Calculates the prevalence of a class for each variable.
Declaration
public static double[] GetRatio(int[] positives, int[] negatives)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | positives | An array of counts detailing the occurrence of the first class. |
System.Int32[] | negatives | An array of counts detailing the occurrence of the second class. |
Returns
Type | Description |
---|---|
System.Double[] | An array containing the proportion of the first class over the total of occurrences. |
GetRatio(Int32[][], Int32, Int32)
Calculates the prevalence of a class.
Declaration
public static double[] GetRatio(this int[][] data, int positiveColumn, int negativeColumn)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[][] | data | A matrix containing counted, grouped data. |
System.Int32 | positiveColumn | The index for the column which contains counts for occurrence of the first class. |
System.Int32 | negativeColumn | The index for the column which contains counts for occurrence of the second class. |
Returns
Type | Description |
---|---|
System.Double[] | An array containing the proportion of the first class over the total of occurrences. |
IsBinary(Int32[])
Determines whether the class labels contains only (-1 and +1) or (0 and +1).
Declaration
public static bool IsBinary(this int[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | p |
Returns
Type | Description |
---|---|
System.Boolean |
IsMinusOnePlusOne(Int32[])
Determines whether the class labels contains only -1 and +1.
Declaration
public static bool IsMinusOnePlusOne(this int[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | p |
Returns
Type | Description |
---|---|
System.Boolean |
IsMulticlass(Boolean[][])
Determines whether the class labels contains one true value per sample.
Declaration
public static bool IsMulticlass(this bool[][] y)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean[][] | y |
Returns
Type | Description |
---|---|
System.Boolean |
IsMultilabel(Boolean[][])
Determines whether the class labels contains one true value per sample.
Declaration
public static bool IsMultilabel(this bool[][] y)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean[][] | y |
Returns
Type | Description |
---|---|
System.Boolean |
IsZeroOne(Int32[])
Determines whether the class labels contains only zero and ones.
Declaration
public static bool IsZeroOne(this int[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | p |
Returns
Type | Description |
---|---|
System.Boolean |
Random(Int32, Double)
Returns a random group assignment for a sample into two mutually exclusive groups.
Declaration
public static int[] Random(int samples, double proportion)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | samples | The sample size. |
System.Double | proportion | The proportion of samples between the groups. |
Returns
Type | Description |
---|---|
System.Int32[] |
Random(Int32, Double[])
Returns a random group assignment for a sample.
Declaration
public static int[] Random(int samples, double[] proportion)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | samples | The sample size. |
System.Double[] | proportion | The desired proportion for each class. |
Returns
Type | Description |
---|---|
System.Int32[] |
Random(Int32, Int32)
Returns a random group assignment for a sample.
Declaration
public static int[] Random(int samples, int classes)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | samples | The sample size. |
System.Int32 | classes | The number of groups. |
Returns
Type | Description |
---|---|
System.Int32[] |
Random(Int32[], Double)
Returns a random group assignment for a sample, making sure different class labels are distributed evenly among the groups.
Declaration
public static int[] Random(int[] labels, double proportion)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | labels | A vector containing class labels. |
System.Double | proportion | The proportion of positive and negative samples. |
Returns
Type | Description |
---|---|
System.Int32[] |
Random(Int32[], Int32)
Returns a random group assignment for a sample, making sure different class labels are distributed evenly among the groups.
Declaration
public static int[] Random(int[] labels, int categories)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | labels | A vector containing class labels. |
System.Int32 | categories | The number of groups. |
Returns
Type | Description |
---|---|
System.Int32[] |
Random(Int32[], Int32, Int32)
Returns a random group assignment for a sample, making sure different class labels are distributed evenly among the groups.
Declaration
public static int[] Random(int[] labels, int classes, int categories)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | labels | A vector containing class labels. |
System.Int32 | classes | The number of different classes in |
System.Int32 | categories | The number of groups. |
Returns
Type | Description |
---|---|
System.Int32[] |
Separate<T>(T[], Int32[])
Divides values into groups given a vector containing the group labels for every value.
Declaration
public static T[][] Separate<T>(this T[] values, int[] labels)
Parameters
Type | Name | Description |
---|---|---|
T[] | values | The values to be separated into groups. |
System.Int32[] | labels | A vector containing the class label associated with each of the values. The labels must begin on 0 and its maximum value should be the number of groups - 1. |
Returns
Type | Description |
---|---|
T[][] | The original values divided into groups. |
Type Parameters
Name | Description |
---|---|
T | The type of the values. |
Separate<T>(T[], Int32[], Int32)
Divides values into groups given a vector containing the group labels for every value.
Declaration
public static T[][] Separate<T>(this T[] values, int[] labels, int groups)
Parameters
Type | Name | Description |
---|---|---|
T[] | values | The values to be separated into groups. |
System.Int32[] | labels | A vector containing the class label associated with each of the values. The labels must begin on 0 and its maximum value should be the number of groups - 1. |
System.Int32 | groups | The number of groups. |
Returns
Type | Description |
---|---|
T[][] | The original values divided into groups. |
Type Parameters
Name | Description |
---|---|
T | The type of the values. |
Summarize(Int32[][], Int32, Int32)
Groups the occurrences contained in data matrix of binary (dichotomous) data. This operation can be reversed using the Expand(Int32[][], Int32, Int32, Int32) method.
Declaration
public static int[][] Summarize(this int[][] data, int groupIndex, int yesNoIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[][] | data | A data matrix containing at least a column of binary data. |
System.Int32 | groupIndex | Index of the column which contains the group label name. |
System.Int32 | yesNoIndex | Index of the column which contains the binary [0,1] data. |
Returns
Type | Description |
---|---|
System.Int32[][] | A matrix containing the group label in the first column, the number of occurrences of the first class in the second column and the number of occurrences of the second class in the third column. |
ToMinusOnePlusOne(Boolean)
Converts a boolean variable into a -1 or +1 representation (-1 is false, +1 is true).
Declaration
public static int ToMinusOnePlusOne(this bool p)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | p |
Returns
Type | Description |
---|---|
System.Int32 |
ToMinusOnePlusOne(Boolean[])
Converts boolean variables into a -1 or +1 representation (-1 is false, +1 is true).
Declaration
public static int[] ToMinusOnePlusOne(this bool[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean[] | p |
Returns
Type | Description |
---|---|
System.Int32[] |
ToMinusOnePlusOne(Boolean[][])
Converts boolean variables into a -1 or +1 representation (-1 is false, +1 is true).
Declaration
public static double[][] ToMinusOnePlusOne(this bool[][] p)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean[][] | p |
Returns
Type | Description |
---|---|
System.Double[][] |
ToMinusOnePlusOne(Double)
Converts a boolean variable into a -1 or +1 representation (-1 is false, +1 is true).
Declaration
public static int ToMinusOnePlusOne(this double p)
Parameters
Type | Name | Description |
---|---|---|
System.Double | p |
Returns
Type | Description |
---|---|
System.Int32 |
ToMinusOnePlusOne(Double[])
Converts boolean variables into a -1 or +1 representation (-1 is false, +1 is true).
Declaration
public static int[] ToMinusOnePlusOne(this double[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | p |
Returns
Type | Description |
---|---|
System.Int32[] |
ToMinusOnePlusOne(Int32)
Converts a boolean variable into a -1 or +1 representation (-1 is false, +1 is true).
Declaration
public static int ToMinusOnePlusOne(this int p)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | p |
Returns
Type | Description |
---|---|
System.Int32 |
ToMinusOnePlusOne(Int32[])
Converts boolean variables into a -1 or +1 representation (-1 is false, +1 is true).
Declaration
public static int[] ToMinusOnePlusOne(this int[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | p |
Returns
Type | Description |
---|---|
System.Int32[] |
ToMinusOnePlusOne<T>(Boolean[][])
Converts boolean variables into a -1 or +1 representation (-1 is false, +1 is true).
Declaration
public static T[][] ToMinusOnePlusOne<T>(this bool[][] p)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean[][] | p |
Returns
Type | Description |
---|---|
T[][] |
Type Parameters
Name | Description |
---|---|
T |
ToMulticlass(Double[])
Converts double variables into class labels, starting at zero.
Declaration
public static int[] ToMulticlass(this double[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | p |
Returns
Type | Description |
---|---|
System.Int32[] |
ToMulticlass(Double[], Int32)
Converts double variables into class labels, starting at zero.
Declaration
public static int[] ToMulticlass(this double[] p, int min)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | p | |
System.Int32 | min |
Returns
Type | Description |
---|---|
System.Int32[] |
ToMulticlass(Int32[])
Converts double variables into class labels, starting at zero.
Declaration
public static int[] ToMulticlass(this int[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | p |
Returns
Type | Description |
---|---|
System.Int32[] |
ToMulticlass(Int32[], Int32)
Converts double variables into class labels, starting at zero.
Declaration
public static int[] ToMulticlass(this int[] p, int min)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | p | |
System.Int32 | min |
Returns
Type | Description |
---|---|
System.Int32[] |
ToZeroOne(Boolean)
Converts a boolean variable into a 0-or-1 representation (0 is false, 1 is true).
Declaration
public static int ToZeroOne(this bool p)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | p |
Returns
Type | Description |
---|---|
System.Int32 |
ToZeroOne(Boolean[])
Converts boolean variables into a 0-or-1 representation (0 is false, 1 is true).
Declaration
public static int[] ToZeroOne(this bool[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean[] | p |
Returns
Type | Description |
---|---|
System.Int32[] |
ToZeroOne(Double)
Converts a boolean variable into a 0-or-1 representation (0 is false, 1 is true).
Declaration
public static int ToZeroOne(this double p)
Parameters
Type | Name | Description |
---|---|---|
System.Double | p |
Returns
Type | Description |
---|---|
System.Int32 |
ToZeroOne(Double[])
Converts boolean variables into a 0-or-1 representation (0 is false, 1 is true).
Declaration
public static int[] ToZeroOne(this double[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | p |
Returns
Type | Description |
---|---|
System.Int32[] |
ToZeroOne(Int32)
Converts a boolean variable into a 0-or-1 representation (0 is false, 1 is true).
Declaration
public static int ToZeroOne(this int p)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | p |
Returns
Type | Description |
---|---|
System.Int32 |
ToZeroOne(Int32[])
Converts boolean variables into a 0-or-1 representation (0 is false, 1 is true).
Declaration
public static int[] ToZeroOne(this int[] p)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | p |
Returns
Type | Description |
---|---|
System.Int32[] |