use of weka.core.FastVector 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 weka.core.FastVector in project iobserve-analysis by research-iobserve.
the class BehaviorModelTable method toInstances.
/**
* create an Instances object for clustering.
*
* @return instance
*/
public Instances toInstances() {
final FastVector fastVector = new FastVector();
// add transitions
for (int i = 0; i < this.signatures.size(); i++) {
for (int j = 0; j < this.signatures.size(); j++) {
if (this.transitions[i][j] > AbstractBehaviorModelTable.TRANSITION_THRESHOLD) {
final Attribute attribute = new Attribute(AbstractBehaviorModelTable.EDGE_INDICATOR + this.inverseSignatures[i] + AbstractBehaviorModelTable.EDGE_DIVIDER + this.inverseSignatures[j]);
fastVector.addElement(attribute);
} else {
continue;
}
}
}
// add informations
this.signatures.values().stream().forEach(pair -> Arrays.stream(pair.getSecond()).forEach(callInformation -> fastVector.addElement(new Attribute(AbstractBehaviorModelTable.INFORMATION_INDICATOR + this.inverseSignatures[pair.getFirst()] + AbstractBehaviorModelTable.INFORMATION_DIVIDER + callInformation.getSignature()))));
// TODO name
final Instances instances = new Instances("Test", fastVector, 0);
final Instance instance = this.toInstance();
instances.add(instance);
return instances;
}
use of weka.core.FastVector in project iobserve-analysis by research-iobserve.
the class BehaviorModelTable method toInstances.
/**
* create an Instances object for clustering.
*
* @return instance
*/
public Instances toInstances() {
final FastVector fastVector = new FastVector();
// add transitions
for (int i = 0; i < this.signatures.size(); i++) {
for (int j = 0; j < this.signatures.size(); j++) {
if (this.transitions[i][j] > AbstractBehaviorModelTable.TRANSITION_THRESHOLD) {
final Attribute attribute = new Attribute(AbstractBehaviorModelTable.EDGE_INDICATOR + this.inverseSignatures[i] + AbstractBehaviorModelTable.EDGE_DIVIDER + this.inverseSignatures[j]);
fastVector.addElement(attribute);
} else {
continue;
}
}
}
// add informations
this.signatures.values().stream().forEach(pair -> Arrays.stream(pair.getSecond()).forEach(callInformation -> fastVector.addElement(new Attribute(AbstractBehaviorModelTable.INFORMATION_INDICATOR + this.inverseSignatures[pair.getFirst()] + AbstractBehaviorModelTable.INFORMATION_DIVIDER + callInformation.getSignature()))));
// TODO name
final Instances instances = new Instances("Test", fastVector, 0);
final Instance instance = this.toInstance();
instances.add(instance);
return instances;
}
use of weka.core.FastVector in project iobserve-analysis by research-iobserve.
the class ClusterMerger method execute.
/*
* (non-Javadoc)
*
* @see teetime.framework.AbstractConsumerStage#execute(java.lang.Object)
*/
@Override
protected void execute(final Map<Integer, List<Pair<Instance, Double>>> clustering) throws Exception {
/**
* simply pick the first instance of every cluster lookup attributes to build a new
* instances Object
*/
Instance instance = clustering.entrySet().iterator().next().getValue().get(0).getElement1();
final FastVector attributes = new FastVector();
for (int j = 0; j < instance.numAttributes(); j++) {
attributes.addElement(instance.attribute(j));
}
final Instances result = new Instances("Clustering Result", attributes, clustering.size());
for (final List<Pair<Instance, Double>> entry : clustering.values()) {
if (!entry.isEmpty()) {
instance = entry.get(0).getElement1();
result.add(instance);
}
}
if (ClusterMerger.LOGGER.isDebugEnabled()) {
this.printInstances(result);
}
this.outputPort.send(result);
}
use of weka.core.FastVector in project lobcder by skoulouzis.
the class LDClustering method initAttributes.
private void initAttributes() throws ParseException, Exception {
int index = 0;
Attribute uidAttribute = new Attribute("uid", index++);
// Declare a nominal attribute along with its values
FastVector verbVector = new FastVector(Request.Method.values().length);
for (Request.Method m : Request.Method.values()) {
verbVector.addElement(m.code);
}
Attribute verbAttribute = new Attribute("verb", verbVector, index++);
Attribute checksumAttribute = new Attribute("checksum", (FastVector) null, index++);
Attribute contentTypeAttribute = new Attribute("contentType", (FastVector) null, index++);
Attribute createDateAttribute = new Attribute("createDate", "yyyy-MM-dd HH:mm:ss", index++);
Attribute locationPreferenceAttribute = new Attribute("locationPreference", (FastVector) null, index++);
Attribute descriptionAttribute = new Attribute("description", (FastVector) null, index++);
Attribute validationDateAttribute = new Attribute("validationDate", "yyyy-MM-dd HH:mm:ss", index++);
Attribute lengthAttribute = new Attribute("length", index++);
Attribute modifiedDateAttribute = new Attribute("modifiedDate", "yyyy-MM-dd HH:mm:ss", index++);
Attribute pathAttribute = new Attribute("name", (FastVector) null, index++);
Attribute parentRefAttribute = new Attribute("parentRef", index++);
Attribute statusAttribute = new Attribute("status", (FastVector) null, index++);
FastVector typeVector = new FastVector(3);
typeVector.addElement(nl.uva.cs.lobcder.util.Constants.LOGICAL_DATA);
typeVector.addElement(nl.uva.cs.lobcder.util.Constants.LOGICAL_FILE);
typeVector.addElement(nl.uva.cs.lobcder.util.Constants.LOGICAL_FOLDER);
Attribute typeAttribute = new Attribute("type", typeVector, index++);
// Declare the class attribute along with its values
FastVector supervisedVector = new FastVector(2);
supervisedVector.addElement("true");
supervisedVector.addElement("false");
Attribute supervisedAttribute = new Attribute("supervised", supervisedVector, index++);
Attribute ownerAttribute = new Attribute("owner", (FastVector) null, index++);
// Declare the feature vector
metdataAttributes = new FastVector();
// 0
metdataAttributes.addElement(uidAttribute);
// 1
metdataAttributes.addElement(verbAttribute);
// 2
metdataAttributes.addElement(checksumAttribute);
// 3
metdataAttributes.addElement(contentTypeAttribute);
// 4
metdataAttributes.addElement(createDateAttribute);
// 5
metdataAttributes.addElement(locationPreferenceAttribute);
// 6
metdataAttributes.addElement(descriptionAttribute);
// 7
metdataAttributes.addElement(validationDateAttribute);
// 8
metdataAttributes.addElement(lengthAttribute);
// 9
metdataAttributes.addElement(modifiedDateAttribute);
// 10
metdataAttributes.addElement(pathAttribute);
// 11
metdataAttributes.addElement(parentRefAttribute);
// 12
metdataAttributes.addElement(statusAttribute);
// 13
metdataAttributes.addElement(typeAttribute);
// 14
metdataAttributes.addElement(supervisedAttribute);
// 15
metdataAttributes.addElement(ownerAttribute);
}
Aggregations