rsb module

rsb.get_reward_arm(df_graph, df_weights, new_seed)

Run the IC model and get the reward of adding a seed node

Parameters
  • df_graph (pandas.DataFrame) – The graph we run the RSB on, in the form of a DataFrame. A row represents one edge in the graph, with columns being named “source”, “target”, “probab”. “probab” column is the “true” activation probability used for the simulation.

  • df_weights (pandas.DataFrame) – A dataframe of the node weights used by RSB.

  • new_seed (int) – An id of the new seed node that we are going to test.

Returns

results – An array for nodes affected by adding the new_seed to the seed nodes

Return type

numpy.Array

rsb.rsb(df_edges, nodes, times, num_seeds=10, C=1.0, gamma=0.2, num_repeats_expect=25, style='additive', hide_tqdm=False)

Run the RSB algorithm on a graph

Runs the RSB algorithm [1].

Parameters
  • df_edges (pandas.DataFrame) – The graph we run the TOIM on, in the form of a DataFrame. A row represents one edge in the graph, with columns being named “source”, “target”, “probab”, and “day”. “probab” column is the “true” activation probability and “day” should correspond to the days specified in times.

  • nodes (pandas.Series) – A series containing all unique nodes in df.

  • times (pandas.Series, list) – A series or a list of the times that we are going to iterate through. Useful if you don’t want to iterate through every day in the network.

  • num_seeds (int, optional) – Number of seed nodes to find. Default: 10

  • C (float, optional) – A hyperparameter used by the RSB algorithm. Refer to the RSB paper for more details. [1] Default: 1.0

  • gamma (float, optional) – A hyperparameter used by the RSB algorithm. Refer to the RSB paper for more details. [1] Default: 0.2

  • num_repeats_expect (int, optional) – Default: 25

  • style (str, optional) – Determines whether we take into account all edges up to t (“additive”) or just the ones that were formed at t (“dynamic”). Default: “additive”

  • hide_tqdm (boolean, optional) – A paremeters used if you want to hide all tqdm progress bars. It’s useful if you want to paralellize the algorithm. Default: False

Returns

results – A dataframe with the following columns - time_t, the time step at which everything else was obtained - reward, the average reward obtained by running IC with s_best - selected, the list of the selected seed nodes

Return type

DataFrame

References

1

Bao, Yixin, et al. “Online influence maximization in non-stationary social networks.” 2016 IEEE/ACM 24th International Symposium on Quality of Service (IWQoS). IEEE, 2016