Introduction

In recent years, population growth and technological developments have led to an increase in global energy demand. Fossil fuels account for about 80% of the world’s current energy supply (Safieddin Ardebili 2020; Khoshgoftar Manesh et al. 2020). In recent years, there has been an increase in greenhouse gases as a result of the widespread use of fossil fuels. Greenhouse gases are known to cause significant changes in the global climate. It is also clear that fossil fuels will run out in the future (Alatzas et al. 2019; Le et al. 2020). Renewable energy is the fourth largest energy source after oil, coal, and natural gas; and its use is increasing (Razmjoo et al. 2021; Aravani et al. 2022). Many developed countries are actively using fuels such as biogas and biochar and are becoming less dependent on fossil fuels (Chowdhury et al. 2020; Zamri et al. 2021; Siddiki et al. 2021). The conversion of waste materials into biogas is a biological process. As a sustainable carrier, biogas usually consists of methane (CH4) (35–40%) and carbon dioxide (CO2) (60%). It also contains various gases such as ammonia, hydrogen sulfide, hydrogen, oxygen, nitrogen, and carbon monoxide (Khalil et al. 2019; Pramanik et al. 2019; Zabed et al. 2020; Ramírez-Islas et al. 2020).

Renewable energy and biomass from animal manure in Turkey

Turkey is geographically and climatically a suitable area for energy production from renewable sources such as wind, solar, and hydroelectricity. From a technical point of view, hydroelectric energy in Turkey has 1.5% of the world’s theoretical potential, as well as 17.6% of the European potential. As of the end of July 2022, there are 750 hydroelectric power plants in the country. Turkey attaches great importance to energy production based on hydroelectricity due to its geographical location and water resources. In terms of renewable energy, the largest share of the average electricity production is hydroelectric power plants (RTME and NR 2022). According to the Electricity Transmission Company, the ranking of Turkey’s gross electricity production by primary energy sources as of 2020 is as follows: 78,094 GWh hydroelectric, 70,931 GWh natural gas, 67,873 GWh hard coal and imported coal, 45,806 GWh geothermal/wind/solar, 37,938 GWh lignite, and 5736 GWh renewable wastes and waste heat (Erdin and Ozkaya 2019). Different incentives are given to businesses that produce from different renewable energy sources to reduce carbon emissions and energy costs in Turkey. For 2022, 7.3 dollars/cent for wind and hydroelectric, 10.5 dollars/cent for geothermal, and 13.3 dollars/cent for biomass and solar energy incentives were provided (TETC 2021; EPDK 2022; MI and T 2022; RTME and NR 2022). Data on electricity generation based on renewable resources obtained from the Electricity Transmission Company are given in Fig. 1 (TETC 2021; Ocak and Acar 2021; IEA 2022).

Fig. 1
figure 1

The proportion of renewable energy sources in electricity generation for Turkey

Turkey’s electricity demand is expected to reach 424 TWh in 2023. It is aimed that the share of production from renewable energy sources will be at least 30% by 2023. Turkey’s biomass waste potential is approximately 8.6 Mt oil equivalent (MTEP), and the amount of biogas that can be produced is 1.5–2 MTEP (Melikoglu 2017; Rincon et al. 2019; Ocak and Acar 2021). In this context, the use of biomass as an alternative source to meet the increasing energy demand and reduce the dependence on foreign conventional sources deserves detailed analysis (Bakay and Ağbulut 2021; Yurtkuran 2021; Şenol et al. 2021). It is noteworthy that Turkey has significant biomass potential as it is the world’s 7th largest agricultural biomass producer. The International Energy Agency estimates that the total installed power of biomass power plants in Turkey will increase by 630 MW from 2020 to 2025 (Erdin and Ozkaya 2019; TETC 2021; Erat et al. 2021; IEA 2022; Gündoğan and Koçar 2022).

As of 2022, Turkey’s population is over 84.5 million. Depending on the diversity of climate, vegetation, and landforms, many animal husbandry species have developed in Turkey. Cattle, small ruminants, poultry, beekeeping, silkworm breeding, and fishing are the main types of livestock (IOPRT 2021; World Bank 2021). In 2021, there are 18,240,000 cattle, 57,519,000 small ruminants, and 98,115,000 poultry in Turkey (TUIK 2022). Modern techniques have been developed for animal husbandry in populated cities. Small ruminants in the country are sheep, hair goats, and angora goats. Sheep breeding is generally found in the interior of Turkey. While hair goat breeding is carried out throughout Turkey, Angora goat breeding is carried out in the Mediterranean region. (Font-Palma 2019; Şenol et al. 2021; Ilbas et al. 2022). From the point of view of the enterprise, the number of cattle breeding enterprises registered in the Turkvet Animal Registration System in Turkey is 1,295,632, and the number of sheep and goat breeding enterprises is 444,446 (World Bank 2021; RTMAF 2022). Livestock has a significant share in Turkey’s greenhouse gas emissions. Therefore, it is aimed to find innovative approaches and solutions to reduce greenhouse gas emissions from manures. Sustainable manure management systems should be implemented on farms that reduce the risk to the environment and allow the storage, transportation, and use of manure. Animal manure is a type of biomass and biogas can be produced. When using the obtained biogas, digested substrate or decay product residues can also be used as a valuable fertilizer (Cheng et al. 2021; Karaaslan and Gezen 2022). It is estimated that Turkey’s natural gas need will reach 73,400 Mm3 in 2026. Therefore, the country aims to reduce natural gas imports and increase biogas production. In case of effective use of agricultural and animal waste potential, natural gas can be saved and imports can be reduced significantly (Melikoglu and Menekse 2020; Gündoğan and Koçar 2022). The number of power plants producing electricity from biomass in Turkey is 199. As of 2022, the capacity of the 106 biogas power plants operating in Turkey is approximately 588 MW, contributing 1.21% of the installed power capacity.

