python3 -m venv v-env
source v-env/bin/active
# first download the repository | |
#$ mkdir deployment_manager | |
#$ cd deployment_manager | |
#$ gsutil cp gs://spls/gsp302/* . | |
# change qwiklabs.jinja to this file | |
resources: | |
- name: default-allow-http | |
type: compute.v1.firewall | |
properties: |
# 1. open cloud shell | |
# 2. download the the resource lab named resources-echo-web.tar.gz | |
# 3. upload it in the cloud shell | |
# 4. extract the file | |
tar -xvzf resources-echo-web.tar.gz | |
# 5. build the image as v1 tag | |
docker build -t gcr.io/<PROJECT_ID>/echo-app:v1 . | |
# 6. check if the image was Built |
from mlxtend.frequent_patterns import apriori | |
class Apriori: | |
"""Apriori Class. Its has Apriori steps.""" | |
threshold = 0.5 | |
df = None | |
def __init__(self, df, threshold=None, transform_bol=False): | |
"""Apriori Constructor. |
# Running Apriori | |
if 'ID' in df.columns: del df['ID'] # ID is not relevant to apriori | |
apriori_runner = Apriori(df, threshold=0.4, transform_bol=True) | |
apriori_df = apriori_runner.run(use_colnames=True) | |
print(apriori_df) | |
#output | |
# support itemsets length |
import pandas as pd | |
# create sample dataset | |
columns = ['ID', 'Beer', 'Diaper', 'Gum', 'Soda', 'Snack'] | |
dataset = [[1, 1, 1, 1, 1, 0], | |
[2, 1, 1, 0, 0, 0], | |
[3, 1, 1, 1, 0, 1], | |
[4, 1, 1, 0, 1, 1], | |
[5, 0, 1, 0, 1, 0], |
"""Playing with primes.""" | |
def get_square_root(n): | |
"""Return square root of n.""" | |
return n ** (1.0 / 2) | |
def is_divisor(n, d): | |
"""Return True if n divides d, False otherwise.""" |
"""author: `Bernardo Costa <bernardoantunescosta at gmail.com>`""" | |
import random | |
class MontyHall: | |
"""Monty Hall Simulator Class.""" | |
def __init__(self): | |
self.doors = list('123') | |
self.reward_door = None |
acumulator = [0, 0] | |
for _ in range(10**6): | |
mh = MontyHall() | |
mh.set_random_guess() | |
mh.open_goat_door() | |
mh.switch_door() # comment to don't swich | |
result = mh.validade_guess_door() | |
if result: acumulator[0] += 1 |