How to solve the problem?

Friends, on a single portal was deployed task :

Take the unemployment data for the city of Moscow: 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("", 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(), 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)



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

help to find what I missed!

Thank you!
April 19th 20 at 12:12
0 answer

Find more questions by tags Python