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 flask import Flask | |
from flask_restful import Api, Resource, reqparse | |
from sklearn.externals import joblib | |
import numpy as np | |
# Faz a carga do name space do Flask para isntanciar | |
# o endpoint | |
APP = Flask(__name__) | |
# Instancia o endpoint propriamente dito |
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 | |
from sklearn.model_selection import train_test_split | |
from sklearn.feature_extraction.text import CountVectorizer | |
from sklearn.naive_bayes import MultinomialNB | |
# Carga do conjunto de dados | |
df = \ | |
pd.read_csv("https://raw.githubusercontent.com/fclesio/metalbr/master/rebirth-remains.csv", | |
index_col=False) |
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
## Ref: https://stackoverflow.com/questions/44785585/how-to-delete-all-docker-local-docker-images | |
docker container prune -f && | |
docker stop $(docker ps -aq) && | |
docker rm -vf $(docker ps -a -q) && | |
docker rmi -f $(docker images -a -q) |
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 tensorflow as tf | |
from tensorflow import keras | |
from tensorflow.keras import layers | |
from keras.layers import Dropout | |
# Arch #1: 3 Layers | |
model_arch_1 = keras.Sequential( | |
[ | |
layers.Dense(2, activation="relu", name="layer1"), | |
layers.Dense(3, activation="relu", name="layer2"), |
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 sqlite3 | |
import pandas as pd | |
conn = sqlite3.connect('prod.db') | |
c = conn.cursor() | |
query_create_table = ''' | |
CREATE TABLE IF NOT EXISTS toplines( | |
source_id TEXT, | |
source_name TEXT, |
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 requests | |
import json | |
import pandas as pd | |
URL = "http://newsapi.org/v2/everything?q=bitcoin&from=2020-04-18&sortBy=publishedAt&apiKey=1816423a00634e51839b61f8cfc624cf" | |
parsed = requests.get(URL).json() | |
print(f"type: {type(parsed)}") |
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
# Source: https://stackoverflow.com/questions/44862712/td-idf-find-cosine-similarity-between-new-document-and-dataset/44863365#44863365 | |
import pandas as pd | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.metrics.pairwise import cosine_similarity | |
# Generate DF | |
df = \ | |
pd.DataFrame({'jobId' : [1, 2, 3, 4, 5], | |
'serviceId' : [99, 88, 77, 66, 55], | |
'text' : ['Ich hätte gerne ein Bild an meiner Wand.', |
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 | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
# Generate DF | |
df = \ | |
pd.DataFrame({'jobId' : [1,2,3,4,5], | |
'serviceId' : [99,88,77,66, 55], | |
'text' : ['Ich hätte gerne ein Bild an meiner Wand.', | |
'Ich will ein Bild auf meinem Auto.', | |
'Ich brauche ein Bild auf meinem Auto.', |
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
curl -X POST "http://127.0.0.1:8000/prediction?PAY_AMT6=1000&PAY_AMT5=2000&PAY_AMT4=300&PAY_AMT3=200&PAY_AMT2=450&PAY_AMT1=10000&BILL_AMT6=300&BILL_AMT5=23000&BILL_AMT4=24000&BILL_AMT3=1000&BILL_AMT2=1000&BILL_AMT1=1000&PAY_6=200&PAY_5=200&PAY_4=200&PAY_3=200&PAY_2=200&PAY_0=2000&AGE=35&MARRIAGE=1&EDUCATION=1&SEX=1&LIMIT_BAL=1000000" -H "accept: application/json" |