binoua commited on
Commit
ac693dc
1 Parent(s): 765e3b9

chore: using a database for keys

Browse files
Files changed (2) hide show
  1. handler.py +0 -1
  2. play_with_endpoint.py +8 -6
handler.py CHANGED
@@ -1,4 +1,3 @@
1
- import time
2
  from typing import Dict, List, Any
3
  import numpy as np
4
  from concrete.ml.deployment import FHEModelServer
 
 
1
  from typing import Dict, List, Any
2
  import numpy as np
3
  from concrete.ml.deployment import FHEModelServer
play_with_endpoint.py CHANGED
@@ -4,9 +4,6 @@ import os, sys
4
 
5
  from pathlib import Path
6
 
7
- from sklearn.datasets import make_classification
8
- from sklearn.model_selection import train_test_split
9
-
10
  from concrete.ml.deployment import FHEModelClient
11
 
12
  import requests
@@ -40,8 +37,13 @@ def query(payload):
40
 
41
 
42
  path_to_model = Path("compiled_model")
 
 
 
 
 
43
  x, y = make_classification(n_samples=1000, class_sep=2, n_features=30, random_state=42)
44
- _, X_test, _, y_test = train_test_split(x, y, test_size=0.2, random_state=42)
45
 
46
  # Recover parameters for client side
47
  fhemodel_client = FHEModelClient(path_to_model)
@@ -98,11 +100,11 @@ for i in range(nb_samples):
98
 
99
  if verbose or True:
100
  print(
101
- f"for {i}-th input, {prediction=} with expected {y_test[i]} in {duration_inference:.3f} seconds"
102
  )
103
 
104
  # Measure accuracy
105
- nb_good += y_test[i] == prediction
106
 
107
  print(f"Accuracy on {nb_samples} samples is {nb_good * 1. / nb_samples}")
108
  print(f"Total time: {time.time() - time_start} seconds")
 
4
 
5
  from pathlib import Path
6
 
 
 
 
7
  from concrete.ml.deployment import FHEModelClient
8
 
9
  import requests
 
37
 
38
 
39
  path_to_model = Path("compiled_model")
40
+
41
+ # Logistic regression in FHE
42
+ from sklearn.datasets import make_classification
43
+ from sklearn.model_selection import train_test_split
44
+
45
  x, y = make_classification(n_samples=1000, class_sep=2, n_features=30, random_state=42)
46
+ _, X_test, _, Y_test = train_test_split(x, y, test_size=0.2, random_state=42)
47
 
48
  # Recover parameters for client side
49
  fhemodel_client = FHEModelClient(path_to_model)
 
100
 
101
  if verbose or True:
102
  print(
103
+ f"for {i}-th input, {prediction=} with expected {Y_test[i]} in {duration_inference:.3f} seconds"
104
  )
105
 
106
  # Measure accuracy
107
+ nb_good += Y_test[i] == prediction
108
 
109
  print(f"Accuracy on {nb_samples} samples is {nb_good * 1. / nb_samples}")
110
  print(f"Total time: {time.time() - time_start} seconds")