-
Notifications
You must be signed in to change notification settings - Fork 159
Parameters
David Ray edited this page Jun 6, 2015
·
10 revisions
This page contains an in-depth discussion of Parameters.
Parameters p = Parameters.getAllDefaultParameters();
// Set a few of your desired parameters...
p.setParameterByKey(KEY.INPUT_DIMENSIONS, new int[] { 128, 128 });
p.setParameterByKey(KEY.COLUMN_DIMENSIONS, new int[] { 200 });
p.setParameterByKey(KEY.POTENTIAL_RADIUS, 3);
p.setParameterByKey(KEY.POTENTIAL_PCT, 0.5);
// To clear a parameter
p.clearParameter(KEY.POTENTIAL_PCT);
// To get an empty Parameters object
Parameters newCopy = Parameters.empty();
// To get a copy
Parameters copy = p.copy();
// To retrieve algorithm only parameters
Parameters spatial = Parameters.getSpatialDefaultParameters();
Parameters temporal = Parameters.getTemporalDefaultParameters();
Parameters encoder = Parameters.getEncoderDefaultParameters();
// To merge (union) one Parameters object into another
Parameters spatial = Parameters.getSpatialDefaultParameters();
Parameters temporal = Parameters.getTemporalDefaultParameters();
spatial.union(temporal); // Now contains only those params specific to the SP and TM
Let's use the HotGym fields, "consumption" and "timestamp" as an example:
// This map contains keys which are field names or column names from csv files.
Map<String, Map<String, Object>> fieldEncodings = new HashMap<>();
Map<String, Object> inner = new HashMap<>();
// consumption
inner.put("n", 500);
inner.put("w", 21);
inner.put("minVal", 0.0); // Only needed for ScalarEncoder - otherwise can be left empty
inner.put("maxVal", 0.0); // S.A.A for ScalarEncoder
inner.put("radius", 0.0);
inner.put("resolution", 0.0);
inner.put("periodic", false);
inner.put("clipInput", false);
inner.put("forced", false); // Used to force a non-standard ratio of "n" and "w" values.
inner.put("fieldName", "consumption"); // We'll use "consumption" here
inner.put("fieldType", "float"); // others are "string","datetime","int","float","bool","list"
inner.put("encoderType", "RandomDistributedScalarEncoder"); // Use the class name of the encoder.
fieldEncodings.put("consumption", inner);
// Timestamp
inner = new HashMap<>();
inner.put("n", 0);
inner.put("w", 0);
inner.put("minVal", 0.0);
inner.put("maxVal", 0.0);
inner.put("radius", 0.0);
inner.put("resolution", 0.0);
inner.put("periodic", false);
inner.put("clipInput", false);
inner.put("forced", false);
inner.put("fieldName", "timestamp");
inner.put("fieldType", "datetime");
inner.put("encoderType", "DateEncoder");
inner.put(KEY.DATEFIELD_TOFD.getFieldName(), new Tuple(21,9.5)); // Time of day
inner.put(KEY.DATEFIELD_PATTERN.getFieldName(), "MM/dd/YY HH:mm"); // Date Pattern to be expected
fieldEncodings.put("timestamp", inner);
// Finally add the encoding map to the Parameters
p.setParameterByKey(KEY.FIELD_ENCODING_MAP, fieldEncodings);
If you should need to customize an Anomaly computer's settings, it can be done like this:
Map<String, Object> params = new HashMap<>();
params.put(KEY_MODE, Mode.PURE);
params.put(KEY_WINDOW_SIZE, 3);
params.put(KEY_USE_MOVING_AVG, true);
Anomaly customAnomaly = Anomaly.create(params);
// Then insert into network:
Network.create("Network API Demo", p)
.add(Network.createRegion("Region 1")
.add(Network.createLayer("Layer 2/3", p)
.add(customAnomaly)));
- Introduction (Home)
- History & News Archives...
- Usability
- Architecture
- NAPI Quick Start Guide
- NAPI In Depth
- Saving Your Network: PersistenceAPI Serialization
- Roadmap
- Browse Java Docs
- Build Instructions
- Eclipse (Dev Setup)
- Anomaly Prediction
- Test Coverage Reports
- [Cortical.io Demos] (https://github.com/numenta/htm.java-examples/tree/master/src/main/java/org/numenta/nupic/examples/cortical_io)
- Hot Gym Demo
- Performance Benchmarks with jmh - blog
- BLOG: Join the "cogmission"