Use Jupyter notebook to solve this code: Source: # Load the data and libraries import
Question:
Use Jupyter notebook to solve this code:
Source:
# Load the data and libraries
import pandas as pd
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
from unittest.mock import patch
def laplace_mech(v, sensitivity, epsilon):
return v + np.random.laplace(loc=0, scale=sensitivity / epsilon)
adult = pd.read_csv('https://github.com/jnear/cs211-data-privacy/raw/master/homework/adult_with_pii.csv')
adult = adult.dropna()
Question:
Write code to answer the query: "how many participants have never been married?"
Hint: filter the adult_data data frame to contain only participants who were never married, then return the len of the filtered data frame.
def query1():
# YOUR CODE HERE
raise NotImplementedError()
query1()
# TEST CASE for question 1
assert query1() == 9726
Type Markdown and LaTeX: ????2