How To Forecast Gross Profit With GoodData and AWS SageMaker

Written by Jan Pansky  | 

Share
How To Forecast Gross Profit With GoodData and AWS SageMaker

In the ever-evolving landscape of data analytics, staying ahead of the competition requires innovation and adaptability. At GoodData, we have embraced this need for change by adopting an API-first approach and pursuing an "analytics as code" philosophy, setting the stage for transformative use cases. In this article, we'll explore how we've harnessed the combined power of machine learning, AWS SageMaker, and our React SDK to forecast gross profits, a crucial metric in the business world.

Modern Data Stack

Recognizing the Importance of Sales Metrics

Sales metrics are a cornerstone of business operations, offering crucial insights into financial well-being and profitability. These metrics encompass various aspects of revenue generation and are invaluable for decision-makers in guiding financial planning, strategy, and overall success. At GoodData, we've simplified the calculation of these metrics, including gross profit, by integrating them into the semantic layer of our analytics platform, eliminating the need for separate SQL queries. This streamlining ensures real-time access to essential sales data, making it imperative for business leaders to closely monitor these metrics for a comprehensive understanding of their organization's performance.

The Challenge: Predicting Future Gross Profit

Our primary challenge centered on forecasting gross profit for upcoming periods, a pivotal element in managing financial health and profitability. To address this challenge effectively, we turned to AWS Sage, a machine-learning model designed for predictive analytics.

AWS Sage is a powerful platform that specializes in constructing and deploying machine learning models. It leverages advanced techniques, including neural networks, to provide highly accurate predictions based on historical data. We then harnessed the capabilities of AWS Sage to train a specialized model for forecasting future gross profits.

The Solution: A Collaborative Endeavor

After coming together as a team and brainstorming a solution, we identified the following template of steps:

Data Collection and Preprocessing

It all begins with gathering and refining data, a crucial step in providing our model with a strong foundation for analysis. During this phase, we collect and prepare data, ensuring it covers all the essential details needed for the model's analysis. We clean and organize the data to create a high-quality dataset that the model can use for accurate predictions and valuable insights. This step is essential for data-driven decision-making and strategy optimization.

Model Selection and Training

In the SageMaker environment, we have access to a variety of algorithms and tools that allow us to experiment with different models, simplifying the process of training the model with large datasets. During this phase, we evaluate the model's performance based on historical data. The model's predictions for future timeframes are stored in an AWS S3 bucket for easy integration into the GoodData analytics platform.

The following Python code demonstrates how to set up the SageMaker model for training and configure the essential parameters. You can find the full code in the article's accompanying resources. Keep in mind that these settings are specific to the dataset in question and can be adjusted for different data.

\`\``python
\# Set up a SageMaker model for training
estimator = sagemaker.estimator.Estimator(
    image_uri=train_model_entry.image_name, 
    sagemaker_session=train_model_entry.sagemaker_session,
    role=role,
    instance_count=1,
    instance_type="ml.c4.2xlarge",
    base_job_name="gooddata-demo",
    output_path=train_model_entry.s3_output_path,
)
\# Define model training parameters
hyperparameters = {
    "time_freq": train_model_entry.freq,
    "epochs": 400,
    "early_stopping_patience": 40,
    "mini_batch_size": 64,
    "learning_rate": 5E-4,
    "context_length": train_model_entry.context_length,
    "prediction_length": train_model_entry.prediction_length,
}
\# Begin the model training process with these settings
\# ...
\`\``

The model training process involves feeding the prepared dataset into the chosen model and iteratively updating the model's parameters to improve prediction accuracy. Once trained, the model is ready to forecast gross profit.

Model Evaluation and Deployment

After training, it's vital to assess the model's performance. We use various metrics and validation techniques to evaluate how well the model makes forecasts. The model's predictions are then integrated into GoodData's Dashboard Plugin, allowing users to access and visualize the forecasts within their analytical platform, making it easier for decision-makers to utilize the model's insights.

Model deployment typically involves making it available as a web service or API for real-time use by other applications and systems, with SageMaker providing deployment features. It's important to remember that model deployment should include monitoring and maintenance to ensure long-term performance.

GoodData Dashboard Plugin

To make these forecasts accessible and actionable, GoodData has developed a user-friendly dashboard plugin using the React SDK. This plugin smoothly integrates with GoodData Dashboards, allowing for an effortless combination of predicted results with historical data. In essence, it enhances the original historical data by infusing it with valuable forecasted insights.

If you're interested in creating your own dashboard plugin within GoodData Cloud, follow these steps and refer to the Plugin Development Toolkit for more information.

  1. Set up hosting for your plugins.
  2. Update the Content Security Policy of your GoodData Cloud instance's gateway to enable the loading of plugins from the hosting location.
  3. We recommend getting started with our Plugin Development Toolkit, which includes a CLI tool that simplifies the process of creating a new plugin.

This approach ensures that forecasted insights can seamlessly integrate into your dashboard, making data-driven decisions and business strategy optimization more accessible and practical.

Realizing the Potential: Using the Forecasted Gross Profits

With the machine learning output integrated into the GoodData platform, the solution was equipped with a powerful tool to make data-driven decisions and plan for the future. The forecasted gross profits transformed into a crucial component of the client's financial strategy, driving well-informed decisions and optimizing profitability.

Gross profit graph gooddata

Forecasted gross profits played a crucial role in strategic planning, enabling the client to make well-informed decisions regarding resource allocation, investments, and expansion. This data-driven approach also facilitated ongoing profitability optimization by identifying revenue growth and cost reduction opportunities, ultimately leading to refined pricing strategies and improved overall profitability. Most significantly, the integration of machine learning and GoodData shifted the client towards data-driven decision-making, replacing intuition with accurate predictions. This transformation enhanced the client's competitiveness in their industry, allowing them to adapt quickly to market changes, meet customer demands precisely, and outperform competitors who were still dependent on traditional analytics.

The Road Ahead

While the initial steps have been promising, we have more ambitious plans for the future. The next phase involves creating an automated data pipeline to streamline the retraining of the machine learning model, ensuring that the forecasts are always up-to-date and readily available for reports and visualizations within GoodData.

Leverage Analytics and Machine Learning to Solve Business Challenges

This article serves as a compelling example of how businesses can leverage the synergy between GoodData's analytics platform and machine learning to address intricate business challenges. Through an agile and collaborative approach, we have showcased the GoodData platform’s proficiency in prototyping and delivering solutions tailored to client's distinct requirements. By harnessing the predictive power of machine learning, businesses can enhance their financial management, make data-driven decisions, and gain a competitive edge in a continually evolving landscape.

Want to dig deeper into creating the perfect solution with GoodData? Try it for yourself with our free 30-day trial.

Why not try our 30-day free trial?

Fully managed, API-first analytics platform. Get instant access — no installation or credit card required.

Get started

Written by Jan Pansky  | 

Share