Question
Use Jupyter notebook to solve this code: Source: # Load the data and libraries import pandas as pd import numpy as np from
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
In [1]: # 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) pd.read_csv('https://github.com/jnear/cs211-data-privacy/raw/master/homework/adult_with_pii.csv') adult = adult - adult.dropna ()
Step by Step Solution
3.52 Rating (155 Votes )
There are 3 Steps involved in it
Step: 1
Certainly Heres a Jupyter Notebook code to answer the query how many participants have never been ma...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started