<jupyter_start><jupyter_text>From the information about data i know that it has . and () for depicting same country but different region<jupyter_code>print([x for x in world.Country if '.' in x or '(' in x])
world.iloc[8:16,:]
country_list=list(world["Country"].values)
count=0
for i in country_list:
  locat=0
  for j in i:
    if j=='.':
      i=i[:locat]
      country_list[count]=i
    elif j=='(':
      i=i[:locat-1] #remove the space also
      country_list[count]=i
    else:
      locat+=1
  count+=1

world['Country']=country_list
world=world.groupby("Country")['Cases'].sum().reset_index()
world.head()
print([x for x in world.Country if '.' in x or '(' in x])
world.iloc[8:9,:]
continent=pd.read_csv('https://raw.githubusercontent.com/AmiAnurag/Covid-19-Prediction-Using-Fbprophet/main/continents2%5B1%5D.csv')
continent.head()
continent.name=continent.name.str.upper()
continent.head()
plt.plot(world.Cases)<jupyter_output><empty_output><jupyter_text>**Now its all about making the data visualization more magnificient**  World wide spread of covid<jupyter_code>world['Case Range']=pd.cut(world['Cases'],[-150000,50000,200000,800000,1500000,150000000],labels=[0,50,200,800,1500])
world.head()
world['Case Range'].unique()
world.Cases.plot()
alpha=[]
for i in world.Country.str.upper().values:
  if i =='BRUNEI':
    i= 'BRUNEI DARUSSALAM'
  elif i=='US':
    i="UNITED STATES"
  if len(continent[continent['name']==i]['alpha-3'].values)==0:
    alpha.append(np.nan)
  else:
    alpha.append(continent[continent['name']==i]['alpha-3'].values[0])
world['Alpha3']=alpha


alpha=[]
for i in world.Country.str.upper().values:
  if i =='BRUNEI':
    i= 'BRUNEI DARUSSALAM'
  elif i=='US':
    i="UNITED STATES"
  if len(continent[continent['name']==i]['alpha-2'].values)==0:
    alpha.append(np.nan)
  else:
    alpha.append(continent[continent['name']==i]['alpha-2'].values[0])
world['Alpha2']=alpha


continent[continent['name']=='AFGHANISTAN'] #THIS IS THE ALPHA-3 VALUE IN THIRD COLUMN
world.columns
fig=px.choropleth(world.dropna(),locations="Alpha3",color="Case Range",projection='natural earth',hover_data=['Cases'],hover_name='Country')
fig.show()
df0.head() #confirm case<jupyter_output><empty_output><jupyter_text>Visualize the daily growing covid cases world wide<jupyter_code>case_count=[]
for i in range(1,len(df0)):
  case_count.append(sum(pd.to_numeric(df0.iloc[i,1:])))

case_data=pd.DataFrame({'Date':df0['Country/Region'][1:],'Covid Case Count':case_count})
case_data['Date']=pd.to_datetime(case_data['Date'])
case_data.set_index('Date',inplace=True)
case_data.head()
case_data['Covid Case Count'].plot(title='Daily covid 19 cases',figsize=(20,10),label="daily cases")
case_data['Covid Case Count'].rolling(window=30).mean().plot(label="Moving Average, window of 1 month")
plt.ylabel("CASES")
plt.legend()
plt.show()
case_data['Covid Case Count'].rolling(window=5).mean().head()<jupyter_output><empty_output><jupyter_text>Prediction of the covid cases for next 250 days using FBprophet<jupyter_code>case_data.isnull().sum()
dir(Prophet)
model=Prophet(weekly_seasonality=False)
case_data.head(3)
case_data['ds']=case_data.index
case_data['y']=case_data['Covid Case Count']
case_data.head()
model_data=case_data.iloc[:,1:]
model_data.reset_index(inplace=True)
model_data.drop(columns=['Date'],inplace=True)
model_data.head()
model.fit(model_data)
future_dates=model.make_future_dataframe(periods=250)
prediction=model.predict(future_dates)
prediction.tail()
model_data.tail()
prediction.tail(10)
plt.plot(prediction.ds,prediction.yhat)
plt.plot(model_data.ds,model_data.y)
plt.show()
model.plot(prediction)
model.plot_components(prediction)<jupyter_output><empty_output><jupyter_text>Cross validation<jupyter_code>model_data.shape
from fbprophet.diagnostics import cross_validation
df_cv=cross_validation(model,initial="364 days",period='50 day',horizon="50 days")
df_cv.head()<jupyter_output>INFO:fbprophet:Making 4 forecasts with cutoffs between 2021-01-21 00:00:00 and 2021-06-20 00:00:00<jupyter_text>The initial model will be trained on the first 1,825 days of data. It will forecast the next 60 days of data (because horizon is set to 60). The model will then train on the initial period + the period (1,825 + 30 days in this case) and forecast the next 60 days. It will continued like this, adding another 30 days to the training data and then forecasting for the next 60 until there is no longer enough data to do this.In summary, period is how much data to add to the training data set in every iteration of cross-validation, and horizon is how far out it will forecast.<jupyter_code>df_cv.tail()
df_cv.shape
from fbprophet.diagnostics import performance_metrics
df_p=performance_metrics(df_cv)
df_p.head()
df_p.tail()
from fbprophet.plot import plot_cross_validation_metric
fig=plot_cross_validation_metric(df_cv,metric='mse')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14972386991204745, 'fraction_numerical': 0.03334015136019636, 'mean_word_length': 7.029556650246305, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '355662', 'license': 'MIT', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1730, 'n_words': 365, 'path': 'covid_cases_prediction.ipynb', 'repo_name': 'AmiAnurag/Covid-19-Prediction-Using-Fbprophet', 'size': '4889'}