Fields Summary |
---|
private final String | TAG |
private ModelChangeCallback | modelChangeCallback |
private android.bordeaux.services.FeatureAssembly | mFeatureAssembly |
public static final String | SET_FEATURE |
public static final String | SET_PAIRED_FEATURES |
public static final String | FEATURE_SEPARATOR |
public static final String | USE_HISTORY |
public static final String | PREVIOUS_SAMPLE |
private boolean | mUseHistory |
private long | mHistorySpan |
private String | mPrevSample |
private long | mPrevSampleTime |
private static final String[] | APP_BLACKLIST |
private android.bordeaux.learning.HistogramPredictor | mPredictor |
Methods Summary |
---|
public android.os.IBinder | getBinder()
return this;
|
public byte[] | getModel()
return mPredictor.getModel();
|
private java.util.Map | getSampleFeatures()
Map<String, String> sampleFeatures = mFeatureAssembly.getFeatureMap();
long currTime = System.currentTimeMillis();
if (mUseHistory && mPrevSample != null &&
((currTime - mPrevSampleTime) < mHistorySpan)) {
sampleFeatures.put(PREVIOUS_SAMPLE, mPrevSample);
}
return sampleFeatures;
|
public java.util.List | getTopCandidates(int topK)return probabilty of an exmple using the histogram
Map<String, String> features = getSampleFeatures();
List<Map.Entry<String, Double> > topApps = mPredictor.findTopClasses(features, topK);
int listSize = topApps.size();
ArrayList<StringFloat> result = new ArrayList<StringFloat>(listSize);
for (int i = 0; i < listSize; ++i) {
Map.Entry<String, Double> entry = topApps.get(i);
result.add(new StringFloat(entry.getKey(), entry.getValue().floatValue()));
}
return result;
|
public void | pushNewSample(java.lang.String sampleName)Input is a sampleName e.g.action name. This input is then augmented with requested build-in
features such as time and location to create sampleFeatures. The sampleFeatures is then
pushed to the histogram
Map<String, String> sampleFeatures = getSampleFeatures();
Log.i(TAG, "pushNewSample " + sampleName + ": " + sampleFeatures);
// TODO: move to the end of the function?
mPrevSample = sampleName;
mPrevSampleTime = System.currentTimeMillis();
mPredictor.addSample(sampleName, sampleFeatures);
if (modelChangeCallback != null) {
modelChangeCallback.modelChanged(this);
}
|
public void | resetPredictor()Reset the Predictor
mPredictor.resetPredictor();
if (modelChangeCallback != null) {
modelChangeCallback.modelChanged(this);
}
|
public boolean | setModel(byte[] modelData)
return mPredictor.setModel(modelData);
|
public void | setModelChangeCallback(ModelChangeCallback callback)
modelChangeCallback = callback;
|
public boolean | setPredictorParameter(java.lang.String key, java.lang.String value)Set parameters for 1) using History in probability estimations e.g. consider the last event
and 2) featureAssembly e.g. time and location.
Log.i(TAG, "setParameter : " + key + ", " + value);
boolean result = true;
if (key.equals(SET_FEATURE)) {
result = mFeatureAssembly.registerFeature(value);
if (!result) {
Log.e(TAG,"Setting on feauture: " + value + " which is not available");
}
} else if (key.equals(SET_PAIRED_FEATURES)) {
String[] features = value.split(FEATURE_SEPARATOR);
result = mFeatureAssembly.registerFeaturePair(features);
if (!result) {
Log.e(TAG,"Setting feauture pair: " + value + " is not valid");
}
} else if (key.equals(USE_HISTORY)) {
mUseHistory = true;
mHistorySpan = Long.valueOf(value);
} else {
Log.e(TAG,"Setting parameter " + key + " with " + value + " is not valid");
}
return result;
|