Livestock production in the Western Mediterranean Region, Turkey

The Western Mediterranean Region includes the provinces of Antalya, Burdur, and Isparta, designated TR61 in IBBS Level 2. With an area of 36,797 km2, the region constitutes approximately 4.7% of Turkey’s area and 3.8% of its population. The total population of Antalya, Isparta, and Burdur is 3,134,694. While the annual population growth in Turkey was 14.7 per thousand in 2018; this value was 25.9 per thousand in Antalya, 17.3 per thousand in Isparta, and 19.3 per thousand in Burdur. According to 2018 data from Turkstat, 1.20% of the total animal products value was performed by Antalya, 1.57% by Burdur, and 0.95% by Isparta province (RTMAF 2018; TUIK 2022). Animal husbandry in the region is generally in the form of small-scale family businesses and is carried out together with plant production activities. This situation limits professionalization in animal production. Animal shelters feature closed and fixed attachment. The Mediterranean region accounts for 4% of the country’s sheep and goat population. In addition, the region ranks 9th among Level 2 regions in terms of sheep and goat population (WMDA 2022). In 2018 for Antalya, it was reported that the number of cattle was 85,833 (55.99% pure culture, 32.22% cultural hybrids, 6.57% native, 5.06% hybrid, 0.05% buffalo), and the number of small ruminants was 1,245,651 (39.65% sheep, 60.35% goat). In addition, the number of poultry was 530,582 (92.25%-layer hen, 0.87% duck and guinea fowl, 1.8% goose, 5.15% turkey). The livestock support for Antalya in 2018 was 69,491,039 Turkish lira. In addition, 445 cattle and 1190 sheep and goats were donated to Antalya within the scope of the young farmer project (TUIK 2022). Approximately 70% of the population of Burdur is engaged in agriculture and animal husbandry. Culture breed cattle constitute 98.4% of the cattle. There are 23,000 registered farmers and 16,000 active livestock enterprises in the province. According to Turkstat data, there are 14,810 cattle and 5902 small ruminant farms in Burdur. The livestock support for 2018 in Burdur was 67,019,939 Turkish lira. For 2018 in Burdur, the number of cattle was 222,843 (89.69% pure culture, 8.84% culture cross, 0.46% native, and 0.85% crossbreed), and the number of small ruminants was 410,449 (45.07% goat, 54.92% sheep). The number of poultry was 205,813 in Burdur (4.46% turkey, 0.54% goose, 0.2% duck and guinea fowl, 96.71% laying hen). In addition, 515 cattle and 1020 small ruminants were donated to Burdur within the scope of the young farmer project in 2018 (TUIK 2022). In Isparta for 2018, the number of cattle was 145,012 (65.80% pure culture, 15.79% culture cross, 15.17% native, 3% hybrid, and 0.21% buffalo), and the number of small ruminants was 491,550 (56.9% sheep, 43.10% goat), the number of poultry was 445,574 (3.42% turkey, 0.42% goose, 0.80% duck and guinea fowl, 95.34% laying hen). According to the data of the Turkish veterinary information system, there were 13,223 cattle and 4577 small ruminant enterprises in Isparta. Four hundred ninety cattle and 1020 small ruminants were donated to Isparta within the scope of the young farmer project in 2018 (TUIK 2022).

Related studies in the literature

