Вопрос пользователя:
Ответ нейросети:
import matplotlib.pyplot as plt years = [1998, 1999, 2000, 2001] quarters = [1, 2, 3, 4] sales = [ [247.1, 265.8, 271.0, 281.3], [284.2, 307.6, 301.6, 309.8], [311.5, 338.6, 331.7, 346.2], [340.2, 377.5, 376.9, 401.8] ] plt.figure(figsize=(10, 6)) for i in range(4): plt.plot(years, sales[i], label='Quarter ' + str(i+1)) plt.xlabel('Year') plt.ylabel('Sales (thousands of dollars)') plt.title('Sales of the company by quarter') plt.legend() plt.grid(True) plt.show()
import numpy as np from statsmodels.tsa.seasonal import seasonal_decompose data = np.array(sales).flatten() result = seasonal_decompose(data, model='multiplicative', period=4) trend = result.trend seasonal = result.seasonal residual = result.resid plt.figure(figsize=(10, 6)) plt.subplot(411) plt.plot(data, label='Original') plt.legend(loc='upper left') plt.subplot(412) plt.plot(trend, label='Trend') plt.legend(loc='upper left') plt.subplot(413) plt.plot(seasonal, label='Seasonality') plt.legend(loc='upper left') plt.subplot(414) plt.plot(residual, label='Residuals') plt.legend(loc='upper left') plt.tight_layout() plt.show()
from sklearn.metrics import mean_absolute_error, mean_squared_error mae = mean_absolute_error(data, trend*seasonal*residual) mse = mean_squared_error(data, trend*seasonal*residual) print("Mean Absolute Error:", mae) print("Mean Squared Error:", mse)
forecast = trend[-1]*seasonal[-1]*residual[-1] print("Forecast for 1st quarter of 2002:", forecast) print("Forecast for 2nd quarter of 2002:", forecast)
Напишите нам, если в вопросе есть ваши персональные данные ([email protected])
Обратите внимание: ответы, предоставляемые искусственным интеллектом, могут не всегда быть точными. Не рассчитывайте на них в критически важных областях, таких как медицина, юриспруденция, финансы или в вопросах, связанных с безопасностью. Для важных решений всегда обращайтесь к квалифицированным специалистам. Администрация сайта не несет ответственности за контент, сгенерированный автоматически.