Code Monkey home page Code Monkey logo

c1oover / concrete-ml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zama-ai/concrete-ml

0.0 0.0 0.0 26.13 MB

Concrete-ML is a Privacy-Preserving Machine Learning (PPML) open-source set of tools which aims to simplify the use of fully homomorphic encryption (FHE) for data scientists. Particular care was given to the simplicity of our Python package in order to make it usable by any data scientist, even those without prior cryptography knowledge.

License: Other

Shell 4.79% Python 91.84% Makefile 3.38%

concrete-ml's Introduction

Concrete ML

Concrete-ML is an open-source set of tools which aims to simplify the use of fully homomorphic encryption (FHE) for data scientists. Particular care was given to the simplicity of our Python package in order to make it usable by any data scientist, even those without prior cryptography knowledge. Notably, our APIs are as close as possible to scikit-learn and torch APIs to simplify adoption by our users.

Links

For end users

Installation.

The preferred way to use Concrete-ML is through Docker. You can get our Docker image by pulling the latest Docker image:

docker pull zamafhe/concrete-ml:latest

To install Concrete-ML from PyPi, run the following:

pip install concrete-ml

You can find more detailed installation instructions in installing.md

Supported models.

Here is a list of ML algorithms currently supported in this library:

  • LinearRegression (sklearn)
  • LogisticRegression (sklearn)
  • SVM - SVC and SVR (sklearn)
  • DecisionTreeClassifier (sklearn)
  • RandomForestClassifier (sklearn)
  • NeuralNetworkClassifier (skorch)
  • NeuralNetworkRegressor (skorch)
  • XGBoostClassifier (xgboost)

Torch also has its own integration for custom models.

Simple ML examples with scikit-learn.

A simple example which is very close to scikit-learn is as follows, for a logistic regression :

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split

from concrete.ml.sklearn import LogisticRegression

# Create the data for classification
x, y = make_classification(n_samples=100, class_sep=2, n_features=4, random_state=42)

# Retrieve train and test sets
X_train, X_test, y_train, y_test = train_test_split(
    x, y, test_size=10, random_state=42
)

# Fix the number of bits to used for quantization 
model = LogisticRegression(n_bits=2)

# Fit the model
model.fit(X_train, y_train)

# Run the predictions on non-encrypted data as a reference
y_pred_clear = model.predict(X_test, execute_in_fhe=False)

# Compile into an FHE model
model.compile(x)

# Run the inference in FHE
y_pred_fhe = model.predict(X_test, execute_in_fhe=True)

print("In clear  :", y_pred_clear)
print("In FHE    :", y_pred_fhe)
print(f"Comparison: {int((y_pred_fhe == y_pred_clear).sum()/len(y_pred_fhe)*100)}% similar")

# Output:
#  In clear  : [0 0 0 1 0 1 0 1 1 1]
#  In FHE    : [0 0 0 1 0 1 0 1 1 1]
#  Comparison: 100% similar

We explain this in more detail in the documentation, and show how we have tried to mimic scikit-learn and torch APIs, to ease the adoption of Concrete-ML. We refer the reader to linear models, tree-based models and neural networks documentations, which show how similar our APIs are to their non-FHE counterparts.

For developers

Project setup.

Installation steps are described in project_setup.md. Information about how to use Docker for development are available in docker_setup.md.

Documenting.

Some information about how to build the documentation of Concrete-ML are available. Notably, our documentation is pushed to https://docs.zama.ai/concrete-ml/.

Developing.

Contributing.

Information about how to contribute is available in contributing.md.

License

This software is distributed under the BSD-3-Clause-Clear license. If you have any questions, please contact us at [email protected].

concrete-ml's People

Contributors

bcm-at-zama avatar icetdrinker avatar jfrery avatar andrei-stoian-zama avatar romanbredehoft avatar dependabot[bot] avatar fd0r avatar

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.