Git Product home page Git Product logo

helr's Introduction

HELR: Homomorphic Logistic Regression on Encrypted Data

How to run this program?

In 'Debug' folder, just use 'make all' command (might need to type 'make clean' first if you re-construct this program).

This will construct 'HELR' file that we can run.

The command to run HELR is follow:

./HELR file_name_for_train file_name_for_test isTargetFirst isEncrypted numIter learningRate numThread

  • Here files for train and test should be in data folder with csv format (distinguished by comma).
  • isTargetFirst: the target value (Y_i) is at the first column or last.
  • isEncrypted: usually "1", but you can use "0" if you want to check plaintext logistic regression (with approximate signmoid).
  • numIter: the number of iteration
  • learningRate: the step size of GD algorithm (0.001 - 1.0 value is used)
  • numThread: the number of thread for multi-threading.

Notice that you might need to change the path to the NTL library and HEAAN library (at makefile and src/subdir.mk).

NTL lib: http://www.shoup.net/ntl/

HEAAN lib: https://github.com/kimandrik/HEAAN (commit: c2f08aa6163d7ae193f54419559d8decc6f05ef4)

  • Note that we revise Ring.cpp RingMultiplier.cpp Scheme.cpp to set PRIME_BIT_SIZE instead of 59.0

Result (with MNIST data)

We use compressed MNIST data (original data has size 28 by 28 while our data is 14 by 14). The method for compression is computing mean of 4 element in 2 by 2. The command run same experiment is "./HELR MNIST_train.txt MNIST_test.txt 1 1 32 1.0 8".

Performance on Testing PC

  • 32 number of Intel(R) Xeon(R) CPU E5-2620 v4 2.10 GHz (each CPU has 2 cores, we used 8 thread)
  • 64GB RAM (we use about 10GB RAM in this experiment)
Training Time AUROC Accuracy
68.33 min 0.99 96.2%

Example

// Set BasicThreadPool for multi-threading
BasicThreadPool pool(numThread);

// Read Data
long factorNum, sampleNum;
double** zData = SecureML::zDataFromFile(file, factorNum, sampleNum, isFirst);

// Set parameter
long iterNum = 32;
long learningRate = 1.0;
SecureML::Params params(factorNum, sampleNum, iterNum, learningRate, pool.NumThreads());
params.path_to_file = file; ///< path for train data
params.path_to_test_file = file_test; ///< path for test result
params.isfirst = isFirst; ///< Y is at the first column of the data

// Construct and Key Gen
Ring ring(params.logN, params.logQBoot);
SecretKey sk(ring);
Scheme scheme(sk, ring);
scheme.addLeftRotKeys(sk);
scheme.addRightRotKeys(sk);
scheme.addBootKey(sk, params.bBits, params.logq + params.logI);

// Simple Constructor for secureML class
// This will just pass some address of scheme, params, and pool
SecureML::ML secureML(scheme, params, pool, sk);

// Encrypt Training Data 
// Those ciphertexts will be save in encData folder
secureML.EncryptzData(zData, factorNum, sampleNum);

// Training
// Plaintext training is in encrypted trainig for debug
double* pwData = new double[params.factorNum]();
Ciphertext* encWData = new Ciphertext[params.cnum];
secureML.Training(encWData, factorNum, sampleNum, pwData, zData);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.