You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 5.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # Contents
  2. - [LDP LinUCB Description](#ldp-linucb-description)
  3. - [Model Architecture](#model-architecture)
  4. - [Dataset](#dataset)
  5. - [Environment Requirements](#environment-requirements)
  6. - [Script Description](#script-description)
  7. - [Script and Sample Code](#script-and-sample-code)
  8. - [Script Parameters](#script-parameters)
  9. - [Launch](#launch)
  10. - [Model Description](#model-description)
  11. - [Performance](#performance)
  12. - [Description of Random Situation](#description-of-random-situation)
  13. - [ModelZoo Homepage](#modelzoo-homepage)
  14. # [LDP LinUCB](#contents)
  15. Locally Differentially Private (LDP) LinUCB is a variant of LinUCB bandit algorithm with local differential privacy guarantee, which can preserve users' personal data with theoretical guarantee.
  16. [Paper](https://arxiv.org/abs/2006.00701): Kai Zheng, Tianle Cai, Weiran Huang, Zhenguo Li, Liwei Wang. "Locally Differentially Private (Contextual) Bandits Learning." *Advances in Neural Information Processing Systems*. 2020.
  17. # [Model Architecture](#contents)
  18. The server interacts with users in rounds. For a coming user, the server first transfers the current model parameters to the user. In the user side, the model chooses an action based on the user feature to play (e.g., choose a movie to recommend), and observes a reward (or loss) value from the user (e.g., rating of the movie). Then we perturb the data to be transferred by adding Gaussian noise. Finally, the server receives the perturbed data and updates the model. Details can be found in the [original paper](https://arxiv.org/abs/2006.00701).
  19. # [Dataset](#contents)
  20. Note that you can run the scripts based on the dataset mentioned in original paper. In the following sections, we will introduce how to run the scripts using the related dataset below.
  21. Dataset used: [MovieLens 100K](https://grouplens.org/datasets/movielens/100k/)
  22. - Dataset size:5MB, 100,000 ratings (1-5) from 943 users on 1682 movies.
  23. - Data format:csv/txt files
  24. # [Environment Requirements](#contents)
  25. - Hardware (Ascend/GPU)
  26. - Prepare hardware environment with Ascend or GPU processor.
  27. - Framework
  28. - [MindSpore](https://www.mindspore.cn/install/en)
  29. - For more information, please check the resources below:
  30. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  31. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  32. # [Script Description](#contents)
  33. ## [Script and Sample Code](#contents)
  34. ```console
  35. ├── model_zoo
  36. ├── README.md // descriptions about all the models
  37. ├── research
  38. ├── rl
  39. ├── ldp_linucb
  40. ├── README.md // descriptions about LDP LinUCB
  41. ├── scripts
  42. │ ├── run_train_eval.sh // shell script for running on Ascend
  43. ├── src
  44. │ ├── dataset.py // dataset for movielens
  45. │ ├── linucb.py // model
  46. ├── train_eval.py // training script
  47. ├── result1.png // experimental result
  48. ├── result2.png // experimental result
  49. ```
  50. ## [Script Parameters](#contents)
  51. - Parameters for preparing MovieLens 100K dataset
  52. ```python
  53. 'num_actions': 20 # number of candidate movies to be recommended
  54. 'rank_k': 20 # rank of rating matrix completion
  55. ```
  56. - Parameters for LDP LinUCB, MovieLens 100K dataset
  57. ```python
  58. 'epsilon': 8e5 # privacy parameter
  59. 'delta': 0.1 # privacy parameter
  60. 'alpha': 0.1 # failure probability
  61. 'iter_num': 1e6 # number of iterations
  62. ```
  63. ## [Launch](#contents)
  64. - running on Ascend
  65. ```shell
  66. python train_eval.py > result.log 2>&1 &
  67. ```
  68. The python command above will run in the background, you can view the results through the file `result.log`.
  69. The regret value will be achieved as follows:
  70. ```console
  71. --> Step: 0, diff: 348.662, current_regret: 0.000, cumulative regret: 0.000
  72. --> Step: 1, diff: 338.457, current_regret: 0.000, cumulative regret: 0.000
  73. --> Step: 2, diff: 336.465, current_regret: 2.000, cumulative regret: 2.000
  74. --> Step: 3, diff: 327.337, current_regret: 0.000, cumulative regret: 2.000
  75. --> Step: 4, diff: 325.039, current_regret: 2.000, cumulative regret: 4.000
  76. ...
  77. ```
  78. # [Model Description](#contents)
  79. The [original paper](https://arxiv.org/abs/2006.00701) assumes that the norm of user features is bounded by 1 and the norm of rating scores is bounded by 2. For the MovieLens dataset, we normalize rating scores to [-1,1]. Thus, we set `sigma` in Algorithm 5 to be $$4/epsilon \* sqrt(2 \* ln(1.25/delta))$$.
  80. ## [Performance](#contents)
  81. The performance for different privacy parameters:
  82. - x: number of iterations
  83. - y: cumulative regret
  84. ![Result1](result1.png)
  85. The performance compared with optimal non-private regret O(sqrt(T)):
  86. - x: number of iterations
  87. - y: cumulative regret divided by sqrt(T)
  88. ![Result2](result2.png)
  89. # [Description of Random Situation](#contents)
  90. In `train_eval.py`, we randomly sample a user at each round. We also add Gaussian noise to the date being transferred.
  91. # [ModelZoo Homepage](#contents)
  92. Please check the official
  93. [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).