December 02, 2024

Use cognitive services in order to predict the number of Sales per article per Account
using data from Business Central

Predicting the number of sales per article per account can be a valuable task for businesses looking to improve their sales forecasting and better understand their customers’ behavior. With the help of Azure Cognitive Services, it is possible to build a predictive model that uses data from Business Central to predict the number of sales per article per account. Here are the steps to do this:

  1. Set up an Azure Cognitive Services account To use Azure Cognitive Services, you need to set up an account on the Azure portal. Once you have set up the account, you can access various APIs, including the Machine Learning API, which can be used for building predictive models.
  2. Prepare the data To build a predictive model, you need to prepare the data that you will use to train the model. In this case, you will need data from Business Central that includes the number of sales per article per account. You can extract this data from Business Central using the APIs provided by the application.
  3. Train the model Once you have prepared the data, you can use the Azure Machine Learning API to train the predictive model. This involves selecting the appropriate features (such as account, article, date, etc.), selecting a model type (such as regression, decision tree, or neural network), and tuning the model parameters (such as learning rate, regularization, or depth).
  4. Evaluate the model After training the model, you need to evaluate its performance on a test set of data. This involves comparing the predicted values to the actual values and calculating metrics such as mean squared error or R-squared.
  5. Deploy the model Once you have evaluated the model and are satisfied with its performance, you can deploy it to a production environment. This involves creating an API that allows you to send new data to the model and receive predictions in real-time.

Here’s an example code using Python and the Azure Machine Learning API to build a predictive model for sales per article per account:

import pandas as pd

import requests

from azureml.core import Workspace

from azureml.core.webservice import AciWebservice

from azureml.core.model import Model

from azureml.core.authentication import ServicePrincipalAuthentication

# Define the Business Central API endpoints

bc_endpoint = ‘<YOUR_BUSINESS_CENTRAL_API_ENDPOINT>’

bc_key = ‘<YOUR_BUSINESS_CENTRAL_API_KEY>’

headers = {‘Authorization’: f’Bearer {bc_key}’}

# Define the Azure Machine Learning workspace

svc_pr = ServicePrincipalAuthentication(

    tenant_id='<YOUR_AZURE_TENANT_ID>’,

    service_principal_id='<YOUR_AZURE_SP_ID>’,

    service_principal_password='<YOUR_AZURE_SP_PASSWORD>’

)

ws = Workspace(

    subscription_id='<YOUR_AZURE_SUBSCRIPTION_ID>’,

    resource_group='<YOUR_AZURE_RESOURCE_GROUP>’,

    workspace_name='<YOUR_AZURE_WORKSPACE_NAME>’,

    auth=svc_pr

)

# Extract data from Business Central

data = []

response = requests.get(f'{bc_endpoint}/sales’, headers=headers)

for sale in response.json():

    data.append({

        ‘Account’: sale[‘Account’],

        ‘Article’: sale[‘Article’],

        ‘Quantity’: sale[‘Quantity’],

        ‘Date’: sale[‘Date’]

    })

df = pd.DataFrame(data)

# Train the predictive model

from azureml.core.experiment import Experiment

from azureml.train.automl import AutoMLConfig

automl_config = AutoMLConfig(

    task=’regression’,

    training_data=df,

    label_column_name=’Quantity’,

    iterations=10,

    max_concurrent_iterations=4

)

experiment = Experiment(ws, ‘sales-prediction’)

run = experiment.submit(automl_config)

run.wait_for_completion(show_output=True)

# Evaluate the model

best_run, fitted_model = run

About The Author

Founder & CEO of Logol AG www.logol.com Microsoft MVP Business Solutions Active member of Scrum Alliance with the certifications CSM and CSP I got Microsoft MCP, MCPD, MCTS certifications as well.Logol, pioneering specialist in the field of cloud-enabled digital transformation, is the first operator specifically created to implement modular programs designed to unleash breakthrough innovation and rationalize business processes. Founded and directed by an award-winning expert tapping directly into the vision of leading IT companies and spearheading forward-thinking digitalization projects, Logol addresses the needs of enterprises in all sectors as they embrace new technologies and organizational change in the era big data and artificial intelligence. Logol helps organizations leverage the power of the most advanced cloud technologies, offering end-to-end consultancy for total digital transformation and business process automation, employing agile methodologies and change management techniques for smooth transitions towards new business paradigms. Digital transformation programs are a milestone in a company’s business evolution and can be the basis of their success. Accompanying clients as they transform their business processes, Logol assists them in rethinking not only the scope of their technologies, but also the strategy, mindset and company culture that make digital transformation viable and effective. As digital transformation programs are successful only if approached with the highest professional competence, Logol selects and employs brilliant professionals who demonstrate outstanding technical expertise in the most advanced information technologies, in depth strategic knowledge of business processes and innovation, and refined soft skills to better support people and organizations facing change. Logol is headquartered in Switzerland and addresses the needs of both public and private sector players by promoting a comprehensive and proactive approach to digital transformation as a necessary step for inclusion and competitiveness in today’s digital economy.

Related posts