Java Code Examples for org.numenta.nupic.Parameters#getEncoderDefaultParameters()

The following examples show how to use org.numenta.nupic.Parameters#getEncoderDefaultParameters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests that a meaningful exception is thrown when no geo encoder configuration was provided
 */
@Test(expected = IllegalArgumentException.class)
public void testGeoEncoderNotInitialized() {
    Publisher manual = Publisher.builder()
        .addHeader("foo")
        .addHeader("geo")
        .addHeader("")
        .build();
    Sensor<File> sensor = Sensor.create(ObservableSensor::create, SensorParams.create(
        Keys::obs, "", manual));
    Map<String, Map<String, Object>> fieldEncodings = setupMap( null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    Parameters params = Parameters.getEncoderDefaultParameters();
    params.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    HTMSensor<File> htmSensor = (HTMSensor<File>) sensor;
    htmSensor.initEncoder(params);
}
 
Example 2
Source File: PersistenceAPITest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
private Parameters getTestEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = setupMap(
        null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");

    fieldEncodings = setupMap(
        fieldEncodings, 
        25, 
        3, 
        0, 0, 0, 0.1, null, null, null, 
        "consumption", "float", "RandomDistributedScalarEncoder");

    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_DOFW.getFieldName(), new Tuple(1, 1.0)); // Day of week
    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_TOFD.getFieldName(), new Tuple(5, 4.0)); // Time of day
    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_PATTERN.getFieldName(), "MM/dd/YY HH:mm");

    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}
 
Example 3
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests that a meaningful exception is thrown when no boolean encoder configuration was provided
 */
