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 matplotlib.pyplot as plt | |
import pandas as pd | |
import mplleaflet as mll | |
covid_info = pd.read_csv('covid19_df.csv') | |
covid_info.drop(['date', 'estimated_population_2019', 'confirmed_per_100k_inhabitants', 'death_rate'], | |
axis=1, inplace=True) | |
covid_info = covid_info[covid_info.is_last == True] | |
covid_info.rename(columns={'city_ibge_code': 'codigo_ibge'}, inplace=True) |
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
covid_info = pd.read_csv('covid19_df.csv') | |
covid_info.drop(['date', 'estimated_population_2019', 'confirmed_per_100k_inhabitants', 'death_rate'], | |
axis=1, inplace=True) | |
covid_info = covid_info[covid_info.is_last == True] | |
covid_info.rename(columns={'city_ibge_code': 'codigo_ibge'}, inplace=True) | |
cities_info = pd.read_csv('municipios.csv') | |
cities_info.drop(['nome', 'codigo_uf', 'capital'], | |
axis=1, inplace=True) |
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 matplotlib.pyplot as plt | |
import pandas as pd | |
import mplleaflet as mll |
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
merged_df = pd.merge(left=covid_info, right=cities_info, left_on='codigo_ibge', right_on='codigo_ibge') | |
merged_df = merged_df[merged_df.place_type == 'city'] |
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
# Imports | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import seaborn as sns | |
# sklearn imports | |
from sklearn.datasets import load_iris | |
from sklearn.model_selection import train_test_split | |
from sklearn.linear_model import LinearRegression |
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
iris_dataset = load_iris() | |
iris = pd.DataFrame(iris_dataset.data, columns=iris_dataset.feature_names) | |
iris['target'] = iris_dataset.target |
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
x = pd.DataFrame(iris_dataset.data, columns=iris_dataset.feature_names) | |
y = pd.DataFrame(iris_dataset.target, columns=['target']) | |
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=5) | |
model = LinearRegression() | |
model.fit(x_train, y_train) |
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
train_predict = model.predict(x_train) | |
rmse = np.sqrt(mean_squared_error(y_train, train_predict)) | |
r2 = r2_score(y_train, train_predict) | |
print('Conjunto de treino') | |
print(rmse) | |
print(r2) | |
np.round(train_predict, 0, train_predict) | |
scatter = plt.scatter(x_train['sepal length (cm)'], x_train['sepal width (cm)'], | |
c=train_predict, cmap=plt.cm.Set1, |
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
# Imports | |
from flask import Flask, request | |
from . import image | |
# Flask app | |
app = Flask(__name__) | |
@app.route('/image-handler', methods=['POST']) | |
def handler(): | |
return image.image_handler(image, methods) |
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 cv2 # openCV | |
import numpy as np | |
def image_resize(image, width = None, height = None): | |
img = cv2.imread(image) | |
dim = None | |
(h, w) = image.shape[:2] | |
if width is None: | |
r = height / float(h) | |
dim = (int(w * r), height) |
OlderNewer