Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BA Timeline Summarization
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kaiser
BA Timeline Summarization
Commits
e682cf0c
Commit
e682cf0c
authored
3 years ago
by
vvye
Browse files
Options
Downloads
Patches
Plain Diff
Implement personalized pagerank by date uniformity
parent
53a69981
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
date_selection.py
+28
-5
28 additions, 5 deletions
date_selection.py
with
28 additions
and
5 deletions
date_selection.py
+
28
−
5
View file @
e682cf0c
import
math
from
collections
import
Counter
import
igraph
...
...
@@ -37,13 +38,35 @@ def rank_dates_by_wilson(articles, start_date, end_date, num_dates):
g
=
igraph
.
Graph
.
TupleList
(
edges
,
directed
=
True
,
edge_attrs
=
'
weight
'
)
vertex_names
=
g
.
vs
[
'
name
'
]
# rank vertices by pagerank score
pagerank_scores
=
g
.
pagerank
(
directed
=
True
,
weights
=
g
.
es
[
'
weight
'
])
ranked_dates
=
util
.
rank
(
vertex_names
,
scores
=
pagerank_scores
)
# rank the dates with personalized pagerank
# (do this multiple times with different "vertex weights", depending on alpha,
# and return the result that is most uniform)
best_uniformity
=
math
.
inf
best_ranked_dates
=
[]
candidate_alphas
=
[
0.01
*
x
for
x
in
range
(
1
,
100
)]
for
alpha
in
candidate_alphas
:
print
(
date_uniformity
(
ranked_dates
[:
num_dates
]))
# calculate vertex "weights" for personalized pagerank
vertex_weights
=
[]
start
=
min
(
vertex_names
)
for
date
in
vertex_names
:
diff_to_start
=
util
.
days_between
(
start
,
date
)
try
:
vertex_weights
.
append
(
alpha
**
-
diff_to_start
)
except
OverflowError
:
vertex_weights
.
append
(
math
.
inf
)
return
ranked_dates
# rank vertices with personalized pagerank
pagerank_scores
=
g
.
personalized_pagerank
(
directed
=
True
,
weights
=
g
.
es
[
'
weight
'
],
reset
=
vertex_weights
)
ranked_dates
=
util
.
rank
(
vertex_names
,
scores
=
pagerank_scores
)
# if this result is the most uniform yet, save it
uniformity
=
date_uniformity
(
ranked_dates
[:
num_dates
])
if
uniformity
<
best_uniformity
:
best_uniformity
=
uniformity
best_ranked_dates
=
ranked_dates
return
best_ranked_dates
def
date_uniformity
(
dates
):
...
...
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