Search in sources :

Example 1 with UserSessionAsCountsOfCalls

use of org.iobserve.analysis.behavior.karlsruhe.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<UserSessionCollectionModel> 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;
}
Also used : Instances(weka.core.Instances) UserSessionCollectionModel(org.iobserve.analysis.data.UserSessionCollectionModel) UserSessionAsCountsOfCalls(org.iobserve.analysis.behavior.karlsruhe.data.UserSessionAsCountsOfCalls) ClusteringResults(org.iobserve.analysis.behavior.karlsruhe.data.ClusteringResults)

Example 2 with UserSessionAsCountsOfCalls

use of org.iobserve.analysis.behavior.karlsruhe.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;
}
Also used : UserSessionAsCountsOfCalls(org.iobserve.analysis.behavior.karlsruhe.data.UserSessionAsCountsOfCalls) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) UserSession(org.iobserve.analysis.session.data.UserSession) ArrayList(java.util.ArrayList)

Example 3 with UserSessionAsCountsOfCalls

use of org.iobserve.analysis.behavior.karlsruhe.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;
}
Also used : Instances(weka.core.Instances) FastVector(weka.core.FastVector) UserSessionAsCountsOfCalls(org.iobserve.analysis.behavior.karlsruhe.data.UserSessionAsCountsOfCalls) Attribute(weka.core.Attribute) Instance(weka.core.Instance)

Aggregations

UserSessionAsCountsOfCalls (org.iobserve.analysis.behavior.karlsruhe.data.UserSessionAsCountsOfCalls)3 Instances (weka.core.Instances)2 ArrayList (java.util.ArrayList)1 ClusteringResults (org.iobserve.analysis.behavior.karlsruhe.data.ClusteringResults)1 UserSessionCollectionModel (org.iobserve.analysis.data.UserSessionCollectionModel)1 UserSession (org.iobserve.analysis.session.data.UserSession)1 EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)1 Attribute (weka.core.Attribute)1 FastVector (weka.core.FastVector)1 Instance (weka.core.Instance)1