In the literature, there are studies on theoretical and experimental biogas calculations for various countries and regions of the world. There are also studies involving artificial intelligence in biogas calculations. Some of these recent studies are given here. In addition, studies on biogas in Turkey are also included at the end of this section. Nejafi et al. (Najafi and Faizollahzadeh Ardabili 2018) used ANFIS and ANN models to predict small-scale biogas production and stated that ANFIS gave better results. Avcıoğlu et al. (Avcıoğlu et al. 2019) calculated the energy potential of agricultural biomass residues in Turkey. It has been stated that the total agricultural residue in Turkey is 75,084 kt and the theoretical energy potential is 998,473 TJ. De Clercq et al. (De Clercq et al. 2019) created a machine learning model that can predict biogas output based on waste input to improve production in the industry. The machine learning model used consists of logistic regression, SVM, random forest, extreme gradient boosting, and k-near neighbor regression. Beltramo et al. (Beltramo et al. 2019) used an optimized ANN model to predict the biogas production rate of an agricultural biogas plant. Bao et al. (Bao et al. 2019) calculated China’s animal manure-based biogas potential. It has been estimated that China’s biogas potential was 61,000 Mm3 in 2015 and could be between 86,000 and 110,000 Mm3 in 2030. Melikoğlu and Menekşe (2020) estimated 2140 Mm3 biomethane amount from cattle and sheep manure for 2026 in Turkey. It is reported that in 2026, it can meet approximately 2.9% of the country’s natural gas needs. Stolarski et al. (Stolarski et al. 2020) examined the development of bioenergy technologies in some European countries. It has been determined that the greatest potential for agricultural biomass is in Germany and Poland. It was stated that 92% of the biogas plants are in Germany. Oliveira et al. (Oliveira et al. 2020) examined the energy potential of manure and municipal waste in Brazil. In the study, a mathematical model based on multiple LR was created to predict the electricity generation potential. Elmaz et al. (Elmaz et al. 2020) used the machine learning method to predict the results of biomass gasification. In the study, polynomial regression, SVM, decision tree regression (DTR), and multilayer heuristics methods were used. MLP and DTR showed the best performance compared to other methods. Ulusoy et al. (Ulusoy et al. 2021) analyzed the biogas and energy production potential from chicken manure in Balıkesir, Turkey. The pilot plant processes 110 kt of waste and produces 8.58 Mm3/year of biogas. With this biogas production, 17 GWh/year of electricity and 16 GWh/year of thermal energy can be obtained. Seo et al. (Seo et al. 2021) applied ANN to predict the biogas output of dry anaerobic digestion of food waste. The model presented a derived R2 of 0.82 for validation data and 0.85 for test data, indicating a high linear correlation between datasets. Siddiki et al. (Siddiki et al. 2021) investigated the manure, biogas, and energy production of Bangladesh in 2018–2019. As a result, 27,923.72 Mm3/year of biogas will be produced from 486.77 Mt of manure. Ceylan et al. (Ceylan et al. 2021) developed a hybrid optimization model for determining the optimum installation location of a biogas power plant for Manisa, Turkey. The mathematical model of the process was determined by the neuro-regression approach. The traditional and hybrid models were compared, and it was concluded that the values of the hybrid model were more acceptable. Jeong et al. (Jeong et al. 2021) estimated biogas production from a municipal wastewater treatment plant in South Korea. The anaerobic digestion process was tried to be modeled using deep learning-based models. The highest success in terms of R2 value was found to be 0.76. Oliveira et al. (Oliveira et al. 2021) created a mathematical model for the estimation and optimization of the energy potential from animal manure and sewage in the Brazilian state of Minas Gerais. In the study, a nonlinear deterministic constructive algorithm was used. Senocak and Guner Goren (Senocak and Guner Goren 2022) estimated the agricultural and animal amount and energy potential expected to emerge in the coming years of various agricultural and animal-based biomass resources of Acıpayam-Denizli, Turkey, using SVM and performing spatial analysis.

Ozcan et al. (Ozcan et al. 2015) determined the biomass potential of Turkey according to different sources. In the study, it was stated that the total biogas potential installed power is 9.50 GW, and the energy value of the total usable dry manure amount related to animal husbandry is 53.74 TWh/year. Özer (Özer 2017) stated that the animal manure and agricultural residues and potential for 2015 for Ardahan, Turkey is 81 Mm3 and 323 GWh of electricity can be produced with this potential. Karaca (Karaca 2018) reported that the amount of biogas from the manure of dairy cattle and meat chickens in Turkey is 1.6 billion m3 annually, and the thermal energy value is approximately 36.7 PJ. Akyürek and Coşkun (Akyürek and Coşkun 2019) determined the biogas potential from animal wastes in the Aegean Region of Turkey. It has been reported that approximately 4.6 Mt/year of CO2 emissions can be reduced by biogas production. Ersoy and Uğurlu (2020) evaluated the biogas production and greenhouse gas reduction potential of Turkey’s livestock sector in 2015 with two different scenarios. According to the first scenario, the amount of biogas was determined as 8.41 billion m3 and 4.18 billion m3 in the second scenario. It has been emphasized that 1.13% of greenhouse gas emissions can be prevented through biogas production. Ocak and Acar (Ocak and Acar 2021) evaluated the energy production potential of the Marmara region, Turkey. In the study, it was stated that it would be economically better to convert agricultural and animal waste first into biogas and then into electricity. Çalışkan and Tümen Özdil (2021) determined the biogas potential of animal origin for different regions of Turkey between 2007 and 2019. It has been stated that the total biogas potential between 2007 and 2019 is 128.338 Mm3 and will correspond to 7.99% of electricity consumption. Aksüt et al. (Aksüt et al. 2022) stated that the amount of biogas based on cattle, small ruminants, and poultry for Tokat, Turkey in 2021 is 49 Mm3 and its energy equivalent is 292.000 MWh. Çakal and Çelik (Çakal and Çelik 2022) determined the biogas potential and energy equivalent of Turkey’s agricultural wastes. In the study, it was determined that the total amount of biogas is 240,673,168 m3/year, and the biogas energy equivalent is 5463.19 TJ/year. Aksay and Tabak (Aksay and Tabak 2022) reported that the biogas potential of animal manure and agricultural wastes in Turkey is 17 billion m3. It has been stated that 38 GWh of electricity can be produced with this potential, and a total of 174 million tons of CO2 emissions can be reduced.

It is predicted that biogas production based on manure may play an important role in the future of renewable energy in Turkey. Turkey has forward-looking goals to increase renewable energy production and reduce greenhouse gas emissions. In addition, investments in this area in Turkey are mostly in the establishment phase and are expected to continue increasing. With the growth in the software system in Turkey, it is foreseen that there will be 100,000 additional employment and an export potential of ten billion dollars by 2025. The software industry, with its unique global dynamics, creates a qualified and high-income employment opportunity in the country. Turkey’s studies on the use of artificial intelligence methods continue (TÜSİAD 2022). For the use of livestock controllers, researchers, and policy planners, accurate estimation of energy conversions according to Turkey’s manure-based production potential are of great importance. With such estimation methods used in the study, the feasibility of animal manure-oriented biogas production in Turkey can be analyzed in detail, and its impact on energy and the economy can give an idea to researchers and policy planners. Energy conversion calculations based on fertilizer potential for the coming years can contribute to the planning of Turkey’s future energy needs.

