Skip to content

Instantly share code, notes, and snippets.

@M3nin0
Created June 15, 2020 15:50
Show Gist options
  • Save M3nin0/e18f3575674d40e5976be74ca27b1ca7 to your computer and use it in GitHub Desktop.
Save M3nin0/e18f3575674d40e5976be74ca27b1ca7 to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
from sklearn import linear_model
import matplotlib.pyplot as plt
# Carregando os dados
data_owd = pd.read_csv('https://covid.ourworldindata.org/data/owid-covid-data.csv')
# Filtrando os dados (Canadá)
can = data_owd[data_owd.iso_code == 'CAN']
can = can[can.new_cases > 50]
can = can[~np.isnan(can.new_tests)]
# Ajustando a curva
x = can.new_tests.values.reshape(-1, 1)
y = can.new_cases.values.reshape(-1, 1)
regr = linear_model.LinearRegression()
regr.fit(x, y)
y_pred = regr.predict(x)
plt.figure(dpi = 150)
plt.scatter(x, y)
plt.plot(x, y_pred, color='red')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment