Skip to content

Commit

Permalink
forecast narrative finalized
Browse files Browse the repository at this point in the history
  • Loading branch information
denisabd committed May 8, 2023
1 parent 781322f commit bf86794
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 67 deletions.
8 changes: 5 additions & 3 deletions R/narrate_forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,23 +293,25 @@ narrate_forecast <- function(

trend_narrative <- trend_df %>%
narrator::narrate_trend(
type = "yoy",
type = type,
coverage = coverage,
coverage_limit = coverage_limit,
narration_depth = narration_depth
)

variables_trend <- trend_df %>%
narrator::narrate_trend(
type = "yoy",
type = type,
coverage = coverage,
coverage_limit = coverage_limit,
narration_depth = narration_depth,
return_data = TRUE
)

narrative <- append(narrative, trend_narrative)
variables <- append(variables, variables_trend)
variables <- append(variables, variables_trend[names(variables_trend) != "narrative"])

variables <- append(variables, list(narrative = narrative), 0)

# ChatGPT -----------------------------------------------------------------
if (use_chatgpt) {
Expand Down
79 changes: 26 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,17 @@ narrative_enhanced <- enhance_narrative(narrative_one)
cat(narrative_enhanced)
```

The company’s Total Sales across all Regions has reached an impressive
38790478.4, showcasing its strong market presence. Among the Outlying
Regions, North America (NA) dominates with a total sales value of
18079736.4, accounting for 46.6% of total sales. Additionally, the
Europe, Middle East, and Africa (EMEA) region follows, with a sales
value of 13555412.7, contributing to 34.9% of total sales.

Analyzing the sales data further indicates that in North America,
notable product categories by sales are Food & Beverage, generating a
substantial sales value of 7392821 and accounting for 40.9% of total
sales. Electronics, with sales value of 3789132.7, is also a significant
product category, contributing 21% to total sales. Similarly, in the
EMEA region, Food & Beverage is the top product category, responsible
for generating a sales value of 5265113.2, contributing to 38.8% of
total sales. Electronics come in second, with a sales value of
3182803.4, accounting for 23.5% of sales in the EMEA region.

Overall, when considering outlying products by sales for all regions,
Food & Beverage category remains dominant. It has registered a sales
value of 15543469.7, contributing to 40.1% of total sales. Electronics
come in second among outlying products with a sales value of 8608962.8,
representing 22.2% of total outlying sales.
The aggregate Total Sales figure for all Regions amounts to an
impressive 38790478.4. Notably, Outlying Regions such as North America
(18079736.4, 46.6 %) and EMEA (13555412.7, 34.9 %) have proven to be
significant contributors to this success. Upon closer examination, it is
revealed that within NA, Food & Beverage (7392821, 40.9 %) and
Electronics (3789132.7, 21 %) are the leading products by sales.
Similarly, in EMEA, Food & Beverage (5265113.2, 38.8 %) and Electronics
(3182803.4, 23.5 %) reign supreme in terms of revenue generation. It is
also noteworthy that Food & Beverage (15543469.7, 40.1 %) and
Electronics (8608962.8, 22.2 %) have emerged as the Outlying Products by
Sales in these regions.

### Translation

Expand All @@ -168,30 +157,16 @@ translation <- translate_narrative(narrative_enhanced, language = "Czech")
cat(translation)
```

Celkový objem prodeje společnosti přes všechny regiony dosáhl
impresivního čísla 38790478,4, což ukazuje na její silnou pozici na
trhu. Mezi vzdálenými regiony tvoří Severní Amerika (NA) dominantní
tržbu s celkovou hodnotou prodeje 18079736,4, což odpovídá 46,6%
celkového objemu prodeje. Dále následuje oblast Evropy, Středního
východu a Afriky (EMEA) s hodnotou prodeje 13555412,7, přispívající k
34,9% z celkového prodeje.

Podrobnější analýza prodejních dat ukazuje, že v Severní Americe jsou
významné kategorie produktů podle prodeje potraviny a nápoje, generující
obrovskou tržbu 7392821, což odpovídá 40,9% celkového prodeje.
Elektronika s prodejem ve výši 3789132,7 je také významnou kategorií
produktů, přispívající k 21% celkového prodeje. Obdobně v oblasti EMEA
jsou potraviny a nápoje nejvýznamnější kategorií produktů a jsou
zodpovědné za generování prodeje v hodnotě 5265113,2 což představuje
38,8% z celkového prodeje. Elektronika se umisťuje na druhé pozici s
prodejem ve výši 3182803,4, což odpovídá 23,5% prodeje v oblasti EMEA.

Celkově, pokud se budou posuzovat vzdálené produkty podle prodeje ve
všech oblastech, kategorie potravin a nápojů zůstává dominantní.
Zaregistrovala prodej v hodnotě 15543469,7, přispívající 40,1% k
celkovému prodeji. Elektronika se umisťuje na druhém místě mezi
vzdálenými produkty s prodejem ve výši 8608962,8, což odpovídá 22,2%
celkového prodeje.
Celkové prodeje všech regionů dosáhly působivé částky 38 790 478,4. Na
významu v rámci tohoto úspěchu se značně podílely vzdálené oblasti, jako
Severní Amerika (18 079 736,4, 46,6 %) a EMEA (13 555 412,7, 34,9 %). Po
bližším zkoumání se ukázalo, že v Severní Americe jsou vedoucími
produkty podle prodejů potraviny a nápoje (7 392 821, 40,9 %) a
elektronika (3 789 132,7, 21 %). Obdobně v EMEA jsou potraviny a nápoje
(5 265 113,2, 38,8 %) a elektronika (3 182 803,4, 23,5 %) panujícími
produkty v termínech výnosů. Je také důležité podotknout, že potraviny a
nápoje (15 543 469,7, 40,1 %) a elektronika (8 608 962,8, 22,2 %) se
staly důležitými produkty díky prodejům i v těchto vzdálených oblastech.

### Summarization

Expand All @@ -203,13 +178,11 @@ summarization <- summarize_narrative(narrative_enhanced)
cat(summarization)
```

Company’s total sales reach 38790478.4. North America leads with 46.6%
of total sales, followed by EMEA with 34.9%. Notable product categories
in NA are Food & Beverage and Electronics, generating 40.9% and 21% of
sales, respectively. In EMEA, Food & Beverage and Electronics account
for 38.8% and 23.5% of sales, respectively. Food & Beverage is the
dominant category across all regions, generating 40.1% of total outlying
sales. Electronics follow with 22.2%.
Total sales of 38790478.4 were achieved, with significant contributions
from Outlying Regions such as North America (46.6%) and EMEA (34.9%).
Food & Beverage and Electronics were the leading products by sales
within NA and EMEA. Food & Beverage and Electronics were also the
outlying products by sales in these regions.

# Python

Expand Down
10 changes: 3 additions & 7 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ articles:
formatting: formatting.html
templates: templates.html
trend: trend.html
last_built: 2023-05-07T19:43Z
last_built: 2023-05-08T07:36Z
urls:
reference: https://denisabd.github.io/narrator/reference
article: https://denisabd.github.io/narrator/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions tests/testthat/test-narrate_forecast.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that("narrate_forecast() works", {
fit_prophet <- function(data) {
model <- prophet::prophet(data)
model <- suppressMessages(prophet::prophet(data))
future <- prophet::make_future_dataframe(model, periods = 12, freq = "month")
forecast <- predict(model, future)
return(forecast)
Expand All @@ -22,7 +22,8 @@ test_that("narrate_forecast() works", {
dplyr::select(-data) %>%
tidyr::unnest(forecast) %>%
dplyr::select(ds, yhat) %>%
dplyr::left_join(actuals)
dplyr::left_join(actuals) %>%
suppressMessages()

expect_no_error(narrate_forecast(df, actuals = "y", forecast = "yhat"))
expect_no_error(narrate_forecast(df, actuals = "y", forecast = "yhat"))
Expand Down

0 comments on commit bf86794

Please sign in to comment.