In this study, the provinces of Antalya, Isparta, and Burdur, which are in the TR61 region of Turkey, were selected. This region is also named the Western Mediterranean and Lakes Region and is one of Turkey’s important livestock bases. The Western Mediterranean Region has very favorable conditions for agriculture and animal production with its geographical location, fertile lands, suitable climate, adequate water resources, proximity to major markets, and competitive workforce. The fertile and wetland structure of the region provides product diversity in terms of animal production. The region holds more than 10% of the country’s general production in cattle breeding, especially in wool and milk production related to hair goats. With its ecological structure, livestock can be made in the most economical way throughout the year and has many economic advantages. These economic advantages can be summarized as low-cost shelter opportunities due to the favorable climate, the use of most fruit and vegetable industry by-products only by animals, the relatively cheap cost of feed, and the fact that animal manure is an important agricultural input for covered production and floriculture. Antalya is located on the Mediterranean coast and has great potential in terms of the tourism sector. On the other hand, the regions located in the highland part of the province are quite suitable for animal husbandry. Especially in the summer months, the population of the city increases, and the demand for animal products increases. Animal production gains importance in meeting this increase in demand. Along with agricultural plant production in Isparta, animal husbandry has become a developed branch of agriculture due to favorable climatic and environmental conditions. All kinds of cattle, small ruminants, and poultry farming are carried out in the province. With the animal breeding studies implemented in the province in recent years, there have been remarkable developments both in the number of animals and in animal products. Various sheep species and hair goats are widely grown in the city, and animal husbandry is among the important livelihoods of the people of Isparta. The livelihood of the people of Burdur is agriculture and animal husbandry. For example, 40% of Burdur’s economy is based on milk production (RTMAF 2018). The number of animals in the province has been increasing over the years and has an important position in the country, especially in dairy cattle breeding. In the province, where animal husbandry is intense, there is a daily production of over 1000 tons of raw milk. Burdur Mehmet Akif Ersoy University has served as a regional university in the field of animal husbandry and provides support to regional farmers in areas such as animal health, animal breeding, farm education, and livestock-based industry. In this sense, incentive mechanisms have also been created in the field of animal husbandry in the province, and new steps have been taken toward modern animal breeding (BAGEV 2022; CoHE 2022; RTMCT 2022).

In this study, biogas amount, CO2 emission, coal, electricity, thermal energy, and CH4 values were modeled by using general and special information about cattle, small ruminants, and poultry, and animal age, number, and waste amount information. No detailed analysis has been found in such studies in which artificial intelligence techniques are used in the literature. In the theoretical biogas calculations for Turkey, artificial intelligence applications were not included, although detailed. Popular machine learning algorithms in the literature were used for modeling in the study. The study is given in four parts. In the first part, statistical information about the biogas and the study area is given and a literature review is included. In the second part, the parameters used in the calculation of biogas and energy potentials and the proposed methods for estimation are explained in detail. In the third part, the findings of the experimental results of machine learning algorithms are compared under various scenarios. In the last part, the results are given in detail and suggestions have been made.

Material and method

Theoretical determination of animal manure, biogas, and energy potential

In the study, 2018 data from Turkstat were used for Antalya, Isparta, and Burdur. As it is known, the Covid-19 pandemic started in 2019, and therefore, data from 2018 were used in this study. The post-pandemic situation and its effect on livestock are the subjects of future studies. Information on the number of animals is given in Fig. 2. Each animal species was evaluated separately in its category. In the calculation of the manure amount, the data obtained from the farms of the relevant provinces were used for the live mass values according to the animal species and breed for each age group. In determining the daily amount of fresh manure, the percentage of live weight values was used, since a value that can represent Turkey, in general, is not available. These values were taken as 6% for cattle, 5% for small ruminants, and 4% for poultry. Using these values, the daily fresh manure values were calculated separately for each province according to the age and type of cattle and small ruminants, and poultry separately, and the total amount of manure was determined. The amount of animal manure varies according to feeding, climatic conditions, and reproduction type. Availability coefficient (AC) according to animal species has been taken as 50% for cattle, 13% for small ruminants, and 99% for poultry, respectively (Avcioǧlu and Türker 2012; Afazeli et al. 2014; Scarlat et al. 2015).

Fig. 2
figure 2

Distribution of the number of animals in the region

Details of the animal species are given in Tables 2, 3, and 4 (Dong et al. 2006). In these tables, VS, B0, MCF, MS (defined in Table 5) data used as parameters in CH4 calculation are also given. These parameters were used in the Tier 2 approach. Table 1 is a summary of Tables 2, 3, and 4 (Avcioǧlu and Türker 2012).

Table 1 Manure characteristics and biogas yields by animal breeds (Avcioǧlu and Türker 2012)
Table 2 Parameters and values used for cattle
Table 3 Parameters and values are used for small ruminants
Table 4 Parameters and values used for poultry

