Skip to content

Latest commit

 

History

History

book-recommender-system

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

In this project we will show how to use our framework for building privacy-preserving recommender system.

For demonstration purposes we will use Book Recommenation Dataset from Kaggle.

We don't to create fancy recommender system in order to show how to use our framework, so we will use XGBoost model for classification built on top of 3 features: user_age, user_location and book_publication_year.

Following steps are required to build privacy-preserving recommender system:

  1. Data preprocessing and model training
  2. Creating Aleo Project
  3. Model transplilation to Aleo Smart Contracts
  4. Smart contract execution

1. Data preprocessing and model training

a. Download dataset from here and put it into data folder.

Now let's open this notebook and follow instructions there.

2. Creating Aleo Project

To create new Aleo project run following command:

leo new aleo_book_recommender

3. Model transpilation to Aleo Smart Contracts

Instructions for model transpilation can be found here

4. Smart contract execution

Due to unstable testnet we will use local development environment for now.

  1. Build Aleo Smart Contracts
leo build
  1. Create mock data for testing

Let's pick a few random users and books from our dataset and create mock data for them. We've prepared this data for you, so you can find it here.

We apply quantization to our model, so we need to quantize our data as well. Our model uses 32-bit floating point numbers, so we need to quantize our data to 32-bit integers. This notebook shows how to do it.

Here is Aleo inputs from test dataset with positive target (user liked the book):

[main]
book_publication_year: i32 = 32571i32;
user_age: i32 = 32767i32;
user_in_canada: i32 = 32767i32;
user_in_italy: i32 = 0i32;
user_in_spain: i32 = 0i32;
user_in_united_kingdom: i32 = 0i32;
user_in_usa: i32 = 0i32;

Here is Aleo inputs from test dataset with negative target (user didn't like the book):

[main]
book_publication_year: i32 = 32539i32;
user_age: i32 = 4387i32;
user_in_canada: i32 = 0i32;
user_in_italy: i32 = 0i32;
user_in_spain: i32 = 0i32;
user_in_united_kingdom: i32 = 0i32;
user_in_usa: i32 = 32767i32;

Let's grab the first one and paste in aleo_book_recommender.in file.

Run the following command to compile and execute smart contract:

leo run
# 5144i32

Okay we've got positive result, so our model works as expected.

Let's try the second one:

leo run
# -5290i32

Okay we've got negative result, so our model works as expected.

Conclusion

This is how you can build privacy-preserving recommender system using Aleo framework. Score of the model is not very high, but you can improve it by adding more features and using more complex model.

References