hello,
I want to add a max gap constraint to the clasp algorithm implemented in SPMF to limit the distance between two items, but I don't know how to do it, or I haven't succeeded yet. could someone give me some ideas?
ClaSp
Re: ClaSp
Good morning,
Sorry for the delay to answer. Been a bit busy.
I had a look at the code of ClaSP.
I think the main modifications would have to be done to the method dfsPruning() located in the file FrequentPatternEnumeration_ClaSP of the package
ca.pfv.spmf.algorithms.sequentialpatterns.clasp_AGP.
This method is the one who is doing the depth first search. So in this method, you could add the code to avoid doing an s-extension if the gap is too big.
In particular, after a quick look, I think this is the lines for the s-extension:
So you would probably have to add something around that place in the code.
Hope that this help you to get started.
Sorry for the delay to answer. Been a bit busy.
I had a look at the code of ClaSP.
I think the main modifications would have to be done to the method dfsPruning() located in the file FrequentPatternEnumeration_ClaSP of the package
ca.pfv.spmf.algorithms.sequentialpatterns.clasp_AGP.
This method is the one who is doing the depth first search. So in this method, you could add the code to avoid doing an s-extension if the gap is too big.
In particular, after a quick look, I think this is the lines for the s-extension:
Code: Select all
int sequenceExtensionSize = new_sequenceExtension.size();
//For all the elements valuables as future s-extensions
for (int i = 0; i < sequenceExtensionSize; i++) {
//we get the new pattern and the nodeTrie associated with it
Pattern newPattern = newPatterns.get(i);
TrieNode nodeToExtend = newNodesToExtends.remove(0);
Item last = newPattern.getIthElement(newPattern.size() - 1).getItem(); // PFV 2013
/* And we make a recursive call to dfs_pruning with the new sequence
* extension. Besides we establish the same set as the set which we will
* make the i-extensions, but beginning from the (i+1)-th element
*/
exploreChildren(newPattern, nodeToExtend, new_sequenceExtension, new_sequenceExtension, i + 1, coocMapAfter, coocMapEquals, last);
}
Hope that this help you to get started.
Re: ClaSp
Hi,
since I am facing a similar problem, did you manage to modify the algorithm adding the max gap constraint?
Thanks.