Model Exporter Interpreter: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
No edit summary
imported>Jeremy
Line 61: Line 61:
|}
|}


_
<!--  -->


==Workspace Class==
==Workspace Class==

Revision as of 13:26, 26 March 2011

The Model_Exporter Interpreter implements several classes which can be used in Microsoft .NET environments to apply Model_Exporter models to new data. The following describes the classes implemented and their use. The classes include the ModelInterpreter, Workspace, and Matrix classes. The source code for these classes is supplied and can be used, compiled, and redistributed without restriction. Note that such redistribution permission does not permit the user to redistribute the Model_Exporter product itself - only the interpreter.

ModelInterpreter Class

The primary class in the Model_Exporter C# Interpreter is a ModelInterpreter object. The object's interface implements the ability to assign input data, specify a model to interpret and apply, and retrieve results from the application. Input data and results are all stored using the Matrix class described below.

Constructors

ModelInterpreter(String filename)

This form of the constructor method allows passing a filename of a Model_Exporter XML file which should be read and parsed for application.

ModelInterpreter(XmlDocument xdoc)

This form of the constructor method allows passing a XmlDocument object which contains the contents of a Model_Exporter XML file. This method may be preferred when the content of an exported model has been previously read and stored in another location like a database. In such cases, the alternative ways to create XmlDocuments (see the XmlDocument documentation) which can be used to pass the parsed XML contents directly to the ModelInterpreter class.

Methods

apply()

Applies the model to the inputdata and stores results in the results property. This method has no return value itself. An error is thrown if inputdata has not already been assigned.


Properties

Read-Only Properties

inputDataSize

(Int32) The number of columns expected for the inputdata matrix.

modeltype

(String) The model type of the model. One of the supported model types such as: "PCA" "PLS" "PCR" "CLS" or "PLSDA" (or other supported model types) This often helps identify what variables are of interest in the results workspace after application of the model.

information

(XmlDocument) The raw, unparsed XML contained in the information section of the model. This may be of interest to help identify where the model came from, what the model is predicting, how many outputs to expect, etc. See the exported model's <information> tag for details included.

results

(Workspace) The workspace object that contains all the results after applying the model. This contains all the variables (see Workspace class below) that were used during model application as well as the variables which hold the results of interest such as yhat, T2, or Q.

Read/Write Properties

inputdata

(Matrix) Specifies the data to which the model should be applied. Type is Matrix as defined using the Matrix class described below. This field is not modified by applying the model. Assigning a new value this field erases the results from a previous model application.


Workspace Class

Constructors

       Workspace()

Methods

       void setVar(String name, Matrix value)
       void setVar(Workspace toadd)
       Matrix getVar(String name)
       Boolean isSet(String name)
       void clearAll()

Properties

       List<String> varList


Matrix Class

The Matrix class is defined through a public-domain class implemented in the cMatrixLib. This class allows storing and retrieval of data in a simple two-dimensional matrix as well as performing various matrix calculations on that data. For the purposes of the Model_Exporter Interpreter, the main use is to provide a convenient method to exchange data between the client and the interpreter. Thus, the details of the class are not given here, but only the main creation and access information. This class is used for the inputdata property and the variables stored in the results Workspace of the ModelInterpreter.

Constructors

Constructor for a new Matrix object is by either specifying the size (in rows and columns) for the new Matrix, or by passing an array of Double to the constructor:

 Matrix mymatrix = new Matrix(int rows, int columns)
 Matrix mymatrix = new Matrix(Double[,] data)

Changing and Accessing Values

Once created, the contents of the matrix can be modified or retrieved using standard (zero-based) indexing:

 mymatrix[0,0] = value;   //replace element 0,0 with specified Double "value"
 value = mymatrix[0,0];   //retrieve value at element 0,0

Determining Size

To determine the size of a given matrix, use the NoRows and NoCols properties:

 int rows = mymatrix.NoRows;
 int columns = mymatrix.NoCols;