@Test(expected = IllegalArgumentException.class)
public void testBoolEncoderNotInitialized() {
    Publisher manual = Publisher.builder()
        .addHeader("foo")
        .addHeader("bool")
        .addHeader("")
        .build();
    Sensor<File> sensor = Sensor.create(ObservableSensor::create, SensorParams.create(
        Keys::obs, "", manual));
    Map<String, Map<String, Object>> fieldEncodings = setupMap( null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    Parameters params = Parameters.getEncoderDefaultParameters();
    params.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    HTMSensor<File> htmSensor = (HTMSensor<File>) sensor;
    htmSensor.initEncoder(params);
}
 
Example 4
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests that a meaningful exception is thrown when no float number encoder configuration was provided
 */
@Test(expected = IllegalArgumentException.class)
public void testFloatNumberEncoderNotInitialized() {
    Publisher manual = Publisher.builder()
        .addHeader("foo")
        .addHeader("float")
        .addHeader("")
        .build();
    Sensor<File> sensor = Sensor.create(ObservableSensor::create, SensorParams.create(
        Keys::obs, "", manual));
    Map<String, Map<String, Object>> fieldEncodings = setupMap( null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    Parameters params = Parameters.getEncoderDefaultParameters();
    params.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    HTMSensor<File> htmSensor = (HTMSensor<File>) sensor;
    htmSensor.initEncoder(params);
}
 
Example 5
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests that a meaningful exception is thrown when no int number encoder configuration was provided
 */
@Test(expected = IllegalArgumentException.class)
public void testIntNumberEncoderNotInitialized() {
    Publisher manual = Publisher.builder()
        .addHeader("foo")
        .addHeader("int")
        .addHeader("")
        .build();
    Sensor<File> sensor = Sensor.create(ObservableSensor::create, SensorParams.create(
        Keys::obs, "", manual));
    Map<String, Map<String, Object>> fieldEncodings = setupMap( null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    Parameters params = Parameters.getEncoderDefaultParameters();
    params.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    HTMSensor<File> htmSensor = (HTMSensor<File>) sensor;
    htmSensor.initEncoder(params);
}
 
Example 6
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests that a meaningful exception is thrown when no coordinate encoder configuration was provided
 */
@Test(expected = IllegalArgumentException.class)
public void testCoordinateEncoderNotInitialized() {
    Publisher manual = Publisher.builder()
        .addHeader("foo")
        .addHeader("coord")
        .addHeader("")
        .build();
    Sensor<File> sensor = Sensor.create(ObservableSensor::create, SensorParams.create(
        Keys::obs, "", manual));
    Map<String, Map<String, Object>> fieldEncodings = setupMap( null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    Parameters params = Parameters.getEncoderDefaultParameters();
    params.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    HTMSensor<File> htmSensor = (HTMSensor<File>) sensor;
    htmSensor.initEncoder(params);
}
 
Example 7
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests that a meaningful exception is thrown when no date encoder configuration was provided
 */
@Test(expected = IllegalArgumentException.class)
public void testDateEncoderNotInitialized() {
    Publisher manual = Publisher.builder()
        .addHeader("foo")
        .addHeader("datetime")
        .addHeader("T")
        .build();
    Sensor<File> sensor = Sensor.create(ObservableSensor::create, SensorParams.create(
        Keys::obs, "", manual));
    Map<String, Map<String, Object>> fieldEncodings = setupMap( null, 
        25, 
        3, 
        0, 0, 0, 0.1, null, null, null, 
        "consumption", "float", "RandomDistributedScalarEncoder");
    Parameters params = Parameters.getEncoderDefaultParameters();
    params.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    HTMSensor<File> htmSensor = (HTMSensor<File>) sensor;
    htmSensor.initEncoder(params);
}
 
Example 8
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests that a meaningful exception is thrown when no string category encoder configuration was provided
 */
@Test(expected = IllegalArgumentException.class)
public void testStringCategoryEncoderNotInitialized() {
    Publisher manual = Publisher.builder()
        .addHeader("foo")
        .addHeader("string")
        .addHeader("C")
        .build();
    Sensor<File> sensor = Sensor.create(ObservableSensor::create, SensorParams.create(
        Keys::obs, "", manual));
    Map<String, Map<String, Object>> fieldEncodings = setupMap( null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    Parameters params = Parameters.getEncoderDefaultParameters();
    params.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    HTMSensor<File> htmSensor = (HTMSensor<File>) sensor;
    htmSensor.initEncoder(params);
}
 
Example 9
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Tests that a meaningful exception is thrown when no list category encoder configuration was provided
 */
@Test(expected = IllegalArgumentException.class)
public void testListCategoryEncoderNotInitialized() {
    Publisher manual = Publisher.builder()
        .addHeader("foo")
        .addHeader("list")
        .addHeader("C")
        .build();
    Sensor<File> sensor = Sensor.create(ObservableSensor::create, SensorParams.create(
        Keys::obs, "", manual));
    Map<String, Map<String, Object>> fieldEncodings = setupMap( null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    Parameters params = Parameters.getEncoderDefaultParameters();
    params.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    HTMSensor<File> htmSensor = (HTMSensor<File>) sensor;
    htmSensor.initEncoder(params);
}
 
Example 10
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
private Parameters getTestEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = setupMap(
        null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    fieldEncodings = setupMap(
        fieldEncodings, 
        25, 
        3, 
        0, 0, 0, 0.1, null, null, null, 
        "consumption", "float", "RandomDistributedScalarEncoder");
    
    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_DOFW.getFieldName(), new Tuple(1, 1.0)); // Day of week
    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_TOFD.getFieldName(), new Tuple(5, 4.0)); // Time of day
    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_PATTERN.getFieldName(), "MM/dd/YY HH:mm");
    
    // This will work also
    //fieldEncodings.get("timestamp").put(KEY.DATEFIELD_FORMATTER.getFieldName(), DateEncoder.FULL_DATE);
            
    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    
    return p;
}
 
Example 11
Source File: TestHarness.java    From flink-htm with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns Encoder parameters for the "dayOfWeek" test encoder.
 * @return
 */
public static Parameters getEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = getFieldEncodingMap();

    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(Parameters.KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}
 
Example 12
Source File: HTMSensorTest.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
private Parameters getCategoryEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = setupMap(
        null,
        0, // n
        0, // w
        0, 0, 0, 0, null, null, null,
        "timestamp", "datetime", "DateEncoder");
    fieldEncodings = setupMap(
        fieldEncodings, 
        25, 
        3, 
        0, 0, 0, 0.1, null, null, null, 
        "consumption", "float", "RandomDistributedScalarEncoder");
    fieldEncodings = setupMap(
        fieldEncodings, 
        25, 
        3, 
        0, 0, 0, 0.0, null, null, Boolean.TRUE, 
        "type", "list", "SDRCategoryEncoder");
    
    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_DOFW.getFieldName(), new Tuple(1, 1.0)); // Day of week
    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_TOFD.getFieldName(), new Tuple(5, 4.0)); // Time of day
    fieldEncodings.get("timestamp").put(KEY.DATEFIELD_PATTERN.getFieldName(), "MM/dd/YY HH:mm");
    
    String categories = "ES;S1;S2;S3;S4;S5;S6;S7;S8;S9;S10;S11;S12;S13;S14;S15;S16;S17;S18;S19;GB;US";
    fieldEncodings.get("type").put(KEY.CATEGORY_LIST.getFieldName(), categories);
    
    // This will work also
    //fieldEncodings.get("timestamp").put(KEY.DATEFIELD_FORMATTER.getFieldName(), DateEncoder.FULL_DATE);
            
    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);
    
    return p;
}
 