Figure 3 was used in the calculation of biogas production from manure (Scarlat et al. 2015; Abdeshahian et al. 2016; Khan et al. 2021; Şenol et al. 2021). Figure 3 also gives the standard coal, CO2 emission (Gao et al. 2019; Khalil et al. 2019), and the estimated electricity conversion (Scarlat et al. 2015; Benito et al. 2015; Khalil et al. 2019).

Fig. 3
figure 3

Biogas, coal, CO2 emissions, and electrical energy conversions from animal manure

If animal manure is not collected and processed in a biogas production system, CH4 gas is naturally produced and released into the atmosphere. Agriculture and livestock production has a significant impact on the formation of greenhouse gas emissions, especially CH4, into the atmosphere (Riaño and García-González 2015).

Different methods are used to calculate CH4 emissions. Tier 1 is the simplest approach in which just the number of each animal type and the emissions per animal are multiplied. The more advanced approach is Tier 2, which is used in most developed countries. It is the product of several parameters per animal species. The assumed emission factors based on average annual temperature are given by the IPCC for each of the proposed livestock categories. Emission factors represent the range in manure volatile solids content and manure management application of each region and were evaluated based on the annual temperature for each climatic region. The formula in Table 5 and the emission factors of the relevant regions in Table 10.11 of IPCC-2006 were used to calculate the CH4 emission with the Tier 1 approach. The formulas in Table 5 and the parameter values in Tables 2, 3, and 4 were used in the calculation with the Tier 2 approach (Dong et al. 2006; Vanderzaag et al. 2013; Baek et al. 2014; Noorollahi et al. 2015; Shin et al. 2016; Ngwabie et al. 2018; Chen et al. 2020; Herrera et al. 2021; Zubir et al. 2022; Basak et al. 2022).

Table 5 Formulas for CH4 emission (Tier 1, Tier 2 approximations) (Dong et al. 2006; Vanderzaag et al. 2013; Baek et al. 2014; Noorollahi et al. 2015; Shin et al. 2016; Ngwabie et al. 2018; Chen et al. 2020; Herrera et al. 2021; Zubir et al. 2022; Basak et al. 2022)

Machine learning algorithms and performance evaluations

In this study, the characteristics and theoretical calculations of cattle, small ruminants, and poultry belonging to the provinces of Antalya, Isparta, and Burdur in 2018 were used. Modeling of biogas amount, CO2 emission, coal, electricity-thermal energy, and CH4 values was carried out by using general and specific information about animals, age, number, and manure of animals. To determine the model with the best results, machine learning algorithms SVM, MLP, and LR were used and hyper-parameter optimization was performed. MLP can be adequately adapted to finite input–output mapping problems, does not require the consideration of the underlying probability density function, and presents the required decision function directly through the training process (Ghalandari et al. 2021; Shankar and Perumal 2021). SVM is often preferred as a machine learning algorithm because of its high generalization, ability to find globally optimal unique solutions, and emphasizing data in high-dimensional feature space (Vijay and Somayajula 2022). LR, on the other hand, was preferred because it has a simple structure and can outperform SVM and MLP in some problems (Javed et al. 2019). MLP, SVM, and LR were preferred in this study because of their popularity in the literature and for the reasons listed herewith.

The modeling mechanism of machine learning models for biogas amount, CO2 emission, coal, electricity-thermal energy, and CH4 values is shown in Fig. 4.

Fig. 4
figure 4

The model mechanism for biogas amount, CO2 emission, coal, electricity-thermal energy, and CH4 values

Figure 4 shows the model mechanism that will estimate the output values by using the general species information of animals, special species information of animals, animal age, animal live mass, number of animals, and the amount of manure according to the animal type, which constitutes the input parameters. Although each machine learning algorithm has different structures, it is seen that the most optimal hyperparameters of these structures can be determined by grid search. The model given in Fig. 4 is a feedforward MLP model using neurons (cells), in which cells multiply the values they receive from the previous cell with a certain weight and transmit the sum they have obtained to the next cell. In this way, the desired estimation values can be obtained from the output layer.

Matlab R2019a and PyCharm 2021.1 programs and scikit-learn 0.24 library were used for hyper-parameter optimizations and training of algorithms. Parameters of machine learning algorithms can greatly affect model success. For this reason, while determining the most suitable model for the related problem, training should be carried out with algorithms with appropriate optimum parameters. In this study, grid search was used to perform hyper-parameter optimization of machine learning algorithms. The grid search method creates a model for each determined combination of hyper-parameters and evaluates the performance so that the most optimal parameters of the relevant algorithm are determined (Pillai et al. 2019).

Support vector machine (SVM)

SVM is one of the most common machine learning algorithms and is used for both classification and regression problems (Smola and Schölkopf 2004). The SVM algorithm is a method based on pre-training, and it tries to create a linear or nonlinear kernel called a hyperplane to separate the classes of the data or to make a regression-based value estimation. In the literature on the SVM algorithm, kernels such as linear, polynomial, and radial basis functions (RBF) are used, and support vectors that can express the data most optimally are tried to be determined (Pisner and Schnyer 2020). v-SVM which is a different variant of SVM uses the nu parameter for controlling the number of support vectors for regression tasks.

Multi-layer perceptron (MLP)

