/
build.gradle
152 lines (135 loc) · 4.54 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* This file may be freely modified, used, and redistributed without restriction. */
/* Set up the repositories to get the LensKit plugin.
* This configuration pulls in things needed for the build.gradle script itself */
buildscript {
repositories {
if (project.findProperty('maven.useLocal') == 'yes') {
mavenLocal()
}
// LensKit snapshots are published to the Sonatype snapshot repository
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
// LensKit releases are published to Maven Central
mavenCentral()
}
dependencies {
classpath 'org.lenskit:lenskit-gradle:3.0-SNAPSHOT'
}
}
apply plugin: 'java' // if you use Groovy or Scala, add those plugins
apply plugin: 'lenskit'
/* Set up the repositories for getting LensKit and other libraries.
* These repositories are used for your Java or Groovy code, and for running LensKit.
*/
repositories {
if (project.findProperty('maven.useLocal') == 'yes') {
logger.lifecycle('using Maven local repository')
mavenLocal()
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
mavenCentral()
}
dependencies {
// Code needs to build with LensKit.
compile "org.lenskit:lenskit-all:3.0-SNAPSHOT"
// To run the code, we also need the LensKit CLI.
runtime "org.lenskit:lenskit-cli:3.0-SNAPSHOT"
// Tests use JUnit
testCompile "junit:junit:4.12"
}
/* Configure LensKit */
lenskit {
// you can configure the threadCount and maxMemory here, or on the command line
// e.g. -PthreadCount=8
}
import org.lenskit.gradle.Crossfold
import org.lenskit.gradle.TrainTest
task crossfold(type: Crossfold, group: 'evaluate') {
input 'data/ml-1m.yml'
// test on random 5 ratings for each user
holdout(5, 'random')
// use 5-fold cross-validation
partitionCount 5
}
/* Run the LensKit evaluation */
task evaluateML(type: TrainTest, group: 'evaluate') {
description 'Runs the LensKit evaluation.'
logFile "$buildDir/evaluate.log"
logFileLevel 'DEBUG'
// we add our crossfold task as evaluation input
dataSet crossfold
// send the output to appropriate files
outputFile "$buildDir/movielens-results.csv"
userOutputFile "$buildDir/movielens-user-results.csv"
// configure our algorithms
algorithm 'Pop', 'algorithms/ml/popular.groovy'
algorithm 'D-G', 'algorithms/ml/gender-pop.groovy'
algorithm 'D-A', 'algorithms/ml/age-pop.groovy'
algorithm 'D-GA', 'algorithms/ml/gender-age-pop.groovy'
algorithm 'RB', 'algorithms/ml/pers-mean.groovy'
algorithm 'II', 'algorithms/ml/item-item.groovy'
algorithm 'UU', 'algorithms/ml/user-user.groovy'
algorithm 'MF', 'algorithms/ml/funksvd.groovy'
algorithm 'II-I', 'algorithms/ml/item-item-implicit.groovy'
algorithm 'UU-I', 'algorithms/ml/user-user-implicit.groovy'
algorithm 'MF-I', 'algorithms/ml/funksvd-implicit.groovy'
// and some evaluation tasks and metrics
predict {
metric 'rmse'
metric 'ndcg'
}
recommend {
listSize 100
metric 'ndcg'
metric 'mrr'
metric 'map'
metric 'pr'
}
recommend {
listSize 100
labelPrefix '1R'
separateItems true
itemOutputFile "$buildDir/movielens-1R-items.csv"
metric 'ndcg'
metric 'mrr'
metric 'map'
metric 'pr'
}
}
task evaluateLastFM(type: TrainTest, group: 'evaluate') {
description 'Runs the LensKit evaluation.'
logFile "$buildDir/evaluate-lastfm.log"
// we add our crossfold task as evaluation input
dataSet 'data/lastfm-user-splits.yml'
dataSet 'data/lastfm-item-splits.yml'
// send the output to appropriate files
outputFile "$buildDir/lastfm-results.csv"
userOutputFile "$buildDir/lastfm-user-results.csv"
// configure our algorithms
algorithm 'Pop', 'algorithms/lastfm/popular.groovy'
algorithm 'PopCt', 'algorithms/lastfm/pop-count.groovy'
algorithm 'II', 'algorithms/lastfm/item-item.groovy'
algorithm 'MF', 'algorithms/lastfm/funksvd.groovy'
algorithm 'UU', 'algorithms/lastfm/user-user.groovy'
// and some evaluation tasks and metrics
recommend {
listSize 100
metric 'ndcg'
metric 'mrr'
metric 'map'
metric 'pr'
}
recommend {
listSize 100
labelPrefix '1R'
separateItems true
itemOutputFile "$buildDir/lastfm-1R-items.csv"
metric 'ndcg'
metric 'mrr'
metric 'map'
metric 'pr'
}
}