This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
max_discount = 50 | |
discount = 20 | |
assert discount <= max_discount | |
def get_final_score(score,bonus,max_score): | |
if bonus: | |
score += 10 | |
if score > max_score: | |
return max_score | |
return score |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
word = "renaissance" | |
for letter in word: | |
if letter not in letter_count: | |
letter_count[letter] = 0 | |
letter_count[letter] += 1 | |
print(letter_count) | |
# {'r': 1, 'e': 2, 'n': 2, 'a': 2, 'i': 1, 's': 2, 'c': 1} | |
from collections import Counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redact_dataset = original_dataset.copy() | |
redact_dataset = redact_dataset[1:] | |
# this dataset does not contain | |
# Osbourne Gillions ogillions0@feedburner.com 31.94 Florida |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
combined_df_temp = [df1, df2, df3, df4, df5] | |
original_dataset = pd.concat(combined_df_temp) | |
print(original_dataset.shape) | |
# Output | |
# (5000, 6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url5 = 'https://raw.githubusercontent.com/OpenMined/PyDP/dev/examples/Tutorial_4-Launch_demo/data/05.csv' | |
df5 = pd.read_csv(url5,sep=",", engine = "python") | |
print(df5.head()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url4 = 'https://raw.githubusercontent.com/OpenMined/PyDP/dev/examples/Tutorial_4-Launch_demo/data/04.csv' | |
df4 = pd.read_csv(url4,sep=",", engine = "python") | |
print(df4.head()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url3 ='https://raw.githubusercontent.com/OpenMined/PyDP/dev/examples/Tutorial_4-Launch_demo/data/03.csv' | |
df3 = pd.read_csv(url3,sep=",", engine = "python") | |
print(df3.head()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url2 = 'https://raw.githubusercontent.com/OpenMined/PyDP/dev/examples/Tutorial_4-Launch_demo/data/02.csv' | |
df2 = pd.read_csv(url2,sep=",", engine = "python") | |
print(df2.head()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url1 = 'https://raw.githubusercontent.com/OpenMined/PyDP/dev/examples/Tutorial_4-Launch_demo/data/01.csv' | |
df1 = pd.read_csv(url1,sep=",", engine = "python") | |
print(df1.head()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pydp as dp # by convention our package is to be imported as dp (for Differential Privacy!) | |
from pydp.algorithms.laplacian import BoundedSum, BoundedMean, Count, Max | |
import pandas as pd | |
import statistics # for calculating mean without applying differential privacy | |
import numpy as np | |
import matplotlib.pyplot as plt |
NewerOlder