/*
* NCSA Data To Knowledge (D2K) Project
* Automated Learning Group
* National Center for Supercomputing Applications
* University of Illinois at Urbana-Champaign
* 605 E. Springfield, Champaign, IL 61820
*
* d2k@ncsa.uiuc.edu
*
* Copyright 2003, Board of Trustees of the University of Illinois,
* All Rights Reserved
*
* NCSA Data To Knowledge (D2K) software, source code, binary code, and Java-byte
* code including D2K modules and D2K itineraries (hereafter, Software) is
* copyrighted by the Board of Trustees of the University of Illinois (UI),
* and ownership remains with the UI.
*
* Prior to receiving this Software Source Code, You must have agreed to a
* non-exclusive, non-transferable, restricted License of Software with UI for
* limited Research Use and/or Internal Business Use. The terms of that License
* control the use of this Software Source Code. For the sake of convenience,
* certain provisions of that License are stated here. However, in the event
* of any real or perceived differences between the terms of the License and the
* statements made herein, the License controls.
*
* You may not distribute the Software including the Binary Code and this Source
* Code to third parties.
*
* You may make Derivative Works. You are encouraged to provide information to
* UI regarding Derivative Works and your experience with Software. However, if
* You make any Derivative Work based on or derived from the Software, then You
* will: (1) clearly notify users that such Derivative Work is a modified version
* and uses or is derived from the original NCSA Data To Knowledge (D2K)
* developed at UI, and include specific language in that notice as provided for
* in the License, and (2) acknowledge via citation and provide UI with a copy of
* any report or publication using the Software or Derivative Work.
*
* If You wish to make Commercial Use of the Software or Derivative Works, then
* You should contact the UI, c/o NCSA, to negotiate an appropriate license for
* such Commercial Use. Commercial Use includes sale, lease, license,
* distribution or otherwise making the Software or Derivative Works available to
* third parties, which includes, but is not limited to, integration of all or
* part of the Software or Derivative Work into a product for sale or license by
* or on behalf of You to third parties.
*
* UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY
* PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. THE UI
* SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE USERS OF THIS SOFTWARE.
*
* By using or copying this Software, You agree to abide by the copyright law
* and all other applicable laws of the U.S. including, but not limited to,
* export control laws, and the terms of the License. UI shall have the right
* to terminate its license with You immediately upon Your breach of, or
* non-compliance with, any of its terms. You may be held legally responsible
* for any copyright infringement that is caused or encouraged by Your failure
* to abide by the terms of the License.
*/
package ncsa.d2k.modules.core.prediction;
import ncsa.d2k.core.modules.ComputeModule;
import ncsa.d2k.modules.*;
import ncsa.d2k.modules.core.datatype.table.*;
/**
=======
ModelPredict
takes in a model and an example Table
and runs the model's predict function
on the input table
*/
public class ModelPredict extends ncsa.d2k.core.modules.ComputeModule
{
/**
This pair returns an array of strings that contains the data types for the inputs.
@return the data types of all inputs.
*/
public String[] getInputTypes() {
String[] types = {
"ncsa.d2k.modules.core.datatype.table.ExampleTable",
"ncsa.d2k.modules.PredictionModelModule"};
return types;
}
/**
* Return the human readable name of the indexed input.
* @param index the index of the input.
* @return the human readable name of the indexed input.
*/
public String getInputName(int index) {
switch(index) {
case 0:
return "Example Table";
case 1:
return "Prediction Model";
default:
return "No such input";
}
}
/**
This pair returns the description of the various inputs.
@return the description of the indexed input.
*/
public String getInputInfo(int index) {
switch (index) {
case 0:
return "The table containing the examples that the model will be applied to.";
case 1:
return "The prediction model to apply.";
default:
return "No such input";
}
}
/**
This pair returns an array of strings that contains the data types for the outputs.
@return the data types of all outputs.
*/
public String[] getOutputTypes() {
String[] types = {
"ncsa.d2k.modules.core.datatype.table.PredictionTable" };
return types;
}
/**
* Return the human readable name of the indexed output.
* @param index the index of the output.
* @return the human readable name of the indexed output.
*/
public String getOutputName(int index) {
switch(index) {
case 0:
return "Prediction Table";
default:
return "No such output";
}
}
/**
This pair returns the description of the outputs.
@return the description of the indexed output.
*/
public String getOutputInfo(int index) {
switch (index) {
case 0:
return "A table with the prediction columns filled in by the model.";
default:
return "No such output";
}
}
/**
* Return the human readable name of the module.
* @return the human readable name of the module.
*/
public String getModuleName() {
return "Model Predict";
}
/**
This pair returns the description of the module.
@return the description of the module.
*/
public String getModuleInfo() {
StringBuffer sb = new StringBuffer( "Overview: This module applies a prediction model to an table of examples and ");
sb.append("makes predictions for each output attribute based on the values of the input attributes. ");
sb.append("</p><p>Description: This module applies a previously built model to a new set of examples that have the ");
sb.append("same attributes as those used to train/build the model. The module creates a new table that contains ");
sb.append("columns for each of the values the model predicts, in addition to the columns found in the original table. ");
sb.append("The new columns are filled in with values predicted by the model based on the values of the input attributes. ");
return sb.toString();
}
/**
*/
public void doit() throws Exception {
ExampleTable tt= (ExampleTable)pullInput(0);
PredictionModelModule pmm=(PredictionModelModule)pullInput(1);
PredictionTable pt=pmm.predict(tt);
pushOutput(pt, 0);
}
}
// Start QA Comments
// 3/30/03 Ruth removed output port for model - no longer copy through
// Still needs comments about impact on input table and if possible better description.
//