MLP is a supervised learning algorithm that learns target values by training on the data it receives as input. MLP uses the input layer, hidden layer, and output layer for classification or regression. In the feedforward neural network structure, which is preferred in this study, the cells are arranged in layers, and the outputs of the cells in the layer can only be given as inputs to the next layer’s overweights (Goodfellow et al. 2016). The output value of the cells is calculated with activation functions such as sigmoid, hyperbolic tangent, and rectifier linear unit (ReLU) (Cui et al. 2017). For the training of the MLP model, algorithms such as scaled conjugate gradient, Levenberg–Marquardt, and Bayesian editing methods are available from backpropagation methods. In addition to these, L-BFGS-B, SGD (stochastic gradient descent) and adaptive moment estimation (Adam) methods have also achieved very good results in recent years. The SGD method provides gradient estimates using a specified number of samples from the data distribution. The Adam algorithm was created by increasing the momentum of the Rmsprop method (Goodfellow et al. 2016). L-BFGS-B is a gradient-based approach that has limited memory and is based on the trust region technique for solving large-scale optimization problems (Byrd et al. 1995).

Linear regression (LR)

LR allows the modeling of the output values by fitting a linear function to the input data. Regulation (regularization) is used in linear regression to solve the problem of multicollinearity and increase efficiency. Lasso regression (Least absolute shrinkage and selection operator), which is one of the frequently used regulation types, adds a penalty to the least-squares loss function by using the L1-norm penalty; Ridge regression, on the other hand, uses the L2-norm penalty to reduce the multicollinearity problem in linear regression that arises in models with many parameters (Tibshirani 1996). Ridge regression is seen in Eq. (1).

$$c={\left({X}^{T}X+\lambda \mathrm{I}\right)}^{-1}{X}^{T}y$$
(1)

In Eq. (1), y is the output, X is the Vandermonde matrix, I is the identity matrix, and the ridge parameter λ ≥ 0 serves as the constant shifting of the diagonals of the moment matrix (Khalaf and Shukur 2005). Elastic net, on the other hand, is another regulation technique and overcomes the limitations of the Lasso method by using a penalty function (Zou and Hastie 2005).

Grid search parameters

In this study, for SVM, one of the hyper-parameters determined for grid search; {SVM, v-SVM} as algorithm type, {Linear, 2–3-4 degrees Polynomial, RBF} as kernel, {0.25, 0.45, 0.65, 0.85, 1.0} as ε/ν parameters, and {100, 500, 1000} values were used as the number of iterations. For MLP, {L-BFGS-B, Sgd, Adam, Scg, Br, Lm} were used as the learning algorithm, {4, 8, 12, 16} as the number of hidden layer neurons, and {100, 500, 1000} as the number of iterations. For LR; {Ridge Regression, Lasso Regression, Elastic net, No regularization} methods including regularization or its variant were used. Other parameters that are not included in the grid search and are considered fixed are; Tolerance or learning rate of 0.005 was used in all algorithms with a cost (C) value of 1 for SVM and an activation function of ReLU in MLP. The hyper-parameter values according to the models and algorithms are shown in Table 6.

Table 6 Hyper-parameter values for models and algorithms

Performance metrics

In this study, performance metrics are needed to determine how successfully the biogas amount, CO2 emission, coal, electricity-thermal energy, and CH4 values obtained by theoretical calculations can be modeled with machine learning algorithms. Various metrics are used in the literature to measure the performance values of models trained with machine learning. Mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE), and coefficient of determination (R2) were used in this study to determine the best model. MSE, RMSE, MAE, and R2 formulas are given in (Eqs. (2)–(5)), respectively.

$$\mathrm{MSE}=\frac{1}{n}{\sum\limits}_{i=1}^{n}{\left({Y}_{i}-{\widehat{Y}}_{i}\right)}^{2}$$
(2)
$$\mathrm{RMSE}=\sqrt{\frac{1}{n}{\sum\limits}_{i=1}^{n}{\left({Y}_{i}-{\widehat{Y}}_{i}\right)}^{2}}$$
(3)
$$\mathrm{MAE}=\frac{1}{n}{\sum\limits}_{i=1}^{n}\left|{Y}_{i}-{\widehat{Y}}_{i}\right|$$
(4)

In Eqs. (24), Y is the target value, \(\widehat{Y}\) is the predicted value, and n is the number of samples.

$${R}^{2}=1-\frac{\sum_{i=1}^{n}{\left({Y}_{i}-{\widehat{Y}}_{i}\right)}^{2}}{\sum_{i=1}^{n}{\left({Y}_{i}-{\overline{Y} }_{i}\right)}^{2}}$$
(5)

In Eq. (5), Y represents the target value, \(\widehat{Y}\) is the predicted value, \(\overline{Y }\) is the mean of the target value, and n is the number of samples.

In this study, leave-one-out-cross-validation (LOOCV), which is used to separate training and test data, was used to obtain more statistically accurate values while measuring the performance of machine learning algorithms.

Results and discussion

In this study, SVM, MLP, and LR algorithms were used for the modeling of biogas, CO2 emission, coal, electric thermal energy, and CH4 amount. To determine the model with the best results and their parameters, hyper-parameter optimization was carried out with the grid search method. While MSE, RMSE, MAE, and R2 metrics were used to compare the success of the models, the Wilcoxon rank sum test was also used to compare the estimates and actual values. Table 7 shows the scores for the parameters that give the best performance as a result of the biogas amount modeling according to the grid search parameters with SVM.

Table 7 Best results with hyper-parameter optimization for SVM and MLP in biogas amount modeling

