Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TIPM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BARBIER Marc
TIPM
Commits
3a6dc14e
Unverified
Commit
3a6dc14e
authored
3 years ago
by
BARBIER Marc
Browse files
Options
Downloads
Patches
Plain Diff
unifed mining route
parent
caee661d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/be/uantwerpen/mime_webapp/controller/PatternMiningController.java
+40
-36
40 additions, 36 deletions
...erpen/mime_webapp/controller/PatternMiningController.java
with
40 additions
and
36 deletions
src/main/java/be/uantwerpen/mime_webapp/controller/PatternMiningController.java
+
40
−
36
View file @
3a6dc14e
...
...
@@ -18,6 +18,7 @@ import javax.validation.constraints.NotNull;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -59,14 +60,7 @@ public class PatternMiningController {
MakePatternOccurrencesSpan
makePatternOccurrencesSpan
=
new
MakePatternOccurrencesSpan
();
RunPBADEmbeddingOnly
runPBADEmbeddingOnly
=
new
RunPBADEmbeddingOnly
();
@RequestMapping
(
value
=
"/rest/mining/run-itemsets"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
String
runItemsetMining
(
@RequestParam
(
"id"
)
Optional
<
String
>
id
,
@RequestParam
(
"columns"
)
String
columns
,
@NotNull
@RequestParam
(
"algorithm"
)
String
algorithm
,
@NotNull
@RequestParam
(
"support"
)
String
support
,
HttpServletRequest
request
)
{
private
String
runMining
(
String
columns
,
HttpServletRequest
request
,
Optional
<
String
>
id
,
String
support
,
String
algorithm
,
boolean
isItemset
)
{
try
{
String
[]
columnsArr
=
columns
.
split
(
",\\s*"
);
FileItem
currentInput
=
getCurrentItem
(
request
,
id
);
...
...
@@ -75,49 +69,59 @@ public class PatternMiningController {
throw
new
RuntimeException
(
"Only Arff supported"
);
File
data
=
currentInput
.
getFile
();
Double
supportAsFloat
=
Double
.
valueOf
(
support
);
File
outputReadable
=
MineUsingSPMF
.
runItemsetMining
(
data
,
Arrays
.
asList
(
columnsArr
),
algorithm
,
supportAsFloat
);
savePatterns
(
request
,
id
,
currentInput
.
getFile
(),
outputReadable
,
"itemsets"
,
columns
,
algorithm
,
support
);
File
occurrencesFile
=
storePatternSetOccurrences
(
id
,
outputReadable
.
getName
(),
request
);
savePatternsWithMetadata
(
outputReadable
,
occurrencesFile
,
currentInput
.
getFile
());
double
supportAsFloat
=
Double
.
parseDouble
(
support
);
File
outputReadable
=
null
;
if
(
isItemset
)
{
outputReadable
=
MineUsingSPMF
.
runItemsetMining
(
data
,
Arrays
.
asList
(
columnsArr
),
algorithm
,
supportAsFloat
);
}
else
{
outputReadable
=
MineUsingSPMF
.
runSequentialPatternMining
(
data
,
Arrays
.
asList
(
columnsArr
),
algorithm
,
supportAsFloat
);
}
savePatterns
(
request
,
id
,
data
,
outputReadable
,
"sequential patterns"
,
columns
,
algorithm
,
support
);
File
occFile
=
storePatternSetOccurrences
(
id
,
outputReadable
.
getName
(),
request
);
savePatternsWithMetadata
(
outputReadable
,
occFile
,
data
);
return
String
.
format
(
"Found %d patterns."
,
IOUtils
.
countLines
(
outputReadable
)-
1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
(
new
RuntimeException
(
e
.
getMessage
())
);
throw
new
RuntimeException
(
e
);
}
}
@
Reque
stMapping
(
value
=
"/rest/mining/run-
sp"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
String
run
SequentialPattern
Mining
(
@
Po
stMapping
(
value
=
"/rest/mining/run-
itemsets"
)
public
@ResponseBody
String
run
Itemset
Mining
(
@RequestParam
(
"id"
)
Optional
<
String
>
id
,
@RequestParam
(
"columns"
)
String
columns
,
@NotNull
@RequestParam
(
"algorithm"
)
String
algorithm
,
@NotNull
@RequestParam
(
"support"
)
String
support
,
HttpServletRequest
request
)
{
try
{
String
[]
columnsArr
=
columns
.
split
(
",\\s*"
);
FileItem
currentInput
=
getCurrentItem
(
request
,
id
);
if
(!
currentInput
.
isArff
())
throw
new
RuntimeException
(
"Only Arff supported"
);
File
data
=
currentInput
.
getFile
();
double
supportAsFloat
=
Double
.
parseDouble
(
support
);
File
outputReadable
=
MineUsingSPMF
.
runSequentialPatternMining
(
data
,
Arrays
.
asList
(
columnsArr
),
algorithm
,
supportAsFloat
);
savePatterns
(
request
,
id
,
data
,
outputReadable
,
"sequential patterns"
,
columns
,
algorithm
,
support
);
File
occFile
=
storePatternSetOccurrences
(
id
,
outputReadable
.
getName
(),
request
);
savePatternsWithMetadata
(
outputReadable
,
occFile
,
data
);
return
String
.
format
(
"Found %d patterns."
,
IOUtils
.
countLines
(
outputReadable
)-
1
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
.
getMessage
());
return
runMining
(
columns
,
request
,
id
,
support
,
algorithm
,
true
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
@PostMapping
(
value
=
"/rest/mining/run-sp"
)
public
@ResponseBody
String
runSequentialPatternMining
(
@RequestParam
(
"id"
)
Optional
<
String
>
id
,
@RequestParam
(
"columns"
)
String
columns
,
@NotNull
@RequestParam
(
"algorithm"
)
String
algorithm
,
@NotNull
@RequestParam
(
"support"
)
String
support
,
HttpServletRequest
request
)
{
return
runMining
(
columns
,
request
,
id
,
support
,
algorithm
,
false
);
}
//new unified route.
@PostMapping
(
value
=
"/rest/mining/mine"
)
public
@ResponseBody
String
runItemsetMining
(
@RequestParam
(
"id"
)
Optional
<
String
>
id
,
@RequestParam
(
"columns"
)
String
columns
,
@NotNull
@RequestParam
(
"algorithm"
)
String
algorithm
,
@NotNull
@RequestParam
(
"support"
)
String
support
,
@NotNull
@RequestParam
(
"isItemset"
)
Boolean
isItemset
,
HttpServletRequest
request
)
{
return
runMining
(
columns
,
request
,
id
,
support
,
algorithm
,
isItemset
);
}
private
File
storePatternSetOccurrences
(
Optional
<
String
>
id
,
String
patternFilename
,
HttpServletRequest
request
)
throws
Exception
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment