Using Probabilistic Machine Learning Methods to Improve Beef Cattle Price Modeling and Promote Beef Production Efﬁciency and Sustainability in Canada

: Accurate agricultural commodity price models enable efﬁcient allocation of limited natural resources, leading to improved sustainability in agriculture. Because of climate change, price volatility and uncertainty in the sector are expected to increase in the future, increasing the need for improved price modeling. With the emergence of machine learning (ML) algorithms, novel tools are now available to enhance the modeling of agricultural commodity prices. This research explores both univariate and multivariate ML techniques to perform probabilistic price prediction modeling for the Canadian beef industry, taking into account beef production, commodity markets, and international trade features to enhance accuracy. We model Alberta fed steer prices using three multivariate ML algorithms (support vector regression (SVR), random forest (RF), and Adaboost (AB)) and three univariate ML algorithms (autoregressive integrated moving average (ARIMA), seasonal ARIMA (SARIMA), and the seasonal autoregressive integrated moving average with exogenous factors (SARIMAX)). We apply these models to monthly fed steer price data between January 2005 and September 2023 and compare predicted prices with observed prices using several validation metrics. The outcomes indicate that both random forest (RF) and Adaboost (AB) show superior overall performance in accurately predicting Alberta fed steer prices in comparison to other algorithms. To better account for the variance of the best model performance, we subsequently adopted a probabilistic approach by considering uncertainty in our best-selected ML model. The beef industry can use these improved price models to minimize resource waste and inefﬁciency in the sector and improve the long-term sustainability prospects for beef producers in Canada.


Introduction
Agricultural commodity markets are often uncertain and unpredictable and can be affected by a wide variety of factors, including but not limited to the following: agricultural input prices and production conditions; fuel and other commodity price swings; agriculture industry financial factors; weather, natural disasters, and climate change; the global economy; and political shocks.Consequently, reliable and timely agricultural commodity price modeling is critical to ensuring the sustainability and economic viability of the agricultural sector by providing better information on commodity price behavior.The increasing availability of ever larger and more comprehensive sets of agricultural data, as well as the consistent need for accurate commodity price models, necessitates the development of robust and efficient analysis techniques that can be used to improve our understanding of commodity prices from current observations.Agricultural commodity price modeling has a long history in agricultural economics, and many different methods have been applied.These have included using time series econometric models, tracking futures prices, expert opinions, and qualitative assessments.The advent of machine learning offers new techniques to analyze and use for commodity price modeling.Identifying the appropriate machine learning methods for agriculture price analysis has gotten less attention than the application of ML to other non-agricultural sectors [1,2], and thus, more research on machine learning strategies appropriate for agricultural price analysis is required [3].
To contribute to this research, we make use of the long-term historical cattle price data available from the CanFax research service.CanFax is an established market research firm that specializes in the analysis of the Canadian beef sector "www.canfax.ca/Research.aspx(accessed on 6 October 2023)".We structure fed cattle price prediction as a machine learning problem using key price and production data for the Canadian beef sector from CanFax and several other sources, and we assess the ability of widely used machine learning algorithms to predict observed fed cattle prices using information from important correlated data.We also generate price predictions with realistic variance by modeling the probability distribution of the residual and considering it as an error term.We assume that the actual prices and residuals are realizations of a normally distributed random variable characterized by an average of zero and a variance derived from the differences between the actual and predicted data.This allows us to consider uncertainty in our ML modeling [4].
Machine learning methods are well suited to discovering complex relationships and hidden patterns across multivariate datasets.This flexibility and pattern recognition capacity minimize the errors that can arise from the incorrect application of structural models of agricultural commodity price processes.The following is a summary of our main contributions to this study:

•
With the long-term historical data available on cattle prices, agricultural commodity markets, economic indices, and international trade features, we structure price prediction as a machine learning problem that can be more accurate, consistent, and efficient than traditional time series statistical methods.

•
Three multivariate machine learning algorithms-support vector regression, random forest regression, and Adaboost regressor models-and three univariate time series algorithms-autoregressive integrated moving average (ARIMA), seasonal ARIMA (SARIMA), and the seasonal autoregressive integrated moving average with exogenous factors (SARIMAX)-were applied to long-term historical fed cattle price datasets (2005 to 2023) in Alberta.We assess the performance of these algorithms against observed fed cattle prices and identify the best machine learning algorithm for fed cattle price prediction.

•
The multivariate machine learning approach offers a feasible alternative to structural multivariate autoregressive modeling and can efficiently combine fed beef price data and related beef market factors, minimizing modeling errors and data requirements.
The rest of the paper is organized as follows: Section 2 reviews existing research on agricultural commodity price analysis, machine learning applications in the agricultural sector, and research on commodity price analysis and sustainability outcomes.Section 3 discusses the materials and methods used in this study, including the study domain and data descriptions, variables used, data preprocessing and partitioning, an introduction to each of the algorithms, as well as model validation and the chosen technical approach.Section 4 discusses the findings of both multivariate and univariate models, as well as feature engineering, hyperparameter optimization, hyperparameter tuning, and the robustness of the models.In this section, we apply a probabilistic modeling approach to the best-selected ML model.Section 5 presents some discussion of the findings, and Section 6 concludes.

Background Literature
Agricultural commodity price modeling has been performed for many decades, employing a wide variety of methods, from expert opinion outlooks and time series analysis [5][6][7] to more recent forays into machine learning approaches [2,8].
Livestock price modeling has been an important segment of agricultural price analysis work, particularly in North America, and prior research has demonstrated that useful models depend on assessing a complex set of factors, including animal health and production dynamics, seasonal, cyclical, and spatial patterns [9], feed grain production conditions [7,10] and even finance and macroeconomic conditions for regions where livestock exports and imports are important [6].
A variety of methods have been employed, from univariate time series models to multivariate time series and structured multiple equation models of both livestock prices as well as the prices of important related inputs, like feeds.An early example of univariate modeling by Oliveira et al. [11] uses the ARIMA Box-Jenkins approach to produce shortrun forecasts of live cattle prices, compares these to futures prices, and finds that ARIMA models do well at short horizons.Zapata and Garcia [12] compare multivariate vector auto-regression and error correction (VAR, VEC) approaches to predict cattle slaughter prices in the United States based on monthly data from lagged prices as well as feeder prices and per capita consumer incomes.Several other statistical approaches are outlined in detail in Linnell [13].
Beyond statistical approaches, another analysis is produced for livestock markets worldwide based on expert opinions from knowledgeable stakeholders and either public or private advisers in the livestock sector.Farm Credit Canada provides outlook reports, and the CanFax Research Service produces a weekly expert report for subscribers, combining quantitative and qualitative assessments of the livestock markets in Canada and the U.S. (canfax.ca).The United States Department of Agriculture, as well as several individual U.S. state agricultural departments, produce a wide variety of publicly available reports on livestock market conditions, which is important for Canadian producers given the high level of integration between Canadian and U.S. livestock markets.Many researchers also argue that ensemble analyses that combine and average the results from several different methodologies are better for assessing livestock market performance [5,7,13].
Evidence in the literature of prior use of machine learning to analyze cattle prices is limited.Kohzadi et al. [14] employed a walk-forward or sliding window technique on commodity price data from 1970 through 1990 to compare artificial neural networks to time series models for modeling commodity prices of cattle and wheat.They found that the ARIMA model did not perform as well as the neural network models.The ARIMA model was most comparable for wheat, but the neural network models were able to catch a substantial number of turning points for both wheat and cattle.Beyond these references, there appears to be minimal exploration in the academic literature of machine learning for livestock price analysis, particularly in Canada.However, there appears to be an increasing uptake of machine learning models in the private sector to provide commodity price modeling services more broadly, but within this, agricultural commodity prices again do not appear to be a major focus.More literature review on the various research and applications of these techniques for the agricultural sector is summarized in Table 1.Thus, our paper can fill this literature gap by analyzing Canadian fed steer prices with machine learning techniques, adding both a methodological and subject-matter contribution to our understanding of beef price data.

Agricultural Commodity Price Information and Sustainability
Statistics Canada and organizations such as Canfax routinely provide livestock market data to producers and agricultural stakeholders to help guide decision making about beef production, marketing, and trade.The availability of accurate agricultural price data has long been regarded as a key factor in promoting a successful and productive agricultural sector [30].Accurate agricultural price information monitoring has been associated with securing global objectives on food security and environmental sustainability [31].Thus, using new methodological tools such as ML to analyze agricultural commodity prices can supplement these broader objectives to increase global access to accurate agricultural commodity market information and improve both production efficiency and sustainability.

Study Domain
The study domain of this research is Alberta, a province in the west of the Canadian Prairies.Since the late 1950s, the cattle industry has gained prominence in the province and is a key component of the province's agricultural sector.Canada contributes significantly to the trade and consumption of beef around the world, and approximately 11.5 million cattle exist in Canada, including 9.5 million beef and 2.0 million dairy cattle.Canada is the world's 12th largest beef producer, with 1.50 million tons (2% of world totals) of beef produced in 2020 [32].Canada exports 47.4% of its beef, accounting for 4.8% of worldwide exports in 2020, and ranks seventh among beef exporters.Western Canada has 3.2 million beef cows, and 79% of Canada's fed cattle are finished for slaughter [32].Alberta has the largest average herd size (255 head) with 1.5 million (41%) beef cows in total, followed by Saskatchewan (1.1 million beef cows, 191 head/producer) (31%), and Manitoba (412 thousand beef cows, 167 head/producer) (11%) [32].Figure 1 shows some statistics about Canada's beef cows in Canada's provinces. of beef produced in 2020 [32].Canada exports 47.4% of its beef, accounting for 4.8% of worldwide exports in 2020, and ranks seventh among beef exporters.Western Canada has 3.2 million beef cows, and 79% of Canada's fed cattle are finished for slaughter [32].Alberta has the largest average herd size (255 head) with 1.5 million (41%) beef cows in total, followed by Saskatchewan (1.1 million beef cows, 191 head/producer) (31%), and Manitoba (412 thousand beef cows, 167 head/producer) (11%) [32].Figure 1 shows some statistics about Canada's beef cows in Canada's provinces.

Data Acquisition, Description, and Exploration
This study uses historical cattle price data gathered from CanFax [33], a market research firm that is a much-relied-upon source of cattle market information in Canada.CanFax Research Services (CRS) delivers comprehensive statistical and market information on domestic and worldwide beef trends in the Canadian beef sector.The dataset includes regularly updated monthly cattle prices (CAD/cwt) starting in January 2005 to September 2023 for fed steer cattle in Alberta, along with several other cattle classes.In order to perform a multivariate machine learning analysis for predicting cattle prices, we constructed a variable matrix comprising several key data series known to be related to cattle prices.For our analysis, we include the consumer price index, which is a measure of overall price inflation, for all items in Canada [34], the monthly average Alberta natural gas price [35] (CAD/gigajoule (GJ)), which is strongly related to agricultural production costs, the Canadian-US dollar exchange rate [36], and Alberta barely prices [37] (CAD/tonne), as barley is the main feed grain used in Alberta beef production.Table 2 summarizes the annual average values for these variables.Figures 2 and 3 also visualize the time series trends of fed steer prices and these related variables that we used for pre-

Data Acquisition, Description, and Exploration
This study uses historical cattle price data gathered from CanFax [33], a market research firm that is a much-relied-upon source of cattle market information in Canada.CanFax Research Services (CRS) delivers comprehensive statistical and market information on domestic and worldwide beef trends in the Canadian beef sector.The dataset includes regularly updated monthly cattle prices (CAD/cwt) starting in January 2005 to September 2023 for fed steer cattle in Alberta, along with several other cattle classes.In order to perform a multivariate machine learning analysis for predicting cattle prices, we constructed a variable matrix comprising several key data series known to be related to cattle prices.For our analysis, we include the consumer price index, which is a measure of overall price inflation, for all items in Canada [34], the monthly average Alberta natural gas price [35] (CAD/gigajoule (GJ)), which is strongly related to agricultural production costs, the Canadian-US dollar exchange rate [36], and Alberta barely prices [37] (CAD/tonne), as barley is the main feed grain used in Alberta beef production.Table 2 summarizes the annual average values for these variables.Figures 2 and 3 also visualize the time series trends of fed steer prices and these related variables that we used for predicting cattle prices from January 2005 to September 2023.The natural gas price and exchange rate display the highest volatility over time.Meanwhile, the fed steer price, barley price, and Canadian consumer price index show a noticeable steep increase in trend starting in 2020, coinciding with the onset of the COVID-19 pandemic outbreak.We used Pearson correlation analysis to investigate the correlations between the predictors and fed steer prices.The correlation values are statistically significant (p-value < 0.01) between fed steer and predictor variables and are displayed in Figure 4.
It shows that there is a high positive relationship between the price of fed steer cattle and the Canadian consumer price index (0.86),Alberta barley prices (0.73), and the exchange rate (0.66).Cattle prices, on the other hand, are negatively correlated with the natural gas price (−0.52).We used Pearson correlation analysis to investigate the correlations between the predictors and fed steer prices.The correlation values are statistically significant (p-value < 0.01) between fed steer and predictor variables and are displayed in Figure 4.It shows that there is a high positive relationship between the price of fed steer cattle and the Canadian consumer price index (0.86),Alberta barley prices (0.73), and the exchange rate (0.66).Cattle prices, on the other hand, are negatively correlated with the natural gas price (−0.52).We used Pearson correlation analysis to investigate the correlations between the predictors and fed steer prices.The correlation values are statistically significant (p-value < 0.01) between fed steer and predictor variables and are displayed in Figure 4.It shows that there is a high positive relationship between the price of fed steer cattle and the Canadian consumer price index (0.86),Alberta barley prices (0.73), and the exchange rate (0.66).Cattle prices, on the other hand, are negatively correlated with the natural gas price (−0.52).

Data Preprocessing, Partitioning (Train-Test), and Tuning
First, the quality of the data is visually checked by searching for obvious errors, outliers, and missing data.For testing the stationary assumption of the data, we utilized Augmented Dickey-Fuller (ADF) tests and determined that first-order differencing was sufficient to transform all variables, with the exception of the consumer price index.The consumer price index required second-order differencing to achieve stationarity.Consequently, for the multivariate dataset, the application of second-order differencing resulted in the entire dataset becoming stationary.
Then, we estimate the multivariate models using the training dataset on the scaled trained data (min-max scaler).Preprocessing the data with the min-max scaler constrains the range of our dataset, and scaling the data enhances model stability and facilitates machine learning analysis.Subsequently, we utilized these models to make predictions and assessed their performance on the scaled test dataset.We used 80% of the data for training and 20% for testing.The next step is to 'tune' the machine learning model, which is a way of prioritizing different features in terms of their importance in the overall prediction performance.We used the 'hyper-parameter module technique' to tune our training datasets.This technique discovers the ideal hyperparameter for each specific machine learning algorithm individually by comparing several model settings and comparing the metric to get the best combination of settings.The tuned model hyperparameter approach is used to improve the performance of the model [38].

An Introduction to Machine Learning Algorithms and Description
Despite the limited applications in agricultural commodity price analysis, machine learning is widely used in a variety of other fields to address complex problems that are difficult to solve with traditional analytical methods [39].ML is an artificial intelligence branch that uses algorithms rather than model-based analysis [40] to systematically synthesize the core connections between data and information with the purpose of predicting future scenarios.The main strength of machine learning is identifying underlying relationships within datasets via pattern detection and prediction.ML systems can also detect disruptions to existing models and redesign and retrain themselves to adapt to and coevolve with new information.By relying on historical experience, the machine learning process plays a critical role in generalizing prediction problems to allow for maximum extraction of useful information from prior observed behaviors and patterns.Thus, historical observed data become 'training' datasets for the machine learning algorithms and better allow the ML model to generate largely accurate predictions even in novel situations.Many big data applications use ML to run at optimal efficiency.Here, we applied our ML techniques to analyze fed steer prices using two different approaches: multivariate and univariate modeling.

Multivariate Analysis
After preparing the data matrix, we applied multivariate and univariate algorithms to predict Alberta fed steer prices.For multivariate machine learning regression modeling, we applied three robust and widely used algorithms: random forest, Adaboost, and support vector machines.
Support Vector Machines (SVM) are a commonly used classification technique that properly categorizes data.Theoretically, it only takes a short training sample and is unaffected by the number of dimensions, but it can be computationally intensive.Furthermore, effective approaches for training SVM are being developed at a swift pace, and they can also be used for regression purposes by making minor changes [41][42][43].
Random forests (RF), which were introduced by Breiman [44], are a set of tree predictors in which each tree is determined by the values of a random vector selected separately with an identical distribution of the trees in the forest.As a widely used classification and regression approach, the random forest has proven to be quite an effective method, which aggregates numerous randomized decision trees and averages their predictions.It has proven to be able to perform well in situations where the number of variables exceeds the number of observations.Furthermore, it is adaptable to a variety of unstructured learning tasks and provides measures of variable significance, making it suitable for large-scale problems [45].The RF algorithm assesses the significance of every feature in the prediction process and displays lower sensitivity to feature scaling and normalization.This characteristic makes it simpler for training and tuning.
The Adaboost algorithm, or adaptive boosting, is another multivariate method that we applied in this study.Adaboost, among the initial practical boosting techniques, was pioneered by Freund and Schapire [46].Its primary concept is based on merging multiple classifiers, termed weak learners, into a singular classifier called a strong classifier by optimizing it through a weighted linear combination and integrating one weak classifier at each step.
Boosting is an ensemble method and employs multiple predictors to enhance accuracy in regression and classification tasks.To amplify and diversify the training dataset, boosting involves sequential sampling, repeatedly drawing samples with replacements from the original data.These methods are learned in a series, primarily benefiting unstable learners like neural networks or decision trees.There's some indication that boosting leads to heightened accuracy levels [47,48].
Each machine learning algorithm has its own set of strengths and weaknesses.For example, Random Forest and Adaboost might be susceptible to overfitting, especially when confronted with noisy datasets.It is important to highlight that Adaboost, despite being designed for improved generalization, can still be vulnerable to overfitting.To mitigate the impact of noisy data and outliers in the original dataset, particularly for Adaboost, we implemented specific data preprocessing strategies as detailed in the paper (in Section 3.3).
Moreover, these models may demand significant computational resources, particularly when handling complex datasets.In situations involving imbalanced datasets, they may show a bias toward the dominant or majority class.Another weakness of RF is its sensitivity to hyperparameters, necessitating meticulous tuning to achieve optimal performance.Additionally, RF models typically operate on fixed datasets, presenting obstacles to the seamless integration of continuous updates with new data.The SVR algorithm shares similar weaknesses, with its main challenge lying in its sensitivity to hyperparameters.The efficacy of SVR is greatly contingent on the precise tuning of kernel parameters and the identification of their optimal values.Furthermore, interpreting SVR can be challenging due to its black-box nature, impeding a clear understanding of the relationships between features and the output.Therefore, proper parameter tuning and feature scaling are imperative for ensuring the effective application of SVR.
Despite these weaknesses, these ML algorithms remain widely used and effective in various applications.Addressing these limitations often involves precise hyperparameter tuning, feature engineering, and considering alternative models based on the dataset's specific characteristics.Also, careful consideration of these limitations and appropriate preprocessing strategies can help mitigate some of these challenges.

Univariate Analysis
For the univariate approach, we used the autoregressive integrated moving average (ARIMA) model, seasonal ARIMA (SARIMA), and the seasonal autoregressive integrated moving average with exogenous factors (SARIMAX).Here, to predict fed steer prices, we only used its previous or historical time series data.Univariate time-series analysis is a method for explaining sequential problems over regular time intervals.When a continuous variable is time-dependent, it is advantageous to apply this method, especially when finding consistent patterns in market data.
ARIMA is a class of models that explains a time series based on its own past values.ARIMA models can be used to model any non-seasonal time series that has patterns and is not random white noise.Making the time series stationary is the first step in creating an ARIMA model, which is achieved through differencing.Depending on the complexity of the series, multiple levels of differencing may be required.Linear regression machine learning models work best when the predictors are not correlated and are independent of one another.
The problem with the basic ARIMA model is that it does not account for seasonality.Considering the seasonality effect, seasonal terms should be added to the ARIMA model to create the Seasonal ARIMA model (SARIMA).Seasonal differencing is used by SARIMA, which is similar to regular differencing, except that instead of subtracting consecutive terms, the value from the previous season is subtracted.
The SARIMAX model is able to deal with external factors.We can include an external predictor, also known as an 'exogenous variable', in the model with the seasonal index.The seasonal index repeats every frequency cycle.
In univariate time series modeling, ARIMA, SARIMA, and SARIMAX are very popular time series prediction models, but like every other model, they also have some weaknesses.ARIMA models assume that the underlying relationships in the time series are linear.They may not capture non-linear relationships effectively, which limits their flexibility.They are also sensitive to order selection, and determining the optimal orders is the main challenge for these models.In the SARIMA model, despite accounting for seasonality, it may not capture complex seasonal patterns.Additionally, these models assume that the variance of the residuals is constant over time.Table 3 presents a summary of the multivariate and univariate machine learning algorithms that were assessed in this study.RFR is an integrated learning method, a general-purpose and quite effective classification and regression approach.It is a technique that ensembles numerous randomized decision trees and averages their predictions.

AB Adaboost Regressor
AdaBoost stands as a widely used classification algorithm.Throughout the training process, the sample's distribution weight is enhanced as the error rate rises; conversely, it diminishes as the new distribution weight decreases.Subsequently, samples are continuously trained based on these altered distribution weights.The objective is to yield robust results by minimizing subsequent model errors, ultimately achieving higher accuracy rates [49,50].

SVM Support Vector Machines
SVM is a supervised learning strategy that uses a symmetrical loss function that penalizes both high and low misestimates equally, and it has been shown to be an effective method for estimating real-value functions [51].It has the capability to conduct both linear and non-linear classification and regression.However, dealing with large datasets can be a challenging task [52].

ARIMA Auto Regressive Integrated Moving Average
ARIMA is a modeling algorithm based on the idea that past values of a time series can be used to predict future values by themselves, also taking into account autocorrelation in the error terms and stationarity.

SARIMA Seasonal Auto Regressive Integrated Moving Average
SARIMA is defined as the 'Seasonal' ARIMA model, and it is formed by adding seasonal lag and moving average terms to an ARIMA model.

SARIMAX Seasonal Auto Regressive Integrated Moving Average with exogenous factors
The SARIMAX model is another form of the SARIMA model with an external predictor, also known as an exogenous variable, e.g., a seasonal index.

Validation Methods
A comparison between the multivariate and univariate algorithms is done to evaluate the best models' performance on cattle price prediction.To minimize errors in prediction models, predicted prices are assessed using mean absolute error (MAE), root mean square error (RMSE), mean square error (MSE), mean absolute percentage error (MAPE), mean percentage error (MPE), and root mean square percentage error (RMSPE) [53][54][55][56].
The mean absolute error (MAE) is an extensively used metric for verifying a deterministic prediction and shows the magnitude of the error regardless of the prediction value [57,58].The average distance between a data point and the fitted line, measured along a vertical line, is known as the root mean squared error (RMSE).RMSE is sensitive to outliers and exhibits both under-and over-estimation in the same pattern.The mean squared error (MSE) measures the average squared gap between observed and predicted values.By utilizing squared units rather than the original data units, it magnifies the influence of larger errors, causing them to be penalized more heavily than smaller errors.This attribute is crucial when identifying a model with smaller errors.MAPE represents the average absolute error in percentages by calculating the average of the absolute percentage errors.This method provides a straightforward interpretation of errors in percentage terms [57].MPE is similar to MAPE, but it does not involve taking the absolute value of the errors.This can be valuable when you want to understand whether the model tends to under-forecast or over-forecast.The primary advantage of MPE is comparing variances between data sets with different scales.RMSPE is the square root of the mean of the squared percentage errors.It penalizes larger errors more than MAPE.This metric gauges the distance between predicted values and the actual values in the dataset, referred to as the "residual" or prediction error.It indicates how closely the actual data aligns with the line of best fit.A lower score reflects the better predictive performance of the model [59].The formulas for each metric are listed below.
where O i is observed data, P i is a deterministic prediction, and n is the number of observations.Models with the lowest metric values were assumed to be the best models, as these metrices are negatively oriented.

Technical Approach at a Glance
In this research, we utilized Python, a powerful and versatile programming language, as the foundation for our entire data processing pipeline.Python's extensive libraries and tools have enabled us to seamlessly integrate various stages of our workflow, including data exploration, feature engineering, data analytics, and visualization.This approach ensures consistency and efficiency throughout our research process.
We employed Scikit-learn in ML modeling, which is a widely used Python library, for implementing various tasks in our machine learning pipeline.This choice was driven by Scikit-learn's comprehensive suite of tools for data preprocessing, cross-validation, hyperparameter tuning, and model training, specifically for algorithms like SVM, RF, and Adaboost.Scikit-learn is particularly favored in data analytics research due to its ease of use, robustness, and comprehensive nature of its algorithms, which are well-suited for a wide range of data types and machine learning tasks.
Our regression pipeline for the multivariate models entailed the following steps: (1) in data preprocessing, we considered relevant samples and features, ensuring the data were appropriate for the models considering stationary assumption and scaling; (2) in data splitting, the dataset was split into training and testing subsets, a standard practice in machine learning to evaluate model performance; (3) in data normalization, we applied MinMaxScaler to the data to bring all variables to a similar scale, which is crucial for algorithms like SVM that are sensitive to the scale of input features; (4) in hyperparameter tuning, each algorithm underwent separate hyperparameter tuning to identify the optimal parameters.This process is critical to enhance model performance and prevent issues like overfitting; and (5) in model evaluation, after choosing the best parameters, the models were trained on the training sample and subsequently evaluated on the testing sample to assess their predictive accuracy and generalizability.
Statistical analysis was done with the Statsmodels library for our univariate analyses of the ARIMA, SARIMA, and SARIMAX models.Statsmodels is an essential tool in our research due to its extensive capabilities in statistical modeling, hypothesis testing, and data exploration, making it ideal for detailed statistical analysis.The use of Statsmodels in our research is justified by its strong statistical foundation, offering precise and reliable tools for time series analysis, which are vital for making informed predictions and understanding temporal dynamics in our data.
The pipeline for the univariate models involves the following: (1) model identification, which determines the order of the ARIMA/SARIMA model by examining autocorrelation and partial autocorrelation functions of the time series data; (2) in parameter estimation of the model, we used techniques like maximum likelihood estimation; (3) in model diagnostics, we assessed the model's performance by checking for autocorrelation in the residuals and ensuring the residuals are normally distributed; and (4) in forecasting, we use the model to make forecasts and evaluate the accuracy of these forecasts against real data.Through the combined use of Scikit-learn and Statsmodels, our research leverages the strengths of both machine learning and statistical modeling, ensuring a robust and comprehensive analysis of the data.This integration allows us to capitalize on the predictive power of machine learning while also benefiting from the inferential capabilities of statistical models, thereby enriching our research findings.

Hyperparameter Optimization
Hyperparameter optimization (HPO) is a crucial step in the development of machine learning models, essential for refining models, improving generalization, and ensuring optimal performance on new, unseen data.In machine learning algorithms, hyperparameters are configuration settings that must be specified before the training process, as they are not learned from the data.These hyperparameters significantly influence the performance of a machine learning model.
In hyperparameter optimization, we aim to discover the optimal set of hyperparameters for effective generalization of unseen data, enhancing the model's performance.Within various existing HPO techniques, we utilized the existing HPO frameworks in SKlearn, which are implemented to select optimal hyperparameters through grid search and random search algorithms.The performance of each configuration is evaluated using cross-validation [60].For each algorithm, we considered a range of hyperparameter values.To exhaustively evaluating the model's performance for each combination, we utilized cross-validation (CV = 10) to ensure robust generalization capabilities.Table 4 outlines the selected parameters and their respective ranges.
The optimization process typically involves dividing the dataset into training and test or validation sets, training the model with different hyperparameter values on the training set, and evaluating the model's performance on the test set.This iterative process continues until the best set of hyperparameters is identified.

Feature Selection and Hyperparameter Tuning
Fine-tuning hyperparameters is crucial for algorithms and enhancing the machine learning model's overall performance.This process is established before the learning phase and is conducted externally to the model.Without adequate hyperparameter tuning, the model cannot deliver accurate results since the minimization of the loss function does not take place and will be prone to making errors.Hyperparameter tuning aims to identify the optimal values that maximize the model's performance, minimize loss, and model parameters for the ARIMA, SARIMA, and SARIMAX models.Table 7 describes some additional summary statistics of time series model residuals using the results.Prob (Q) is the p-value for the null hypothesis that the residuals have no correlation structure.Prob (JB) is the p-value associated with the null hypothesis that the residuals are Gaussian normally distributed.If either of the p-values is less than 0.05, the hypothesis is rejected.When the values of prob (Q) and prob (JB) are near 0.00, we can reject the null hypothesis that the residuals are not Gaussian normally distributed and have some correlation structure.The Akaike information criterion (AIC) and Bayesian information criterion (BIC) were used to estimate the parameters of the best-fit ARIMA model in time series modeling [61].Using the stepwise approach, a seasonal interval of 12 months or one year is chosen for the SARIMA-based machine learning problem, which implies that price patterns repeat in a similar way every year rather than at a higher frequency pattern every quarter or season.Within SARIMAX, the consumer price index is chosen as an exogenous term due to its independence but high correlation with agricultural commodity prices.Comparing the performance of all models, the random forest and Adaboost models were selected as outstanding multivariate models according to the validation metrices on the test data for predicting monthly Alberta fed steer cattle prices.

Robustness of the Models
To secure the robustness of the models, we took additional steps.As a preliminary step, we segregated the dataset into training and test sets, in which modeling analyses were initially conducted on the training subset, and subsequently, the performance was assessed on the test subset.In addition to the test evaluation, the training accuracy is also detailed in Table 9. Examining the validation metrics on the training data also shows a high level of modeling accuracy, increasing confidence in the robustness of our approaches.
Moving forward, we applied cross-validation to identify optimal hyperparameters for each specific machine learning algorithm.Applying cross-validation is essential in identifying optimal hyperparameters in machine learning for various reasons, such as optimizing hyperparameters, preventing overfitting, reducing variability, and ensuring a more realistic evaluation.Cross-validation contributes to a reliable and unbiased estimation of a model's performance.Simulating how the model generalizes to different subsets of the data facilitates the identification of optimal hyperparameters, resulting in a robust and well-generalized assessment.Since both RF and AB demonstrated comparable high performance, we opted to present the remaining validation visualizations solely using the RF model.The RF model's primary outcome estimates the anticipated cattle price but lacks variance, leading to a decrease in variance for the RF deterministic forecasts.The most statistically valid method to produce predictions with realistic variance is modeling the probability density of the residual and taking it into account.The premise is that the scaled actual price and residuals are realizations of a univariate Gaussian random variable, with an average of zero and a variance based on the disparities between the actual and RF-predicted values.A Gaussian distribution was assumed for the residuals for simplicity in modeling the conditional distribution.This approach yields realizations of the conditional distribution of the actual price values using a probabilistic approach.Figure 5 shows the visualization of the scaled actual and probabilistic RF predicted for the test data set from January 2005 to September 2023.Also, the boxplots illustrate 500 realizations of the probabilistic, generated prices, indicating the inner quartile range within these forecasts.The whiskers represent the 0.025 and 0.975 quantiles.The graph demonstrates that the outcomes of our probabilistic RF prediction model fall within the 95% confidence interval.The zoomed visualization of the test data verification (the right side of Figure 5 is represented in Figure 6).

Applying Probabilistic Modeling Approach to the Selected Machine Learning Model
Since both RF and AB demonstrated comparable high performance, we opted to present the remaining validation visualizations solely using the RF model.The RF model's primary outcome estimates the anticipated cattle price but lacks variance, leading to a decrease in variance for the RF deterministic forecasts.The most statistically valid method to produce predictions with realistic variance is modeling the probability density of the residual and taking it into account.The premise is that the scaled actual price and residuals are realizations of a univariate Gaussian random variable, with an average of zero and a variance based on the disparities between the actual and RF-predicted values.A Gaussian distribution was assumed for the residuals for simplicity in modeling the conditional distribution.This approach yields realizations of the conditional distribution of the actual price values using a probabilistic approach.Figure 5 shows the visualization of the scaled actual and probabilistic RF predicted for the test data set from January 2005 to September 2023.Also, the boxplots illustrate 500 realizations of the probabilistic, generated prices, indicating the inner quartile range within these forecasts.The whiskers represent the 0.025 and 0.975 quantiles.The graph demonstrates that the outcomes of our probabilistic RF prediction model fall within the 95% confidence interval.The zoomed visualization of the test data verification (the right side of Figure 5 is represented in Figure 6).

Discussion
The results of the Random Forest and Adaboost modeling of fed steer prices provide confidence in our approach.Even taking errors in the predicted prices into account, the actual fed steer price test data falls within the 95% confidence interval for most of the test data period.The multivariate approach also provides some approximation of the variability of fed steer prices.Univariate models are unable to reflect this more detailed agricultural commodity price behavior over such a long time horizon and are typically only used to develop in-sample forecasts for two or three time periods.So, the potential of being able to more fully and feasibly incorporate multiple important data features into the fed steer price model is a useful addition to existing agricultural commodity price modeling methods.
There seems to be an exception in our model estimates occurring around test point 34 in Figure 6, which corresponds approximately to the winter of 2022.This was a period of very high inflationary pressures in North America, and fed steer prices also showed a steep increase during this time period.So, our ML approach was not able to fully capture this shift in the time trends for beef prices.However, the predictions returned to the 95% confidence interval shortly after this, so this discrepancy appears to have been temporary.This suggests that there is more work to be done to build a multivariate model that can more closely keep up with more infrequent agricultural commodity price swings, but our initial modeling efforts have nonetheless performed very well.
With the increasing availability of machine learning analysis tools, it should be possible for other analysts to similarly construct reasonable multivariate machine learning models of fed steer prices and other agricultural commodity price data.These machine learning models can then be added to the portfolio of more traditional commodity price modeling techniques and help build a more robust ensemble picture of agricultural commodity price behavior and trends.

Conclusions
Alberta's cattle industry is important to the province's economy.The province is a key producer of beef in Canada, boasting the largest distribution of feeder beef cattle and calves.Cattle prices in Alberta have experienced considerable fluctuations from 2005 until the present due to multiple influencing factors.We believe that modeling these prices holds significance for farmers, policymakers, insurance companies, and traders, enabling informed marketing decisions and risk management.This study highlights the successful predictive ability of machine learning algorithms in anticipating cattle prices and their associated uncertainties in Alberta.Factors like data quality, variable selection, and model optimization are pivotal aspects that can be well ensured with machine learning approaches without compromising performance.Greater use of standard machine learning methods in commodity price modeling has the potential to improve our ability to analyze agricultural commodity prices.In this paper, we have conducted a side-by-side comparison of univariate and multivariate machine learning modeling methods on monthly fed steer prices in Alberta between January 2005 and September 2023.We can summarize this study's outcomes with three main points: 1.
Multivariate modeling, incorporating additional key variables as predictors, demonstrated an advantage over univariate approaches in our investigation.

2.
Probabilistic modeling has an advantage compared to deterministic modeling.By employing probabilistic modeling, we consider uncertainties and incorporate them into deterministic RF predictions, providing a more realistic context for the predicted values with the selected RF model.This process should be more routinely applied to other machine learning modeling studies.

3.
Lastly, in the comparison of multivariate machine learning algorithms, the Adaboost and Random Forest models exhibited almost similar and robust validation performance with respect to our variables.When comparing univariate models, SARIMAX demonstrated the best univariate time series model, considering the seasonal effect and incorporating the Canadian consumer price index as an exogenous term.However, multivariate models performed better overall.
Machine learning methods with additional probabilistic modeling can thus improve our analytical capacity by enabling more accurate model selection by 'letting the data speak' as well as better incorporating new information and complex time series data structure elements.Future steps involve investigating whether a multivariate approach could further enhance the prediction of fed steer prices in a year characterized by significant shocks and dynamic influences such as inflation, more variation in grain prices, and exchange rates.
Possible future work derived from this study could include the following: 1.
Further refining and enhancing the existing ML models by exploring additional algorithms, fine-tuning hyperparameters, or considering ensemble machine learning methods for improved predictive performance for agricultural commodity prices.

2.
Exploring advanced ML techniques such as deep learning or reinforcement learning to evaluate their relevance and potential advantages in cattle price prediction.

3.
Investigating the impact of some additional external factors or variables on the cattle price prediction models, such as environmental factors and climate variabilities and resource availability, geopolitical shocks, economic indicators, or other relevant factors that could contribute to a more comprehensive understanding of price dynamics.
The methods used in this manuscript are becoming more accessible to livestock sector researchers and analysts, and our work should help support additional explorations of the value of machine learning in understanding commodity price dynamics.Our contribution can also help minimize the impact of commodity price shocks on production and sustainability through better modeling.

Figure 1 .
Figure 1.Canada's beef cows in provinces (all inventories in 1000 heads), as of January 2021, reported by StatCan.

Figure 1 .
Figure 1.Canada's beef cows in provinces (all inventories in 1000 heads), as of January 2021, reported by StatCan.

Figure 3 .
Figure 3. Time-series variations of the predictors from January 2005 to September 2023. .

Figure 3 .
Figure 3. Time-series variations of the predictors from January 2005 to September 2023.

Figure 3 .
Figure 3. Time-series variations of the predictors from January 2005 to September 2023. .

Figure 5 .
Figure 5. Actual and probabilistic RF predicted normalized cattle prices by RF model on scaled test data from 2005 to 2023.Boxplots show 500 realizations of the probabilistic RF model.The boxes display the median and interquartile range, while the whiskers indicate the 95% interval.

Figure 5 .
Figure 5. Actual and probabilistic RF predicted normalized cattle prices by RF model on scaled test data from 2005 to 2023.Boxplots show 500 realizations of the probabilistic RF model.The boxes display the median and interquartile range, while the whiskers indicate the 95% interval.

Figure 5 .
Figure 5. Actual and probabilistic RF predicted normalized cattle prices by RF model on scaled test data from 2005 to 2023.Boxplots show 500 realizations of the probabilistic RF model.The boxes display the median and interquartile range, while the whiskers indicate the 95% interval.

Figure 6 .
Figure 6.Zoomed graph of actual and probabilistic RF-predicted normalized cattle prices using RF model on scaled test data.

Figure 6 .
Figure 6.Zoomed graph of actual and probabilistic RF-predicted normalized cattle prices using RF model on scaled test data.

Table 1 .
Summary of application of ML to agriculture.

Table 2 .
Annual average price values for key data variables (* 2023 includes January to September).

Table 2 .
Annual average price values for key data variables (* 2023 includes January to September).

Table 3 .
Summary description of the multivariate and univariate ML approaches used in this study.

Table 7 .
Summary statistics of residuals for the best-selected univariate ML models.Upon running the ML models on the training data, we computed the various validation metrics to assess the model's performance using the remaining 20% of the test dataset.Smaller values of MAE, RMSE, MSE, MAPE, MPE, and RMSPE indicate better performance since they are negatively oriented metrics.As a result, we can be confident in the model's ability to accurately model cattle price values.The accuracy of our models is summarized in

Table 8 .
The accuracy metrics of the ML price predicting models on the test data.

Table 9 .
The accuracy metrics of the ML price predicting models on the training data.