org.encog.neural.data.sql
Class SQLNeuralDataSet

java.lang.Object
  extended by org.encog.neural.data.sql.SQLNeuralDataSet
All Implemented Interfaces:
Iterable<NeuralDataPair>, EngineDataSet, NeuralDataSet

public class SQLNeuralDataSet
extends Object
implements NeuralDataSet

A dataset based on a SQL query. This is not a memory based dataset, so it can handle very large datasets without a memory issue. This class makes use of JDBC to query the database. If you are running into "out of memory" issues with this class try setting a lower "fetch size". This can be done with: sqlDataSet.getStatement().setFetchSize(1000);


Nested Class Summary
 class SQLNeuralDataSet.SQLNeuralIterator
          Iterator used to iterate over SQL results.
 
Field Summary
static String ADD_NOT_SUPPORTED
          Error message: adds are not supported.
static String REMOVE_NOT_SUPPORTED
          Error message: removes are not supported.
 
Constructor Summary
SQLNeuralDataSet(Connection connection, String sql, int inputSize, int idealSize)
          Create a SQLNeuralDataSet based on the specified connection.
SQLNeuralDataSet(String sql, int inputSize, int idealSize, String driver, String url, String uid, String pwd)
          Construct a SQL dataset.
 
Method Summary
 void add(NeuralData data1)
          Adds are not supported.
 void add(NeuralData inputData, NeuralData idealData)
          Adds are not supported.
 void add(NeuralDataPair inputData)
          Adds are not supported.
 void close()
          Close the SQL connection.
 Connection getConnection()
           
 int getIdealSize()
           
 int getInputSize()
           
 PreparedStatement getStatement()
           
 boolean isCloseConnection()
           
 boolean isSupervised()
           
 Iterator<NeuralDataPair> iterator()
          Get an iterator for this collection.
 void setCloseConnection(boolean closeConnection)
          Allows you to determine if the connection should be closed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADD_NOT_SUPPORTED

public static final String ADD_NOT_SUPPORTED
Error message: adds are not supported.

See Also:
Constant Field Values

REMOVE_NOT_SUPPORTED

public static final String REMOVE_NOT_SUPPORTED
Error message: removes are not supported.

See Also:
Constant Field Values
Constructor Detail

SQLNeuralDataSet

public SQLNeuralDataSet(Connection connection,
                        String sql,
                        int inputSize,
                        int idealSize)
Create a SQLNeuralDataSet based on the specified connection. This connection WILL NOT be closed when the close method is called.

Parameters:
connection - The connection to use.
sql - The SQL command to execute.
inputSize - The size of the input data.
idealSize - The size of the ideal data.

SQLNeuralDataSet

public SQLNeuralDataSet(String sql,
                        int inputSize,
                        int idealSize,
                        String driver,
                        String url,
                        String uid,
                        String pwd)
Construct a SQL dataset. A connection will be opened, this connection will be closed when the close method is called.

Parameters:
sql - The SQL command to execute.
inputSize - The size of the input data.
idealSize - The size of the ideal data.
driver - The driver to use.
url - The database connection URL.
uid - The database user id.
pwd - The database password.
Method Detail

add

public void add(NeuralData data1)
Adds are not supported.

Specified by:
add in interface NeuralDataSet
Parameters:
data1 - Not used.

add

public void add(NeuralData inputData,
                NeuralData idealData)
Adds are not supported.

Specified by:
add in interface NeuralDataSet
Parameters:
inputData - Not used.
idealData - Not used.

add

public void add(NeuralDataPair inputData)
Adds are not supported.

Specified by:
add in interface NeuralDataSet
Parameters:
inputData - Not used.

close

public void close()
Close the SQL connection.

Specified by:
close in interface NeuralDataSet

getConnection

public Connection getConnection()
Returns:
The JDBC connection being used.

getIdealSize

public int getIdealSize()
Specified by:
getIdealSize in interface EngineDataSet
Specified by:
getIdealSize in interface NeuralDataSet
Returns:
The size of the ideal data.

getInputSize

public int getInputSize()
Specified by:
getInputSize in interface EngineDataSet
Specified by:
getInputSize in interface NeuralDataSet
Returns:
The size of the input data.

getStatement

public PreparedStatement getStatement()
Returns:
The JDBC PreparedStatement being used.

isCloseConnection

public boolean isCloseConnection()
Returns:
True if the connection should be closed when the close method is called.

iterator

public Iterator<NeuralDataPair> iterator()
Get an iterator for this collection.

Specified by:
iterator in interface Iterable<NeuralDataPair>
Returns:
An iterator for use with this collection.

setCloseConnection

public void setCloseConnection(boolean closeConnection)
Allows you to determine if the connection should be closed. See the two constructors for how this is set by default. You can override this default behavior using this method.

Parameters:
closeConnection - True if the connection should be closed.

isSupervised

public boolean isSupervised()
Specified by:
isSupervised in interface EngineDataSet
Specified by:
isSupervised in interface NeuralDataSet
Returns:
True if this training data is supervised.


Copyright © 2011. All Rights Reserved.