This file contains hidden or 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 os | |
from flask import Flask, redirect, render_template, request, url_for | |
from werkzeug.utils import secure_filename | |
DATA_FOLDER_PATH = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'static') | |
ALLOWED_EXTENSIONS = set(['.png', '.jpg', '.jpeg']) | |
IMG_MAX_SIZE = 16 * 1024 * 1024 | |
app = Flask(__name__) |
This file contains hidden or 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 numpy as np | |
import keras.preprocessing.image as image_utils | |
from keras.applications.imagenet_utils import decode_predictions, preprocess_input | |
# You can import any other model if you would like to :) | |
from keras.applications.resnet50 import ResNet50 | |
IMG_SIZE = (224, 224) | |
# Loading the model only once | |
CLASSIFICATION_MODEL = ResNet50() |
This file contains hidden or 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
SELECT t1.datname AS db_name, | |
Pg_size_pretty(Pg_database_size(t1.datname)) AS db_size | |
FROM pg_database t1 | |
ORDER BY Pg_database_size(t1.datname) DESC |
This file contains hidden or 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
# This function could be made generic to almost any loaded CSV file with | |
# pandas. Can you see how to do it? | |
import pandas as pd | |
# Some constants | |
PARQUET_ENGINE = "pyarrow" | |
DATE_COL = "purchase_date" | |
CATEGORICAL_COLS = ["card_id", "category_3", "merchant_id", "month_lag", | |
"installments", "state_id", "subsector_id", |
This file contains hidden or 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
# To get the segmentation_models library, run: | |
# pip install segmentation-models | |
from segmentation_models import Unet | |
def build_pretrained_unet_model(): | |
"""Build a pre-trained Unet model. """ | |
return Unet(backbone_name='resnet34', encoder_weights='imagenet') |
This file contains hidden or 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
# Extracted from this blog post: https://tech.marksblogg.com/install-and-configure-apache-airflow.html. | |
import airflow | |
from airflow import models, settings | |
from airflow.contrib.auth.backends.password_auth import PasswordUser | |
user = PasswordUser(models.User()) | |
user.username = 'username' | |
user.email = '[email protected]' |
This file contains hidden or 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
from hyperopt import tpe, fmin, Trials | |
from hyperopt.hp import normal | |
from hyperopt.plotting import main_plot_history, main_plot_histogram | |
import pandas as pd | |
import matplotlib.pylab as plt | |
def rosenbrock(suggestion): | |
""" | |
A test function to minimize using hyperopt. The |
This file contains hidden or 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 pandas as pd | |
import matplotlib.pylab as plt | |
import seaborn as sns | |
# In the clipboard | |
# piece,price | |
# gpu,869 | |
# ssd,140 | |
# power,113 |
This file contains hidden or 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 geopandas as gpd | |
import requests | |
def get_data_from_url(url): | |
data = requets.get(url).json() | |
return gpd.GeoDataFrame.from_features(data) |
This file contains hidden or 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 pandas as pd | |
INPUT_PATH = "your/input/path.csv" | |
OUPUT_PATH = "your/output/path_{}.csv" | |
df = pd.read_csv(INPUT_PATH, parse_dates=['tms_gmt']) | |
df['year'] = df.tms_gmt.dt.year | |
for year in df['year'].unique(): |