It is seen that the SVM method gives the best performance values with the v-svm algorithm, and the R2 value was obtained as 0.999 in the 4th and 2nd degrees polynomial. In the MLP model, the L-BFGS-B method as a learning algorithm was able to reach higher R2 values and lower MSE, RMSE, and MAE values compared to other learning methods. The best scores in the MLP model were determined with the parameters that the R2 = 0.997 after 1000 iterations of training using four hidden neurons with the L-BFGS-B method, and the R2 = 0.998 after 100 iterations of training using 12 hidden neurons. Table 8 shows the performance scores of the modeling of the biogas amount according to the grid search parameters with LR.

Table 8 Hyper-parameter optimization for LR in biogas amount

It is seen that in Table 8, the LR model generally gave good results for different parameter combinations. The highest R2 values of 0.995 were obtained for ridge regression and no regularization.

In Tables 7 and 8, considering the best values of the algorithms, two-parameter combinations from each algorithm were determined and used in other models. While determining the parameter combinations for MLP, two parameters with the same R2 values, one with the lowest RMSE value and the other with the lowest MAE value, were determined. The algorithms giving the best results and parameters are shown in Table 9.

Table 9 Algorithms with optimal parameters

Algorithms with the most suitable parameters for modeling biogas amount and statistical test results are shown in Table 10. Wilcoxon rank sum test results have been indicated with h, and its value has been expressed with p. Acceptance of the null test in the 5% confidence interval has been indicated with a “ + ” sign and rejection with a “ − ” sign.

Table 10 Modeling of biogas amount with algorithms with optimal parameters

The graphic of biogas modeling is seen in Fig. 5. The thick line in Fig. 5 shows the theoretical values obtained from the formulation in Fig. 3 and the thin lines show the modeling results. The biogas unit on the vertical axis is m3/year. Algorithms with the most suitable parameters determined after hyper-parameter optimization were used in modeling CO2 emissions, coal, electricity, thermal energy, and CH4 emissions. Algorithms with the most suitable parameters for CO2 emission modeling and statistical test results are shown in Table 11.

Fig. 5
figure 5

Comparison of the algorithms with the most suitable parameters and the biogas amount modeling with the original values

Table 11 Modeling of CO2 emissions with algorithms with the most suitable parameters

In Table 11, it is seen that the model and parameter values that give good results for biogas modeling can also successfully perform CO2 emission modeling. This shows that the hyper-parameter optimization has been carried out successfully, and the parameters for the related problem can be optimized. The graph of the CO2 emission modeling is seen in Fig. 6. The thick line shows the theoretical values obtained from the formulation in Fig. 3 and the thin lines show the modeling results. The CO2 emission on the vertical axis is ton/year.

Fig. 6
figure 6

Comparison of the algorithms with the most suitable parameters and CO2 emission models with the original values

Algorithms with the most suitable parameters for coal amount modeling and statistical test results are shown in Table 12.

Table 12 Coal amount modeling with algorithms with optimal parameters

In the modeling of coal amount, the LR method gives the highest R2 values with 0.997. In addition, as a result of the Wilcoxon rank sum test, the LR method obtained the highest statistical value with p = 1.0. The SVM method came to the fore in biogas amount and CO2 emission modeling, and the LR method gave better results in coal amount modeling. The graph of the coal amount modeling is seen in Fig. 7. The thick line shows the theoretical values obtained from the formulation in Fig. 3 and the thin lines show the modeling results. The coal amount on the vertical axis is ton/year.

Fig. 7
figure 7

Comparison of the algorithms with the most suitable parameters and the coal amount models with the original values

Algorithms with the most suitable parameters for electricity generation modeling and statistical test results are shown in Table 13.

Table 13 Electricity generation modeling with algorithms with optimal parameters

It is seen in Table 13 that SVM-v1 and SVM-v2 models give the highest R2 value of 0.999 for electricity generation modeling. It can be seen from the h values in Table 8 that the statistical test results of the models in which the SVM method is used are also accepted. The graph of the electricity generation modeling is seen in Fig. 8. The thick line shows the theoretical values obtained from the formulation in Fig. 3 and the thin lines show the modeling results. The electricity generation on the vertical axis is kWh/year.

Fig. 8
figure 8

Comparison of the algorithms with the most suitable parameters and the electricity generation models with the original values

Algorithms with the most suitable parameters for thermal energy modeling and statistical test results are shown in Table 14.

Table 14 Thermal energy modeling with algorithms with optimal parameters

In Table 14, SVM-v1 and SVM-v2 models give the highest R2 value of 0.999 for thermal energy modeling. The graphic of the thermal energy modeling is seen in Fig. 9. The thick line shows the theoretical values obtained from the formulation in Fig. 3 and the thin lines show the modeling results. The thermal energy on the vertical axis is MJ/year.

Fig. 9
figure 9

Comparison of the algorithms with the most suitable parameters and the thermal energy models with the original values

Algorithms with the most suitable parameters for methane emission (Tier 1 approximation) modeling and statistical test results are shown in Table 15

Table 15 CH4 emission (Tier 1) modeling with algorithms with optimal parameters

The SVM method achieved high MSE, RMSE, and MAE values and is not suitable for methane (Tier 1 approximation) modeling. The MLP-v1 algorithm gave the best modeling result with an R2 value of 0.977. The graph of the methane emission modeling is shown in Fig. 10. The thick line shows the theoretical values obtained from the formulation in Table 5. Thin lines show the modeling results. The CH4 emission on the vertical axis is ton CH4/year.

