InfluenceDiffusion 0.0.7__tar.gz → 0.0.8__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.
Files changed (18) hide show
  1. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/Graph.py +2 -0
  2. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/Trace.py +2 -0
  3. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/__init__.py +1 -1
  4. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/estimation_models/BaseWeightEstimator.py +2 -0
  5. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/estimation_models/EMEstimation.py +2 -0
  6. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/estimation_models/OptimEstimation.py +2 -0
  7. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/utils.py +14 -0
  8. InfluenceDiffusion-0.0.8/InfluenceDiffusion/weight_samplers.py +30 -0
  9. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion.egg-info/PKG-INFO +1 -1
  10. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion.egg-info/SOURCES.txt +1 -0
  11. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/PKG-INFO +1 -1
  12. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/setup.py +1 -1
  13. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/estimation_models/__init__.py +0 -0
  14. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion/influence_models.py +0 -0
  15. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion.egg-info/dependency_links.txt +0 -0
  16. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion.egg-info/requires.txt +0 -0
  17. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/InfluenceDiffusion.egg-info/top_level.txt +0 -0
  18. {InfluenceDiffusion-0.0.7 → InfluenceDiffusion-0.0.8}/setup.cfg +0 -0
@@ -3,6 +3,8 @@ import numpy as np
3
3
  from typing import List, Tuple, Union, Dict
4
4
  import networkx as nx
5
5
 
6
+ __all__ = ["Graph"]
7
+
6
8
 
7
9
  class Graph(nx.DiGraph):
8
10
  def __init__(self, edge_list: List[Tuple[int, int]],
@@ -6,6 +6,8 @@ from itertools import chain
6
6
  from .Graph import Graph
7
7
  from .utils import multiple_union
8
8
 
9
+ __all__ = ["PseudoTraces", "Traces", "Trace"]
10
+
9
11
 
10
12
  class PseudoTraces(dict):
11
13
  """A collection of pseudo traces.
@@ -1,4 +1,4 @@
1
1
  from .Graph import Graph
2
2
  from .influence_models import InfluenceModel, ICM, LTM, GLTM
3
3
  from .Trace import Trace, Traces, PseudoTraces
4
- from .utils import invert_non_zeros, multiple_union
4
+ from .utils import invert_non_zeros, multiple_union, random_vector_inside_simplex, random_vector_on_simplex
@@ -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,30 @@
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
+
7
+ def make_weighted_cascade_weights(g: Graph):
8
+ vertex_2_indegree = g.get_vertex_2_indegree_dict(weighted=False)
9
+ weights = 1. / np.array([vertex_2_indegree[sink] for sink in g.edge_array[:, 1]])
10
+ return weights
11
+
12
+
13
+ def make_random_weights_with_indeg_constraint(g: Graph, indeg_ub=1, random_state=None):
14
+ if random_state:
15
+ np.random.seed(random_state)
16
+ weights = np.zeros(g.count_edges())
17
+ for v in g.get_sinks():
18
+ parent_mask = g.get_parents_mask(v)
19
+ weights[parent_mask] = random_vector_inside_simplex(parent_mask.sum(), ub=indeg_ub)
20
+ return weights
21
+
22
+
23
+ def make_random_weights_with_fixed_indeg(g: Graph, indeg_ub=1, random_state=None):
24
+ if random_state:
25
+ np.random.seed(random_state)
26
+ weights = np.zeros(g.count_edges())
27
+ for v in g.get_sinks():
28
+ parent_mask = g.get_parents_mask(v)
29
+ weights[parent_mask] = random_vector_on_simplex(parent_mask.sum(), ub=indeg_ub)
30
+ return weights
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: InfluenceDiffusion
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: InfluenceDiffusion package
5
5
  Author: Alexander Kagan
6
6
  Author-email: <amkagan@umich.edu>
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: InfluenceDiffusion
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: InfluenceDiffusion package
5
5
  Author: Alexander Kagan
6
6
  Author-email: <amkagan@umich.edu>
@@ -1,6 +1,6 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
- VERSION = '0.0.7'
3
+ VERSION = '0.0.8'
4
4
  DESCRIPTION = 'InfluenceDiffusion package'
5
5
  LONG_DESCRIPTION = 'in this package, we implement popular network diffusion models and methods for their estimation.'
6
6