Java Reference
In-Depth Information
this capability and some tools may require algorithm-specific data
preparation.
In the modeling phase, we first build, and then test the model.
To be able to test, we need a test dataset, that is, one taken from the
original data and used to determine how well the model performs
on data it has not seen before. Since our data is randomly ordered,
we will take the first 70 percent of records for the build dataset,
called CUSTOMER_BUILD, and the remaining 30 percent for the
test dataset, called CUSTOMER_TEST.
6.4.1
Build
For model building, there are a couple of JDM artifacts to be aware
of. First, JDM requires a connection to the DME to perform mining.
This is illustrated in the following code. JDM requires the instantia-
tion of a factory object to create a connection. Factory objects also
play a major role in working with JDM overall. See Chapter 8 for a
discussion of JDM factories.
import javax.datamining.resource.ConnectionFactory;
import javax.datamining.resource.Connection;
import javax.datamining.resource.ConnectionSpec;
Hashtable env new Hashtable();
env.put( Context.INITIAL_CONTEXT_FACTORY,
”com.myCompany.javax.datamining.resource.initialContextFactoryImpl” );
env.put( Context.PROVIDER_URL, ”http://myHost:myPort/myService” );
env.put( Context.SECURITY_PRINCIPAL, ”user” );
env.put( Context.SECURITY_CREDENTIALS, ”password” );
InitialContext jndiContext new javax.naming.InitialContext( env );
// Perform JNDI lookup to obtain the connection factory
ConnectionFactory jdmCFactory (ConnectionFactory)
jndiContext.lookup(”java:comp/env/jdm/MyServer”);
// Create a data mining server connection
ConnectionSpec svrConnSpec (ConnectionSpec) jdmCFactory.getConnectionSpec();
svrConnSpec.setName( ”jdm_user” );
svrConnSpec.setPassword( ”jdm_password” );
svrConnSpec.setURI( ”serverURI” );
Connection dmeConn
(Connection) jdmCFactory.getConnection( svrConnSpec );
Now that we have a connection, dmeConn , we can proceed to set
up the model building task. The task requires defining the data
using a PhysicalDataSet object. This object is saved to the DME for
 
Search WWH ::




Custom Search