Machine Learning - Diagnostic - Discriminant Functions extension

From Q
Jump to: navigation, search

Produces a table of coefficients of linear discriminant functions for each class of a Linear Discriminant Analysislinear discriminant analysis. The class of a new data point can be predicted by computing the functions for all classes and choosing the class with the highest function output.



includeWeb("QScript R Output Functions");

var is_displayr = (!!Q.isOnTheWeb && Q.isOnTheWeb());
if (!is_displayr)
    if (Q.fileFormatVersion() >= 17.13)
        alert("Please update Q to use this feature from the extension button, or run it from the menu via Automate > Browse Online Library > Machine Learning > Diagnostic > Discriminant Functions.");

function main() {

    // The following 2 variables contain information specific to this diagnostic.
    var required_class = "LDA";
    var output_name_suffix = "discriminant.functions";
    var item = checkSelectedItemClass(required_class);
    if (item == null)
        return false;
    var r_name = stringToRName(item.referenceName);

    // The following lines contain the R code to run
    var expression = r_name + "$original$discriminant.functions";

    return createROutput(item, expression, output_name_suffix);