FileDocCategorySizeDatePackage
Learning_StochasticLinearRanker.javaAPI DocAndroid 5.1 API5841Thu Mar 12 22:22:48 GMT 2015android.bordeaux.services

Learning_StochasticLinearRanker

public class Learning_StochasticLinearRanker extends ILearning_StochasticLinearRanker.Stub implements IBordeauxLearner

Fields Summary
private final String
TAG
private StochasticLinearRankerWithPrior
mLearningSlRanker
private android.bordeaux.services.IBordeauxLearner.ModelChangeCallback
modelChangeCallback
Constructors Summary
public Learning_StochasticLinearRanker()


     
    
Methods Summary
public voidResetRanker()

        if (mLearningSlRanker == null)
            mLearningSlRanker = new StochasticLinearRankerWithPrior();
        mLearningSlRanker.resetRanker();
    
public floatScoreSample(java.util.List sample)

        ArrayList<StringFloat> temp = (ArrayList<StringFloat>)sample;
        String[] keys = new String[temp.size()];
        float[] values = new float[temp.size()];
        for (int i = 0; i < temp.size(); i++){
            keys[i] = temp.get(i).key;
            values[i] = temp.get(i).value;
        }
        if (mLearningSlRanker == null)
            mLearningSlRanker = new StochasticLinearRankerWithPrior();
        return mLearningSlRanker.scoreSample(keys,values);
    
public booleanSetModelParameter(java.lang.String key, java.lang.String value)

        if (mLearningSlRanker == null)
            mLearningSlRanker = new StochasticLinearRankerWithPrior();
        return mLearningSlRanker.setModelParameter(key,value);
    
public booleanSetModelPriorWeight(java.util.List sample)

        ArrayList<StringFloat> temp = (ArrayList<StringFloat>)sample;
        HashMap<String, Float> weights = new HashMap<String, Float>();
        for (int i = 0; i < temp.size(); i++)
            weights.put(temp.get(i).key, temp.get(i).value);
        if (mLearningSlRanker == null)
            mLearningSlRanker = new StochasticLinearRankerWithPrior();
        return mLearningSlRanker.setModelPriorWeights(weights);
    
public booleanUpdateClassifier(java.util.List sample_1, java.util.List sample_2)

        ArrayList<StringFloat> temp_1 = (ArrayList<StringFloat>)sample_1;
        String[] keys_1 = new String[temp_1.size()];
        float[] values_1 = new float[temp_1.size()];
        for (int i = 0; i < temp_1.size(); i++){
            keys_1[i] = temp_1.get(i).key;
            values_1[i] = temp_1.get(i).value;
        }
        ArrayList<StringFloat> temp_2 = (ArrayList<StringFloat>)sample_2;
        String[] keys_2 = new String[temp_2.size()];
        float[] values_2 = new float[temp_2.size()];
        for (int i = 0; i < temp_2.size(); i++){
            keys_2[i] = temp_2.get(i).key;
            values_2[i] = temp_2.get(i).value;
        }
        if (mLearningSlRanker == null)
            mLearningSlRanker = new StochasticLinearRankerWithPrior();
        boolean res = mLearningSlRanker.updateClassifier(keys_1,values_1,keys_2,values_2);
        if (res && modelChangeCallback != null) {
            modelChangeCallback.modelChanged(this);
        }
        return res;
    
public android.os.IBindergetBinder()

        return this;
    
public byte[]getModel()

        if (mLearningSlRanker == null)
            mLearningSlRanker = new StochasticLinearRankerWithPrior();
        StochasticLinearRankerWithPrior.Model model = mLearningSlRanker.getModel();
        try {
            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
            ObjectOutputStream objStream = new ObjectOutputStream(byteStream);
            objStream.writeObject(model);
            //return byteStream.toByteArray();
            byte[] bytes = byteStream.toByteArray();
            return bytes;
        } catch (IOException e) {
            throw new RuntimeException("Can't get model");
        }
    
public booleansetModel(byte[] modelData)

        try {
            ByteArrayInputStream input = new ByteArrayInputStream(modelData);
            ObjectInputStream objStream = new ObjectInputStream(input);
            StochasticLinearRankerWithPrior.Model model =
                    (StochasticLinearRankerWithPrior.Model) objStream.readObject();
            if (mLearningSlRanker == null)
                mLearningSlRanker = new StochasticLinearRankerWithPrior();
            boolean res = mLearningSlRanker.loadModel(model);
            return res;
        } catch (IOException e) {
            throw new RuntimeException("Can't load model");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException("Learning class not found");
        }
    
public voidsetModelChangeCallback(android.bordeaux.services.IBordeauxLearner.ModelChangeCallback callback)

        modelChangeCallback = callback;