Libraries.Compute.Statistics.Transforms.SplitRowsTransform Documentation
The SplitRowsTransform class takes a data frame and transforms it into two DataFrames with copies of all of the data inside them. Specifically, you can set a percentage of the total data, like 0.8 for 80%, which then instructs the transform to select 80% of the rows, randomly, and place it into one DataFrame copy, with the remainder going in the other. This operation is synchronized across all columns so that it is the same split everywhere.
Example Code
DataFrame frame
frame:LoadFromCommaSeparatedValue(
"Hello, Hi
0, 17
1, 19
2, 21
3, 23
4, 25
5, 27
6, 29
7, 31
8, 33
9, 35
10, 35"
)
frame:AddSelectedColumn(0)
frame:AddSelectedColumn(1)
SplitRowsTransform transform
DataFrame in = transform:Transform(frame)
DataFrame out = transform:GetRemainderFrame()
output in:ToText()
output out:ToText()
Inherits from: Libraries.Language.Object, Libraries.Compute.Statistics.DataFrameTransform
Actions Documentation
Compare(Libraries.Language.Object object)
This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Example
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
CreatesCopy()
This action tells us whether or not this transform makes a copy of the data or modifies it in place. Transforms that do not make a copy should override this action.
Return
boolean: True if this transform makes a copy.
Example
use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Transforms.ReverseTransform
use Libraries.System.File
//Load a comma separated file
DataFrame frame
frame:Load("Data.csv")
//reverse the data frame
ReverseTransform reverse
output reverse:CreatesCopy() // by default, this transform returns true.
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
Example
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
GetHasRandomSeed()
Determines whether or not this class takes a seed for the random number generator into account.
Return
boolean:
GetHashCode()
This action gets the hash code for an object.
Return
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetPercent()
Gets the total percentage of the DataFrame to randomly select.
Return
number:
GetRemainderFrame()
This action provides the DataFrame for the remainder of the data set.
Return
GetResultFrames()
This action returns the resulting operations two frames. The first index of the array is the frame with the percentage indicated in the system. The second index of the array is the remainder frame. This action should only be called after Transform is called, otherwise it will return an empty array.
Return
GetSeed()
Returns the seed for the random number generator. This seed is only used if GetHasRandomSeed() = true.
Return
number:
GetSelectedFrame()
This action provides the DataFrame for the content selected.
Return
SetHasRandomSeed(boolean hasRandomSeed)
Sets whether or not this class takes a seed for the random number generator into account. If true, then it does.
Parameters
- boolean hasRandomSeed
SetPercent(number percent)
Sets the total percentage of the DataFrame to randomly select.
Parameters
- number percent
SetSeed(number seed)
Sets the random seed for the random number generator. As a convenience, this action also tells the class to use the random number generator seed. If this is not the desired behavior, call SetHasRandomSeed(false) on the transform. Calling this action is not necessary if no seed is desired.
Parameters
- number seed
Transform(Libraries.Compute.Statistics.DataFrame frame)
On this page
Variables TableAction Documentation- Compare(Libraries.Language.Object object)
- CreatesCopy()
- Equals(Libraries.Language.Object object)
- GetHasRandomSeed()
- GetHashCode()
- GetPercent()
- GetRemainderFrame()
- GetResultFrames()
- GetSeed()
- GetSelectedFrame()
- SetHasRandomSeed(boolean hasRandomSeed)
- SetPercent(number percent)
- SetSeed(number seed)
- Transform(Libraries.Compute.Statistics.DataFrame frame)