InfluenceDiffusion 0.0.7__tar.gz → 0.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/Graph.py +2 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/Trace.py +2 -0
- InfluenceDiffusion-0.0.9/InfluenceDiffusion/__init__.py +6 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/estimation_models/BaseWeightEstimator.py +2 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/estimation_models/EMEstimation.py +2 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/estimation_models/OptimEstimation.py +2 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/utils.py +14 -0
- InfluenceDiffusion-0.0.9/InfluenceDiffusion/weight_samplers.py +33 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion.egg-info/PKG-INFO +1 -1
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion.egg-info/SOURCES.txt +1 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/PKG-INFO +1 -1
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/setup.py +1 -1
- InfluenceDiffusion-0.0.7/InfluenceDiffusion/__init__.py +0 -4
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/estimation_models/__init__.py +0 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/influence_models.py +0 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion.egg-info/dependency_links.txt +0 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion.egg-info/requires.txt +0 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion.egg-info/top_level.txt +0 -0
- {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/setup.cfg +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from .Graph import Graph
|
|
2
|
+
from .influence_models import InfluenceModel, ICM, LTM, GLTM
|
|
3
|
+
from .Trace import Trace, Traces, PseudoTraces
|
|
4
|
+
from .utils import invert_non_zeros, multiple_union, random_vector_inside_simplex, random_vector_on_simplex
|
|
5
|
+
from .weight_samplers import make_weighted_cascade_weights, make_random_weights_with_fixed_indeg, \
|
|
6
|
+
make_random_weights_with_indeg_constraint
|
|
@@ -11,6 +11,8 @@ from ..Trace import Traces, PseudoTraces
|
|
|
11
11
|
from ..Graph import Graph
|
|
12
12
|
from ..utils import multiple_union
|
|
13
13
|
|
|
14
|
+
__all__ = ["BaseWeightEstimator", "BaseGLTWEightEstimator", "BaseICWEightEstimator"]
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
class BaseWeightEstimator:
|
|
16
18
|
"""Base class for weight estimation in influence models.
|
|
@@ -6,6 +6,8 @@ from ..Trace import Traces, PseudoTraces
|
|
|
6
6
|
from ..utils import invert_non_zeros
|
|
7
7
|
from ..Graph import Graph
|
|
8
8
|
|
|
9
|
+
__all__ = ["BaseWeightEstimatorEM", "ICWeightEstimatorEM", "LTWeightEstimatorEM"]
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
class BaseWeightEstimatorEM(BaseWeightEstimator):
|
|
11
13
|
"""Base class for EM weight estimators.
|
|
@@ -7,6 +7,8 @@ from ..Graph import Graph
|
|
|
7
7
|
from ..Trace import Traces, PseudoTraces
|
|
8
8
|
from .BaseWeightEstimator import BaseGLTWEightEstimator
|
|
9
9
|
|
|
10
|
+
__all__ = ["GLTGridSearchEstimator", "GLTWeightEstimator"]
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
class GLTWeightEstimator(BaseGLTWEightEstimator):
|
|
12
14
|
"""GLTW Weight Estimator for modeling influence in networks.
|
|
@@ -14,3 +14,17 @@ def invert_non_zeros(array):
|
|
|
14
14
|
non_zero_mask = array != 0
|
|
15
15
|
out[non_zero_mask] = 1. / out[non_zero_mask]
|
|
16
16
|
return out
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def random_vector_inside_simplex(dim, ub=1):
|
|
20
|
+
U = np.random.uniform(low=0, high=ub, size=dim)
|
|
21
|
+
U_sorted = np.sort(U)
|
|
22
|
+
U_sorted = np.concatenate(([0], U_sorted))
|
|
23
|
+
x = np.diff(U_sorted)
|
|
24
|
+
return x
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def random_vector_on_simplex(dim, ub=1):
|
|
28
|
+
X = random_vector_inside_simplex(dim=dim, ub=1)
|
|
29
|
+
return X / np.sum(X) * ub
|
|
30
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from .Graph import Graph
|
|
4
|
+
from .utils import random_vector_inside_simplex, random_vector_on_simplex
|
|
5
|
+
|
|
6
|
+
__all__ = ["make_weighted_cascade_weights", "make_random_weights_with_indeg_constraint",
|
|
7
|
+
"make_random_weights_with_fixed_indeg"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def make_weighted_cascade_weights(g: Graph):
|
|
11
|
+
vertex_2_indegree = g.get_vertex_2_indegree_dict(weighted=False)
|
|
12
|
+
weights = 1. / np.array([vertex_2_indegree[sink] for sink in g.edge_array[:, 1]])
|
|
13
|
+
return weights
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def make_random_weights_with_indeg_constraint(g: Graph, indeg_ub=1, random_state=None):
|
|
17
|
+
if random_state:
|
|
18
|
+
np.random.seed(random_state)
|
|
19
|
+
weights = np.zeros(g.count_edges())
|
|
20
|
+
for v in g.get_sinks():
|
|
21
|
+
parent_mask = g.get_parents_mask(v)
|
|
22
|
+
weights[parent_mask] = random_vector_inside_simplex(parent_mask.sum(), ub=indeg_ub)
|
|
23
|
+
return weights
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def make_random_weights_with_fixed_indeg(g: Graph, indeg_ub=1, random_state=None):
|
|
27
|
+
if random_state:
|
|
28
|
+
np.random.seed(random_state)
|
|
29
|
+
weights = np.zeros(g.count_edges())
|
|
30
|
+
for v in g.get_sinks():
|
|
31
|
+
parent_mask = g.get_parents_mask(v)
|
|
32
|
+
weights[parent_mask] = random_vector_on_simplex(parent_mask.sum(), ub=indeg_ub)
|
|
33
|
+
return weights
|
{InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion.egg-info/SOURCES.txt
RENAMED
|
@@ -4,6 +4,7 @@ InfluenceDiffusion/Trace.py
|
|
|
4
4
|
InfluenceDiffusion/__init__.py
|
|
5
5
|
InfluenceDiffusion/influence_models.py
|
|
6
6
|
InfluenceDiffusion/utils.py
|
|
7
|
+
InfluenceDiffusion/weight_samplers.py
|
|
7
8
|
InfluenceDiffusion.egg-info/PKG-INFO
|
|
8
9
|
InfluenceDiffusion.egg-info/SOURCES.txt
|
|
9
10
|
InfluenceDiffusion.egg-info/dependency_links.txt
|
|
File without changes
|
{InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion/influence_models.py
RENAMED
|
File without changes
|
|
File without changes
|
{InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion.egg-info/requires.txt
RENAMED
|
File without changes
|
{InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.9}/InfluenceDiffusion.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|