<jupyter_start><jupyter_text>Stats<jupyter_code>lethality_rt = ((df.loc[273, cols[3]])/(df.loc[273, cols[1]]))*100
lethality_rt = round(lethality_rt,2)
lt_rt = str(lethality_rt)
print("The lethality rate is " + lt_rt + " %")
recovery_rt = ((df.loc[273, cols[2]])/(df.loc[273, cols[1]]))*100
recovery_rt = round(recovery_rt, 2) 
rc_rt = str(recovery_rt)
print("The recovery rate is " + rc_rt + " %")
df_stats = df[['confirmados','recuperados','obitos','suspeitos','ativos']]
standardizer=StandardScaler()
df_stats.head()
scaler=standardizer.fit(df_stats)
df_stats_Stand=scaler.transform(df_stats)<jupyter_output><empty_output><jupyter_text>HeatMap<jupyter_code>XfeaturesArray=zip(df2['confirmados'], df2['recuperados'], df2['obitos'], df2['suspeitos'], df2['ativos'])
Xfeatures=list(XfeaturesArray)
Y=df2['confirmados']
X=standardizer.fit_transform(Xfeatures)
df2 = pd.DataFrame(X, columns=['confirmados','recuperados', 'obitos', 'suspeitos', 'ativos'])
corrMatrix = df2.corr()
sn.heatmap(corrMatrix, annot=True)
plt.show()
print(cols,cols1)
confirmed = df.loc[:, cols[1]]
deaths = df.loc[:, cols[3]]
recoveries = df.loc[:, cols[2]]
cols1<jupyter_output><empty_output><jupyter_text>PieChart dos casos confirmados nos concelhos do Porto<jupyter_code>Z = df1.loc[121,cols1[1]:cols1[-1]]
casos_Porto = Z.sum()
casos_Porto
percent_list=[]
for row in Z:
#    s = print((row*100)/casos_Porto)
    percent_list.append((row*100)/casos_Porto)
print(percent_list)
percent_list = [3.2668486248162925, 4.996850724333403, 10.186857022884736, 14.730212051228218, 13.630065085030443, 7.306319546504304, 6.920008398068444, 1.31009867730422, 3.451606130589964, 5.677094268318287, 7.747218139827839, 4.333403317237035, 5.261389880327525, 2.859542305269788, 4.1066554692420745, 1.5032542515221499, 2.0365315977325213, 0.6760445097627545]

rounded_perc = [round(num, 1) for num in percent_list]
def pie_chart():
    plt.pie(percent_list, labels=['P<NAME>', 'V<NAME>', 'MATOSINHOS', 'PORTO',
       'VILA NOVA DE GAIA', 'GONDOMAR', 'MAIA', 'TROFA', 'SANTO TIRSO',
       'VALONGO', 'PAÇOS DE FERREIRA', 'PAREDES', 'LOUSADA', 'PENAFIEL',
       'FELGUEIRAS', 'AMARANTE', 'MARCO DE CANAVESES', 'BAIÃO'], autopct='%1.0f%%', pctdistance=1.1, labeldistance=1.2, radius=3.2)
pie_chart()<jupyter_output><empty_output><jupyter_text>Regressão Linear<jupyter_code>confirmed = df.loc[:, cols[1]]
deaths = df.loc[:, cols[3]]
confirmed.shape
deaths.shape
jh=np.array(df['ativos'])
hj =np.array(df['confirmados'])
Comparar confirmados com obitos
X = np.vstack((jh, hj)).T
jk = np.array(df['obitos'])
kj = np. array(df['recuperados'])
y = np.vstack((jk, kj)).T
X.ndim
y.ndim
lnr=LinearRegression()
lnr.fit(X,y)
lnr.intercept_
lnr.coef_
lnr.score(X, y)
X_Test=X.copy()
y_Test = y.copy()
test=LinearRegression()
test.fit(X,y)
test.intercept_
test_pred = test.predict(X_Test)
print('Coefficients: \n', test.coef_)
print('Mean squared error: %.2f'
      % mean_squared_error(y_Test, test_pred))
print('Coefficient of determination: %.2f'
      % r2_score(y_Test, test_pred))
plt.scatter(X_Test, y_Test,  color='black')
plt.plot(X_Test, y_Test, color='blue', linewidth=3)

plt.xticks(())
plt.yticks(())

plt.show()<jupyter_output><empty_output><jupyter_text>Clusters<jupyter_code>df3 = df[['recuperados','obitos']]
df3
df.dtypes
df1.loc[:,'PORTO']=pd.to_numeric(df1.loc[:,'PORTO'])
df1.loc[:,'VILA NOVA DE GAIA']=pd.to_numeric(df1.loc[:,'VILA NOVA DE GAIA'])
df1.dtypes
plt.scatter(df1['PORTO'], df1['VILA NOVA DE GAIA'])
plt.title('Cluster')
plt.xlabel(' ')
plt.ylabel(' ')
model1 = KMeans(n_clusters=3, init='k-means++', max_iter=10, n_init=5)
model1.fit_predict(df3)
plt.scatter(df1['PÓVOA DE VARZIM'],df1['VILA DO CONDE'])
plt.scatter(model1.cluster_centers_[:, 1], model1.cluster_centers_[:, 1], s=200, c='RED')
plt.show()
model1 = KMeans(n_clusters=10, init='k-means++', max_iter=10, n_init=1)
model1.fit_predict(df3)
plt.scatter(df1['PÓVOA DE VARZIM'],df1['VILA DO CONDE'])
plt.show()
%whos<jupyter_output>Variable               Type              Data/Info
--------------------------------------------------
KMeans                 type              <class 'sklearn.cluster._kmeans.KMeans'>
KNeighborsClassifier   ABCMeta           <class 'sklearn.neighbors<...>on.KNeighborsClassifier'>
LinearRegression       ABCMeta           <class 'sklearn.linear_mo<...>._base.LinearRegression'>
SimpleImputer          type              <class 'sklearn.impute._base.SimpleImputer'>
StandardScaler         type              <class 'sklearn.preproces<...>ng._data.StandardScaler'>
X                      ndarray           281x2: 562 elems, type `object`, 4496 bytes
Xfeatures              list              n=281
XfeaturesArray         zip               <zip object at 0x7fcccfeaf0c0>
Y                      Series            0           0\n1         <...>ength: 281, dtype: object
Z                      Series            PÓVOA DE VARZIM        77<...>nName: 121, dtype: object
casos_Porto            float             [...]
{'fraction_non_alphanumeric': 0.1742363344051447, 'fraction_numerical': 0.08540996784565916, 'mean_word_length': 4.433406113537118, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '448897', 'license': 'MIT', 'n_tokens_mistral': 2258, 'n_tokens_neox': 1993, 'n_words': 319, 'path': 'progression/Trabalho PCD.ipynb', 'repo_name': 'jorgealexandreb/Covid-19-ML-Project-', 'size': '4990'}