Example 13
Source File: NetworkDemoHarness.java    From htm.java-examples with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns Encoder parameters for the "dayOfWeek" test encoder.
 * @return
 */
public static Parameters getDayDemoTestEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = getDayDemoFieldEncodingMap();

    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}
 
Example 14
Source File: NetworkDemoHarness.java    From htm.java-examples with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns Encoder parameters and meta information for the "Hot Gym" encoder
 * @return
 */
public static Parameters getHotGymTestEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = getHotGymFieldEncodingMap();

    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}
 
Example 15
Source File: NetworkTestHarness.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns Encoder parameters and meta information for the "Hot Gym" encoder
 * @return
 */
public static Parameters getNetworkDemoTestEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = getNetworkDemoFieldEncodingMap();

    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.GLOBAL_INHIBITION, true);
    p.set(KEY.COLUMN_DIMENSIONS, new int[] { 2048 });
    p.set(KEY.CELLS_PER_COLUMN, 32);
    p.set(KEY.NUM_ACTIVE_COLUMNS_PER_INH_AREA, 40.0);
    p.set(KEY.POTENTIAL_PCT, 0.8);
    p.set(KEY.SYN_PERM_CONNECTED,0.1);
    p.set(KEY.SYN_PERM_ACTIVE_INC, 0.0001);
    p.set(KEY.SYN_PERM_INACTIVE_DEC, 0.0005);
    p.set(KEY.MAX_BOOST, 1.0);
    
    p.set(KEY.MAX_NEW_SYNAPSE_COUNT, 20);
    p.set(KEY.INITIAL_PERMANENCE, 0.21);
    p.set(KEY.PERMANENCE_INCREMENT, 0.1);
    p.set(KEY.PERMANENCE_DECREMENT, 0.1);
    p.set(KEY.MIN_THRESHOLD, 9);
    p.set(KEY.ACTIVATION_THRESHOLD, 12);
    
    p.set(KEY.CLIP_INPUT, true);
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}
 
Example 16
Source File: NetworkTestHarness.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns Encoder parameters and meta information for the "Hot Gym" encoder
 * @return
 */
public static Parameters getHotGymTestEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = getHotGymFieldEncodingMap();

    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}
 
Example 17
Source File: NetworkTestHarness.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns Encoder parameters for the "dayOfWeek" test encoder.
 * @return
 */
public static Parameters getDayDemoTestEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = getDayDemoFieldEncodingMap();

    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}
 
Example 18
Source File: NetworkTestHarness.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Parameters and meta information for the "Geospatial Test" encoder
 * @return
 */
public static Parameters getGeospatialTestEncoderParams() {
	Map<String, Map<String, Object>> fieldEncodings = getGeospatialFieldEncodingMap();
	
	Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}
 
Example 19
Source File: NetworkDemoHarness.java    From htm.java-examples with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns Encoder parameters and meta information for the "Hot Gym" encoder
 * @return
 */
public static Parameters getNetworkDemoTestEncoderParams() {
    Map<String, Map<String, Object>> fieldEncodings = getNetworkDemoFieldEncodingMap();

    Parameters p = Parameters.getEncoderDefaultParameters();
    p.set(KEY.GLOBAL_INHIBITION, true);
    p.set(KEY.COLUMN_DIMENSIONS, new int[] { 2048 });
    p.set(KEY.CELLS_PER_COLUMN, 32);
    p.set(KEY.NUM_ACTIVE_COLUMNS_PER_INH_AREA, 40.0);
    p.set(KEY.POTENTIAL_PCT, 0.8);
    p.set(KEY.SYN_PERM_CONNECTED,0.1);
    p.set(KEY.SYN_PERM_ACTIVE_INC, 0.0001);
    p.set(KEY.SYN_PERM_INACTIVE_DEC, 0.0005);
    p.set(KEY.MAX_BOOST, 1.0);
    p.set(KEY.INFERRED_FIELDS, getInferredFieldsMap("consumption", SDRClassifier.class));
    
    p.set(KEY.MAX_NEW_SYNAPSE_COUNT, 20);
    p.set(KEY.INITIAL_PERMANENCE, 0.21);
    p.set(KEY.PERMANENCE_INCREMENT, 0.1);
    p.set(KEY.PERMANENCE_DECREMENT, 0.1);
    p.set(KEY.MIN_THRESHOLD, 9);
    p.set(KEY.ACTIVATION_THRESHOLD, 12);
    
    p.set(KEY.CLIP_INPUT, true);
    p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings);

    return p;
}