Fig. 10
figure 10

Comparison of algorithms with optimal parameters and CH4 emission (Tier 1 approximation) models with original values

Algorithms with the most suitable parameters for CH4 emission modeling (Tier 2 approximation) and statistical test results are shown in Table 16.

Table 16 CH4 emission (Tier 2) modeling with algorithms with optimal parameters

The SVM-v2 model achieved high MSE, RMSE, and MAE values and low R2 values. In addition, the statistical test result was rejected, and it is not suitable for the CH4 emission modeling obtained using the Tier 2 approach. The best modeling result was obtained by LR-v1 and LR-v2 algorithms with R2 values of 0.962. The graph of the CH4 emission modeling is seen in Fig. 11. The thick line shows the theoretical values obtained from the formulation in Table 5. Thin lines show the modeling results. CH4 emission on the vertical axis is ton CH4/year.

Fig. 11
figure 11

Comparison of CH4 emission models with the original values with algorithms with the most suitable parameters

According to the data from Turkstat (2018), there are a total of 3,883,307 animals belonging to different animal species (cattle, small ruminants, poultry) in the provinces of Antalya, Isparta, and Burdur. A total of 550,305 tons/year of animal manure can be obtained from this animal’s existence. As a result of the theoretical calculation, 130,929,541 m3/year of biogas can be produced from animal manure. Depending on biogas production; 93,484 tons/year of coal, 235,673,174 kWh/year of electrical energy, and 2,828,078,093 MJ/year of thermal energy can be provided. In addition, 153,653 tons/year of CO2 emissions will be prevented. As a result of hyperparameter optimization with grid search, SVM-v1, SVM-v2, MLP-v1, MLP-v2, and LR-v1, LR-v2 models were found to be successful. Although all models generally produce good results in the estimation of biogas potential, SVM-v1 and SVM-v2 are seen as the best model with R2 = 0.999. For the estimation of CO2 emission, SVM models produced the best results with R2 = 0.999. When the coal amount estimation is examined, it is seen that the LR-v1 and LR-v2 models produce slightly better results than SVM and MLP with R2 = 0.997 values. In terms of electricity production and thermal energy estimations, SVM models produced the best results with R2 = 0.999 values. In the estimation of methane using the Tier 1 approach, SVM models achieved the worst result compared to other models, while the MLP-v1 model can perform the best estimation with R2 = 0.977. In the methane modeling using the Tier 2 approach, the LR-v1 and LR-v2 models were superior to the other models, and these models reached the performance value of R2 = 0.962.

Conclusion

Turkey meets its energy needs from fossil fuels. It imports most of its energy from abroad. Facilities for the use of biomass resources in energy production are increasing in Turkey. New conversion facilities are also commissioned to use every year for environmentally friendly and clean energy production. Therefore, reliable energy potential estimates are needed. Agriculture and animal husbandry are carried out in every region of Turkey. The geographical location of the country is effective in the abundance of agriculture and animal husbandry, and animal husbandry is among the important sources of income, especially in rural areas. Livestock support packages consisting of many items are offered to animal enterprises. Some of these packages can be specified as feed support, milk support, and animal shelter support. Some of the most important problems of animal husbandry in Turkey are known animal breeding, animal health, and epidemic diseases.

This study focuses on biogas production from animal manure and its conversion to other energy sources to provide an efficient and reliable estimation of resource availability. The biogas potential and CO2 emission, coal, electrical energy, thermal energy, and CH4 emission that may occur according to cattle, small ruminant, and poultry data for 2018 in different categories and age groups of Antalya, Isparta, and Burdur predicted by machine learning algorithms. SVM, MLP, and LR methods from machine learning algorithms were used for estimation. The reasons for the preference of these algorithms are that they are popular in the literature, can be applied to problem solutions belonging to different fields, and are easy to understand. It is seen that machine learning algorithms are successful in modeling biogas, energy, and emission transformations. According to the results of the energy and emission modeling; the SVM-v1 model produces R2 = 0.999 value for CO2 emission, LR models produce R2 = 0.997 value for coal amount, and SVM models produce R2 = 0.999 value for electricity production and thermal energy estimations. For methane emission modeling with Tier 1 and Tier 2 approaches, MLP-v1 model produces R2 = 0.977 value, while LR models produce R2 = 0.962 value, respectively. It is seen that the SVM-v1 model is more successful than other models in energy and emission conversions, excluding methane emission, with performances in the range of R2 = 0.996–0.999. In the estimation of methane emissions, MLP-v1 and LR models were the models with the highest performance values.

There is no study in the literature on the biogas potential calculated according to different animal categories and age-related weight values in Turkey and the estimation of the energy and emission conversions of this potential. Coal, electrical energy, CO2 emissions, thermal energy, and CH4 conversions related to biogas were examined for the first time with machine learning algorithms, and six different prediction models were created and compared. Due to these features, the study carried out in a wide scope is very important for Turkey. Considering the use of biogas potential in the coming years, the share of renewable energy in total energy consumption in Turkey can be increased. This, in turn, may enable the country to reduce its energy imports. The models used in the study can be applied to different regions of Turkey for different or the same biomass sources. In future studies, energy and emission modeling will be carried out for the whole of Turkey, and the proposed models will also be used for modeling biogas production from organic residues, especially agricultural residues. In addition, the selection of possible biogas power plants and the post-pandemic situation and its impact on livestock are the subjects of future studies.