def question_5(data):
    ' Evaluating fitted model on different countries '
    data_israel = data[(data['Country'] == 'Israel')]
    poly_fit = PolynomialFitting(k=5)
    poly_fit.fit(data_israel['DayOfYear'], data_israel['Temp'])
    other_countries = ['Jordan', 'South Africa', 'The Netherlands']
    losses = np.array([])
    for country in other_countries:
        country_data = data[(data['Country'] == country)]
        loss = poly_fit.loss(country_data['DayOfYear'], country_data['Temp'])
        losses = np.append(losses, loss)
    fig = px.bar(x=np.array(other_countries), y=losses, width=700, height=700, labels={'x': 'Country', 'y': 'Losses (MSE)'}, title='Q5 Losses (MSE) per Country With k=5')
    fig.data[(- 1)].text = np.round(losses, 3)
    fig.update_traces(textposition='outside')
    fig.show()
Evaluating fitted model on different countries
def question_5(data):
    '  '
    data_israel = data[(data['Country'] == 'Israel')]
    poly_fit = PolynomialFitting(k=5)
    poly_fit.fit(data_israel['DayOfYear'], data_israel['Temp'])
    other_countries = ['Jordan', 'South Africa', 'The Netherlands']
    losses = np.array([])
    for country in other_countries:
        country_data = data[(data['Country'] == country)]
        loss = poly_fit.loss(country_data['DayOfYear'], country_data['Temp'])
        losses = np.append(losses, loss)
    fig = px.bar(x=np.array(other_countries), y=losses, width=700, height=700, labels={'x': 'Country', 'y': 'Losses (MSE)'}, title='Q5 Losses (MSE) per Country With k=5')
    fig.data[(- 1)].text = np.round(losses, 3)
    fig.update_traces(textposition='outside')
    fig.show()