use of org.iobserve.analysis.session.data.UserSession in project iobserve-analysis by research-iobserve.
the class TSessionOperationsFilter method execute.
@Override
protected void execute(final UserSession session) throws Exception {
final UserSession filteredUserSession = new UserSession(session.getHost(), session.getSessionId());
session.getEvents().stream().filter(this.filter::isAllowed).forEach(filteredUserSession::add);
this.outputPort.send(filteredUserSession);
}
use of org.iobserve.analysis.session.data.UserSession in project iobserve-analysis by research-iobserve.
the class ClusteringPrePostProcessing method getForEachUserGroupAnEntryCallSequenceModel.
/**
* It creates for each cluster(user group) its own entryCallSequenceModel. For that, each
* entryCallSequenceModel receives exclusively the user group's assigned user sessions obtained
* via the clustering. Additionally each entryCallSequenceModel receives the user group's
* occurrence likelihood within the considered user sessions.
*
* @param clusteringResults
* hold the assignments of the clustering and the number of clusters
* @param callSequenceModel
* is the input entryCallSequenceModel that holds all user sessions
* @return for each cluster one entryCallSequenceModel. Each contains exclusively the cluster's
* assigned user sessions
*/
public List<UserSessionCollectionModel> getForEachUserGroupAnEntryCallSequenceModel(final ClusteringResults clusteringResults, final UserSessionCollectionModel callSequenceModel) {
final int numberOfClusters = clusteringResults.getNumberOfClusters();
final int[] assignments = clusteringResults.getAssignments();
final List<UserSessionCollectionModel> entryCallSequenceModels = new ArrayList<>(numberOfClusters);
final double countOfAbsoluteUserSessions = callSequenceModel.getUserSessions().size();
for (int k = 0; k < numberOfClusters; k++) {
final List<UserSession> sessions = new ArrayList<>();
int instanceNumber = 0;
double countOfAssigendUserSessions = 0;
for (final int clusterNum : assignments) {
if (clusterNum == k) {
sessions.add(callSequenceModel.getUserSessions().get(instanceNumber));
countOfAssigendUserSessions++;
}
instanceNumber++;
}
if (sessions.isEmpty()) {
continue;
}
final double relativeFrequencyOfUserGroup = countOfAssigendUserSessions / countOfAbsoluteUserSessions;
entryCallSequenceModels.add(new UserSessionCollectionModel(sessions, relativeFrequencyOfUserGroup));
}
return entryCallSequenceModels;
}
use of org.iobserve.analysis.session.data.UserSession in project iobserve-analysis by research-iobserve.
the class ClusteringEvaluation method performClustering.
/**
* Executes the approach's extraction of user groups process and counts the assignments of user
* sessions of each user group within each cluster to be able to calculate the misclassification
* rate. Returns the sum of squared error of the clustering
*
* @return the sum of squared error of the executed clustering
* @throws IOException
*/
private double performClustering() throws IOException {
final UserGroupExtraction userGroupExtraction = new UserGroupExtraction(this.entryCallSequenceModel, 3, ClusteringEvaluation.VARIANCE_VALUE, true);
userGroupExtraction.extractUserGroups();
final List<UserSessionCollectionModel> entryCallSequenceModelsOfUserGroups = userGroupExtraction.getEntryCallSequenceModelsOfUserGroups();
this.listOfClusterAssignmentsCounter = new ArrayList<>();
for (int i = 0; i < entryCallSequenceModelsOfUserGroups.size(); i++) {
final ClusterAssignmentsCounter clusterAssignments = new ClusterAssignmentsCounter();
this.listOfClusterAssignmentsCounter.add(clusterAssignments);
}
int index = 0;
for (final UserSessionCollectionModel entryCallSequence : entryCallSequenceModelsOfUserGroups) {
for (final UserSession userSession : entryCallSequence.getUserSessions()) {
if (userSession.getSessionId().equals(ClusteringEvaluation.CUSTOMER_TAG)) {
this.listOfClusterAssignmentsCounter.get(index).increaseNumberOfUserGroupCustomer();
} else if (userSession.getSessionId().equals(ClusteringEvaluation.STORE_MANAGER_TAG)) {
this.listOfClusterAssignmentsCounter.get(index).increaseNumberOfUserGroupStoreManager();
} else if (userSession.getSessionId().equals(ClusteringEvaluation.STOCK_MANAGER_TAG)) {
this.listOfClusterAssignmentsCounter.get(index).increaseNumberOfUserGroupStockManager();
}
}
index++;
}
return userGroupExtraction.getClusteringResults().getClusteringMetrics().getSumOfSquaredErrors();
}
use of org.iobserve.analysis.session.data.UserSession in project iobserve-analysis by research-iobserve.
the class TestHelper method getUserSessions.
/**
* Creates new user sessions.
*
* @param numberOfUserSessionsToCreate
* defines the number of user sessions
* @return new user sessions
*/
public static List<UserSession> getUserSessions(final int numberOfUserSessionsToCreate) {
final List<UserSession> userSessions = new ArrayList<>();
for (int i = 0; i < numberOfUserSessionsToCreate; i++) {
final UserSession userSession = new UserSession("host", String.valueOf(i));
userSessions.add(userSession);
}
return userSessions;
}
Aggregations