Database Reference
In-Depth Information
* @param maxNumberOfRecommendations the number of recom-
mendations, -1 if all
* @return the recommendation indexes
* @throws MiningException
*/
private
int[]
recos(State
state,
int
maxNumberOfRecommendations)
throws MiningException {
// Create policy:
Policy policy ¼ new EpsilonGreedyPolicy( 0.5 );
ActionSet actionSet ¼ recoEnv.getActionSet(state);
policy.setActionSet(actionSet);
policy.setActionValueFunction( agent.getQfunction() );
policy.setDifferentActions(true);
// Call policy:
Vector < Integer > recItems ¼ new Vector < Integer > ();
int nact ¼ (int) actionSet.getActionsNumber();
for (int i ¼ 0; i < nact; i++) {
if (recItems.size() ¼¼ maxNumberOfRecommendations)
break;
Action action ¼ policy.nextAction();
recItems.addElement((int)action.getIndex());
}
int[] recs ¼ new int[ recItems.size() ];
for (int i ¼ 0; i < recItems.size(); i++)
recs[i] ¼ recItems.elementAt(i);
return recs;
}
The method showRecs displays the current recommendations. Finally, the learn
method takes the current state and recommendations and calls the learnApply
method of the agent for the previous step.
// Private session data:
private State state ¼ null;
private int[] recs ¼ null;
private int selRec ¼ -1;
private State nextState ¼ null;
private int[] nextRecs ¼ null;
private int nextSelRec ¼ -1;
/**
* Learns from previous step.
*
* @param cstate the current state
Search WWH ::




Custom Search