Friends, on a single portal was deployed task :

Take the unemployment data for the city of Moscow: https://video.ittensive.com/python-advanced/data-9... Group the data by year if the year has fewer than 6 values, drop the years. Build a linear regression model on the years average relationship UnemployedDisabled to UnemployedTotal (percentage of people with disabilities) for a month and answer, what is the expected value in 2020 while maintaining current policy of the city of Moscow?

I solved it:

print(model.predict(np.array(2020).reshape(1,1)))

#print(data_group)

but the answer does not pass the verification :(((((

help to find what I missed!

Thank you!

Take the unemployment data for the city of Moscow: https://video.ittensive.com/python-advanced/data-9... Group the data by year if the year has fewer than 6 values, drop the years. Build a linear regression model on the years average relationship UnemployedDisabled to UnemployedTotal (percentage of people with disabilities) for a month and answer, what is the expected value in 2020 while maintaining current policy of the city of Moscow?

I solved it:

```
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
pd.options.display.max_rows = 1000
data = pd.read_csv("https://video.ittensive.com/python-advanced/data-9753-2019-07-25.utf.csv", delimiter = ";")
data = data.groupby("Year").filter(lambda x : x["UnemployedTotal"].count() < 6)
data["Year"] = data["Year"].astype("category")
data_group = data.groupby("Year").mean()
x = np.array(data_group.index).reshape(len(data_group.index),1)
y = np.array(data_group["UnemployedDisabled"]/data_group["UnemployedTotal"]*100).reshape(len(data_group.index),1)
model = LinearRegression()
model.fit(x, y)
plt.scatter(x,y , color ="orange")
x = np.append(x,[2020]).reshape(len(data_group.index)+1,1)
plt.plot(x, model.predict(x), color = "blue", linewidth = 3)
plt.show()
```

print(model.predict(np.array(2020).reshape(1,1)))

#print(data_group)

but the answer does not pass the verification :(((((

help to find what I missed!

Thank you!

asked April 19th 20 at 12:12

0 answer

Find more questions by tags Python