use of org.iobserve.analysis.userbehavior.data.UserSessionAsCountsOfCalls in project iobserve-analysis by research-iobserve.
the class AbstractClustering method createInstances.
/**
* It transforms the user sessions(userSessions in form of counts of their called operation
* signatures) to Weka instances that can be used for the clustering.
*
* @param countModel
* contains the userSessions in form of counts of called operation signatures
* @param listOfDistinctOperationSignatures
* contains the extracted distinct operation signatures of the input
* entryCallSequenceModel
* @return the Weka instances that hold the data that is used for the clustering
*/
protected Instances createInstances(final List<UserSessionAsCountsOfCalls> countModel, final List<String> listOfDistinctOperationSignatures) {
final int numberOfDistinctOperationSignatures = listOfDistinctOperationSignatures.size();
final FastVector fvWekaAttributes = new FastVector(numberOfDistinctOperationSignatures);
for (int i = 0; i < numberOfDistinctOperationSignatures; i++) {
final String attributeName = "Attribute" + i;
final Attribute attribute = new Attribute(attributeName);
fvWekaAttributes.addElement(attribute);
}
final Instances clusterSet = new Instances("CallCounts", fvWekaAttributes, countModel.size());
for (final UserSessionAsCountsOfCalls userSession : countModel) {
int indexOfAttribute = 0;
final Instance instance = new Instance(numberOfDistinctOperationSignatures);
for (int row = 0; row < listOfDistinctOperationSignatures.size(); row++) {
instance.setValue((Attribute) fvWekaAttributes.elementAt(indexOfAttribute), userSession.getAbsoluteCountOfCalls()[row]);
indexOfAttribute++;
}
clusterSet.add(instance);
}
return clusterSet;
}
use of org.iobserve.analysis.userbehavior.data.UserSessionAsCountsOfCalls in project iobserve-analysis by research-iobserve.
the class ClusteringPrePostProcessing method getCallCountModel.
/**
* Transforms the passed user sessions to counts of called operation signatures that can be used
* for the similarity calculation of the user group clustering. The objective is to transform
* each user session to a list that contains the number of calls of each distinct operation
* signature. It parses through the entry call sequences of each user session and counts the
* calls of each distinct operation signature. The result is a list of user sessions whose call
* sequence is represented as counts of calls.
*
* @param userSessions
* are transformed to counts of calls
* @param listOfDistinctOperationSignatures
* are the distinct operation signatures whose calls are counted for each user
* session
* @return the passed user sessions as counts of calls
*/
public List<UserSessionAsCountsOfCalls> getCallCountModel(final List<UserSession> userSessions, final List<String> listOfDistinctOperationSignatures) {
final List<UserSessionAsCountsOfCalls> callCountModel = new ArrayList<>();
// during the user session
for (final UserSession userSession : userSessions) {
final UserSessionAsCountsOfCalls absoluteCountOfCalls = new UserSessionAsCountsOfCalls(userSession.getSessionId(), listOfDistinctOperationSignatures.size());
final List<EntryCallEvent> callSequence = userSession.getEvents();
for (int i = 0; i < callSequence.size(); i++) {
final String currentCall = callSequence.get(i).getOperationSignature();
final int indexOfCurrentCall = listOfDistinctOperationSignatures.indexOf(currentCall);
absoluteCountOfCalls.getAbsoluteCountOfCalls()[indexOfCurrentCall] = absoluteCountOfCalls.getAbsoluteCountOfCalls()[indexOfCurrentCall] + 1;
}
callCountModel.add(absoluteCountOfCalls);
}
return callCountModel;
}
use of org.iobserve.analysis.userbehavior.data.UserSessionAsCountsOfCalls in project iobserve-analysis by research-iobserve.
the class UserGroupExtraction method extractUserGroups.
/**
* Function to extract user groups.
*/
public void extractUserGroups() {
final ClusteringPrePostProcessing clusteringProcessing = new ClusteringPrePostProcessing();
final XMeansClustering xMeansClustering = new XMeansClustering();
ClusteringResults xMeansClusteringResults;
/**
* 1. Extraction of distinct system operations. Creates a list of the distinct operation
* signatures occurring within the entryCallSequenceModel. It is required to transform each
* user session to counts of its called operations. The counts are used to determine the
* similarity between the user sessions
*/
final List<String> listOfDistinctOperationSignatures = clusteringProcessing.getListOfDistinctOperationSignatures(this.entryCallSequenceModel.getUserSessions());
/**
* 2. Transformation to the call count model. Transforms the call sequences of the user
* sessions to a list of counts of calls that state the number of calls of each distinct
* operation signature for each user session
*/
final List<UserSessionAsCountsOfCalls> callCountModel = clusteringProcessing.getCallCountModel(this.entryCallSequenceModel.getUserSessions(), listOfDistinctOperationSignatures);
/**
* 3. Clustering of user sessions. Clustering of the user sessions whose behavior is
* represented as counts of their called operation signatures to obtain user groups
*/
final Instances instances = xMeansClustering.createInstances(callCountModel, listOfDistinctOperationSignatures);
/*
* The clustering is performed 5 times and the best result is taken. The quality of a
* clustering result is determined by the value of the sum of squared error (SSE) of the
* clustering. The lower the SSE is the better the clustering result.
*/
for (int i = 0; i < 5; i++) {
xMeansClusteringResults = xMeansClustering.clusterSessionsWithXMeans(instances, this.numberOfUserGroupsFromInputUsageModel, this.varianceOfUserGroups, i);
if (this.clusteringResults == null) {
this.clusteringResults = xMeansClusteringResults;
} else if (xMeansClusteringResults.getClusteringMetrics().getSumOfSquaredErrors() < this.clusteringResults.getClusteringMetrics().getSumOfSquaredErrors()) {
this.clusteringResults = xMeansClusteringResults;
}
}
/**
* 4. Obtaining the user groups' call sequence models. Creates for each cluster resp. user
* group its own entry call sequence model that exclusively contains its assigned user
* sessions
*/
final List<EntryCallSequenceModel> entryCallSequenceModelsOfXMeansClustering = clusteringProcessing.getForEachUserGroupAnEntryCallSequenceModel(this.clusteringResults, this.entryCallSequenceModel);
/**
* 5. Obtaining the user groups' workload intensity. Calculates and sets for each user group
* its specific workload intensity parameters
*/
clusteringProcessing.setTheWorkloadIntensityForTheEntryCallSequenceModels(entryCallSequenceModelsOfXMeansClustering, this.isClosedWorkload);
/**
* Sets the resulting entryCallSequenceModels that can be retrieved via the getter method
*/
this.entryCallSequenceModelsOfUserGroups = entryCallSequenceModelsOfXMeansClustering;
}
Aggregations