Differentially private machine learning मॉडल

Python में डेटा प्राइवेसी और अज्ञातिकरण

Rebeca Gonzalez

Data Engineer

डेटा सुरक्षित तरीके से साझा करें

समान डेटा वाली कंपनियाँ, प्रोडक्ट और सेवाएँ बेहतर करने के लिए जानकारी साझा करती हैं.
  • Machine Learning (ML) मॉडल सहित

डेटा चार्ट देखते व्यक्ति की छवि

Python में डेटा प्राइवेसी और अज्ञातिकरण

Differentially private machine learning मॉडल

  • एक SaaS कंपनी जिसके कई ऑनलाइन स्टोर पार्टनर हैं.
  • नया पार्टनर जुड़ने पर पर्याप्त डेटा जुटाने में महीनों लग सकते हैं
  • DP के साथ, SaaS कंपनी पार्टनर्स को डेटा साझा करने के लिए प्रेरित कर सकती है

लैपटॉप पकड़े व्यक्ति का चित्र, स्क्रीन से रॉकेट निकल रहा है

$$ $$ एक व्यक्ति के नीचे कई लोगों के आइकन, अनेक पार्टनर्स का संकेत

Python में डेटा प्राइवेसी और अज्ञातिकरण

Machine learning और प्राइवेसी

  • डेटासेट में संवेदनशील जानकारी होती है
  • हमलावर machine learning एल्गोरिदम के आउटपुट का दुरुपयोग कर सकते हैं
Python में डेटा प्राइवेसी और अज्ञातिकरण

Machine learning और प्राइवेसी

Differentially private machine learning मॉडल

  • संबंधित data distributions का पालन करते हैं
  • व्यक्तियों की प्राइवेसी की गारंटी दे सकते हैं
Python में डेटा प्राइवेसी और अज्ञातिकरण

Differentially private classification मॉडल्स

# Import the scikit-learn naive Bayes classifier
from sklearn.naive_bayes import GaussianNB


# Import the differentially private naive Bayes classifier from diffprivlib.models import GaussianNB
Python में डेटा प्राइवेसी और अज्ञातिकरण

Non-private क्लासिफायर

from sklearn.naive_bayes import GaussianNB

# नॉन-प्राइवेट क्लासिफायर बनाएँ nonprivate_clf = GaussianNB()
# मॉडल को डेटा पर फिट करें nonprivate_clf.fit(X_train, y_train)
print("The accuracy of the non-private model is ", nonprivate_clf.score(X_test, y_test))
The accuracy of the non-private model is  0.8333333333333334
Python में डेटा प्राइवेसी और अज्ञातिकरण

Differentially private क्लासिफायर

from diffprivlib.models import GaussianNB as dp_GaussianNB

# खाली कंस्ट्रक्टर से प्राइवेट क्लासिफायर बनाएँ private_clf = dp_GaussianNB()
# मॉडल को डेटा पर फिट करें और स्कोर देखें private_clf.fit(X_train, y_train)
print("The accuracy of the private model is ", private_clf.score(X_test, y_test))
The accuracy of the private model is  0.7
PrivacyLeakWarning: Bounds have not been specified and will be calculated 
  on the data provided. This will result in additional privacy leakage.
  To ensure differential privacy and no additional privacy leakage, specify bounds for each dimension.
  "privacy leakage, specify bounds for each dimension.", PrivacyLeakWarning)
Python में डेटा प्राइवेसी और अज्ञातिकरण

प्राइवेसी लीकेज से बचें

डेटा लीकेज से बचने के लिए, हम bounds आर्गुमेंट देकर min और max मान सेट कर सकते हैं. यह हो सकता है:

  • (min, max) के रूप में एक ट्युपल
    • ऐसे integers जो पूरे डेटा के min/max को कवर करें
      • उदाहरण:
        (0,100)
        
    • डेटा की हर कॉलम के min और max के लिए arrays.
      • उदाहरण:
        ([0,1,0,2],[10,80,5,70])
        
Python में डेटा प्राइवेसी और अज्ञातिकरण

प्राइवेसी लीकेज से बचें

# Set the bounds to cover at least the min and max values 
bounds = (X_train.min(axis=0) - 1, X_train.max(axis=0) + 1)

# epsilon 0.5 के साथ क्लासिफायर बनाएँ dp_clf = dp_GaussianNB(epsilon=0.5, bounds=bounds)
# मॉडल को डेटा पर फिट करें और स्कोर देखें dp_clf.fit(X_train, y_train) print("The accuracy of the private model is ", private_clf.score(X_test, y_test))
The accuracy of the private model is  0.807000
Python में डेटा प्राइवेसी और अज्ञातिकरण

bounds जोड़ने पर और बातें

# Import random module
import random
# Set the min and max of bounds in the data plus some noise
bounds = (X_train.min(axis=0) - random.sample(range(0, 30), 12), 
          X_train.max(axis=0) + random.sample(range(0, 30), 12))


# epsilon 0.5 के साथ क्लासिफायर बनाएँ dp_clf = dp_GaussianNB(epsilon=0.5, bounds=bounds)
# मॉडल को डेटा पर फिट करें और स्कोर देखें dp_clf.fit(X_train, y_train) print("The accuracy of private classifier with bounds is ", dp_clf.score(X_test, y_test))
The accuracy of private classifier with bounds is 0.7544444444
Python में डेटा प्राइवेसी और अज्ञातिकरण

अलग-अलग epsilon मान

अलग-अलग epsilon मानों से accuracy की तुलना वाला प्लॉट

Python में डेटा प्राइवेसी और अज्ञातिकरण

आइए privacy-preserving मॉडल बनाएँ!

Python में डेटा प्राइवेसी और अज्ञातिकरण

Preparing Video For Download...