Python में डेटा प्राइवेसी और अज्ञातिकरण
Rebeca Gonzalez
Data engineer
हम probability distributions से sample लेकर datasets बना सकते हैं
जैसे normal distribution

प्रकृति में अक्सर मिलते हैं

import numpy as np# नया pandas DataFrame बनाएँ new_measures = pd.DataFrame()# sample के mean/center और standard deviation चुनें mean = 65 standard_deviation = 2# sample जनरेट करना new_measures['Height'] = np.random.normal(mean, standard_deviation, 10000)
# परिणामस्वरूप heights वितरण देखने के लिए हिस्टोग्राम बनाएं
new_measures['Height'].hist(bins=50)

Scikit-learn में datasets जनरेट करने के आसान फंक्शन हैं, जिनसे आप कर सकते हैं:
make_classification()make_blobs()# sklearn datasets मॉड्यूल से make_classification इम्पोर्ट करें from sklearn.datasets import make_classification# samples और उनके labels जनरेट करें x, y = make_classification(n_samples=1000,n_classes=2,n_informative=2,n_features=4,n_clusters_per_class=2,class_sep=1)
# जनरेटेड डेटा और लेबल्स देखें
print(x.shape)
print(y.shape)
print(x)
(1000, 4)
(1000,)
[[ 1.22914870e+00 -2.62386795e+00 2.25878743e+00 2.55377055e+00]
[-1.10279812e+00 -1.15816087e+00 1.55571279e+00 7.80565898e-02]
[ 2.65581977e-03 -2.33278818e+00 2.37837858e+00 1.57533194e+00]
...
[ 4.51006972e-01 7.53435745e-01 -9.21597108e-01 -2.20659747e-01]
[ 5.31925876e-01 7.42210504e-01 -9.37625248e-01 -1.61488855e-01]
[ 1.62862108e+00 -2.72435345e+00 2.22562940e+00 2.87628246e+00]]


# clustering datasets जनरेट करने के लिए datasets मॉड्यूल इम्पोर्ट करें from sklearn.datasets import make_blobs# standard deviation का मान तय करें standard_deviation = 1.5# डेटासेट के data और labels जनरेट करें x, labels = make_blobs(n_features=3, centers=4, cluster_std=standard_deviation)# जनरेटेड डेटा का shape देखें print(x.shape)
(100, 3)


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