Open access peer-reviewed chapter - ONLINE FIRST

Tracing the Local Breeds in an Outdoor System – A Hungarian Example with Mangalica Pig Breed

By Márta Alexy and Tomáš Horváth

Submitted: July 16th 2021Reviewed: November 13th 2021Published: January 6th 2022

DOI: 10.5772/intechopen.101615

Downloaded: 33


Pig farming is largely characterized by closed, large-scale housing technology. These systems are driven by resource efficiency. In intensive technologies, humans control almost completely. However, there are pig farming systems where humans have just little control. These free-range technologies are called organic pig farming systems in which the quality characteristics of the produced meat sold on a premium price are primary. We present the practical difficulties that are challenging in implementing precision pig farming. We characterize the data science methods that determine the reliability our conclusions. This chapter describes the literature on the behavior and production results of pigs, social aspects, and the possibilities of the certified pig meat supply chain. Digital solutions can be implemented to verify and trace the origin of meat products. In our project, Mangalica breeding sows were tagged with passive Radio Frequency Identification (RFID) tags, and a research zone was established at wallowing area. RFID readers record the presence of sows in this zone. In addition, temperature, humidity, and air pressure are recorded hourly for 24 hours a day. Data are analyzed using visualization and data science techniques. We present our interim results and conditions of the experiment in this chapter.


  • Mangalica
  • outdoor pig system
  • sow behavior
  • data science
  • IoT

1. Introduction

1.1 Livestock farming and digital solutions

It is an important fact that large-scale animal farming is a profit-oriented activity because the primary source of income for farmers is the sale of animal products. Therefore, digital technologies that are simple, easy to use and reliable, meet the real needs of the farmers and affordable and can be integrated into day-to-day tasks. In addition, the implementation of the right digital solution has an indirect, positive effect on the implementation of environmental regulations.

In agriculture, including animal production, everything is interconnected, and this complex system needs to be translated into the language of informatics: this requires data. It is also data that, on the one hand, represent the knowledge of the farmer and, on the other hand, have impact on production standards. However, after so far they have not directly appeared in practical decision-making. Third, the data are a valuable source from which hidden correlations may be revealed. Knowing these, more accurate and predictable decision support and recommendation systems can be developed.

IT is based on mathematics science; animal husbandry is based on biological and geographical features and diversity. The difference between these two areas is very significant, as is the way of thinking and attitudes of the professionals dealing with it. The data come from animal husbandry and must be prepared for IT for analysis. Many unforeseen and unpredictable factors affect the production level of pig farming that make it difficult for reliable data analysis models. Such factors include weather, emerging (epidemic) diseases, fluctuations in the market price of raw materials and products, etc. In these, prediction models can help.

1.2 The data and its analysis: a data science perspective

Deployed sensors are providing us with raw data in the form of recordings related to pre-specified measurements. Data can be of various forms such as time series (regularly measured numeric values), binary data (measured presence or absence of an entity), images, audio recordings, or texts (descriptions, news, etc.). Usually, time is an important aspect of the data, stating when the given measurements have happened.

To be able to derive meaningful insights from the collected and raw data, a data scientist needs to know about its context. Context can be briefly defined as any additional information, besides the raw data, which might have an impact on the data collection or the outcome of a data mining/analytics project. Context can be region-, farm-, or farmer-specific and is related to the semantics of the recorded data and the data collection process. Any contextual information can help in explaining various factors related to data quality such as how regional conditions (weather, light, sound conditions) influence the measurements, how reliable the provided data from the farmer are (granularity and precision of the provided information), how much information does the technical infrastructure of the farm (equipment, size, accessibility) allows to collect, etc.

Context should, however, not be confused with domain knowledge that is necessary for a successful outcome of any data mining project. While context might explain the circumstances of measurements, domain knowledge might explain the measurements itself and help to explain anomalies (certain abnormal measurements) as well as drive the data collecting process.

For such, close cooperation and communication between a data scientist and a farmer are required since the knowledge of both is required to achieve collecting good quality data.

1.2.1 Applicable data science methods

A data mining process can be or divided into the following steps: i) business understanding, ii) data understanding, iii) data preparation, iv) modeling, v) evaluation, and vi) deployment.

The goal of a data science project, from the data scientists’ point of view, can be driven by the following question: What purpose will the results of the project serve?

In case the goal is to provide alerts (i.e., “Something is happening”) and detect anomalies (e.g., “Certain animals show unusual behavior”), one should aim for the precision of the resulting machine learning models. On the other hand, if the goal is to uncover hidden patterns and gain deeper insights into the data (e.g., “Some animals are forming a group” or “some event triggers certain behavior”), one should aim for the interpretability of the resulting machine learning models. Of course, achieving a kind of a trade-off between interpretability and accuracy is desirable.

Most of the farmers are interested in social behavior of their animals; thus, we have been considering utilizing pattern mining techniques such as frequent item set and association rule mining approaches.

In case of frequent item sets, for regular time intervals, we consider each animal being present in the area of surveillance (where the RFID readers are installed) to be a kind of “item” in the given “transaction” (a certain time slot, e.g., an hour or half an hour). Also, weather conditions can be represented in various levels forming kinds of items such as “cold,” “not so cold,” “pleasant,” “warm,” “hot” temperature and added into the transactions (time slots) together with the animals present in the area. By specifying some thresholds for frequency of appearances, we could get so-called frequent item sets specifying which animals and weather conditions are appearing together frequently in the given area of interest (of course, weather conditions are the same also outside this area; however, the semantics of the item sets tells us which animals under which weather conditions and in what time intervals used to appear together).

Association rules are computed from frequent item sets and uncover some associations between the items within the item sets. These can be represented in the form of “if-then” rules specifying that if certain items appear together in an area of interest (including animals or weather conditions) and then also other items (animals or weather conditions) would most probably be present in that area as well. Here, a threshold for confidence of rules (the probability threshold that the antecedent implies the consequent of the rule) has to be set up besides the frequency threshold mentioned in case of item set mining.

These techniques result in interpretable results (item sets or rules) and are easy to understand for the farmer. Also, by playing around with the frequency and confidence thresholds, the farmer can specify the granularity of the patterns to be mined. Here, it is important to mention that a user-friendly application for pattern mining and pattern visualization is needed as well.


2. Practical data collection in pig farming systems

Data have long been collected by professionals working in the pig farm. As farming technologies became more intense and concentrated, effective production required information that could be used to plan the production of the animal product. These were mainly based on data that could be collected by humans. Date of first mating and culling, number of live and stillborn piglets, litter weight of live piglets, age and weight at weaning, useful life performance data for sows and males, etc. The economic indicators calculated from these reflect the performance of the pig farm.

The way pigs are kept largely determines how easily exact data can be collected. This is an important feature of data collection in the implementation of newer methods that already allow the application of digitization solutions. These can be effective if they are based on a database with as much data as possible. Although the average data are suitable for statistical analysis, correct conclusions can be drawn from them. However, the relationships and deeper correlations between the factors of production can be obtained in the case where the so-called traditionally, indirectly collected data are supplemented by nonhuman data collected from a direct source showing the individual performance of pigs.

Indirect data recorded during the production of pork can already be registered in farm management systems; we can make statements from it. However, a more accurate picture is obtained by supplementing this management system with data from direct sources.

These include data recorded by various sensors and cameras, a wide range of which can be used in pig farming. Data on pigs kept indoors can be collected relatively easily. Images and videos taken by cameras mounted above the pens, as well as sensors located in the room, reliably collect data. They are suitable for monitoring the health status of pigs kept in the barn, for estimating the individual weight of the animals, and for monitoring behavioral patterns. An important, human-controlled environment for IT is provided.

Large-scale, closed, and well-automated farm technologies have had data collected by sensors in the pig houses for years. These include external and internal temperature sensors, humidity, ammonia, air speed, and carbon dioxide meters for optimal operation of ventilation, heating, and cooling technology. Mention should be made of a sensor for the feeder filling system, which automatically starts and stops the feeder. Or sensors for indicating the amount of feed in the pig feeder, digital water consumption meters for measuring the amount of drinking water used in the barn or digital scales that can be mounted under the legs of the feed bins. The raw data collected by these devices are sent to the computers installed in the service room.

Although these provide direct data on production conditions, they are still one step away from precision production. The next step is the individual collection of data on pigs, which will allow precision monitoring of livestock.

There are ways of pig farming in which human influence is much less. These are semi-free and free-range systems in which data collection encounters several difficulties. Pigs are in a larger area, and other digital solutions need to be used to monitor their movement and individual behavior.


3. Conditions for data collection and processing in pig farming

When implementing a digital solution on a large-scale livestock farm, we need to do the same as when designing husbandry technology. The first step is on-site survey, accurate understanding of the farmer’s needs is the first step. Thereafter, the environmental conditions of large-scale animal husbandry should be considered when designing the devices. No matter how modern housing technology is and care for hygiene, there are technological features that greatly affect the operation and life span of deployable devices and thus their cost-effectiveness. Ammonia, dust, and the “work” of insects put the equipment under heavy strain.

Additionally, under semi-free and free-range conditions, the effects of weather and the placement of animals over a larger area further limit the range of data collection options that can be used. Animals-specific tools for individual data collection should also be chosen considering the ethological characteristics of the animal species. A collar with active RFID attached to the neck of grazed cattle is adequate; however, the same technology cannot be applied to pigs. In their case, only the sensor built into the ear tag can be considered. The size and design of the device are what really matter: the smaller the size, the better.

Therefore, pilot projects are important in which we can test and validate data collection technology. Systems tested over a long period of time will work reliably in practice, and an acceptable value for money for the farmer is also an important consideration.


4. Main characteristics of outdoor pig farming systems

4.1 Behavioral aspects

In outdoor systems, at a reduced level of supplementary feed, a higher frequency of rooting appears. These results suggest that it helps farmers in land cultivation and nutrient load. In fact, Andersen et al. [1] demonstrated that the rooting could replace a mechanical treatment and even result in a higher crop yield of the following crop. Laister and Konrad [2] investigated the following behavioral categories in intensive breeds of growing-finishing pigs in an outdoor system: feeding, drinking, exploring, resting, comfort behavior, locomotion, playing, agonistic and eliminative behavior. A significant difference was not found between behavior types of the three genotypes. On warm days, feral pigs rest at sunny places and clearings of a pine tree forest, whereas on hot days, the pigs search for cool and shadowy places in a high forest [3]. Pigs are exploratory animals, which spend a considerable amount of time moving between parts of the enclosure and examining distant and close habitats [4]. According to Ingold and Kunz [5], moist and wet places stimulate rooting. The most important patterns of comfort behavior in pigs are rubbing and wallowing, the latter fulfilling two purposes: On the one hand, the mud bath shall free the pigs from ectoparasites and itches, and on the other hand, it contributes to the animals’ thermoregulation [6]. In the paper of Johnson et al. [7], investigation on outdoor sows’ behavior showed that outdoor sows did behave more actively. While Johnson and McGlone [8] found that outdoor reared pigs spent more time walking and playing compared with indoor reared pigs.

4.2 Production performance aspects

Several researchers have examined whether different housing environments affect the reproductive and fattening performance of pigs. The genetic background for pigs in organic production in Sweden is the same as in conventional pig production [9]. In the organic herds, the total number of piglets born per litter and the number of piglets stillborn per litter were higher than in the conventional herds. Crushing of the piglets by the sow during the first days of life has been reported to be a more common cause of death in organic herds [10]. Longer nursing period in the organic system means a longer recovery period. It must be shown to be beneficial for reproductive performance. This might reflect larger variations among the organic herds in housing and management. Number of litters per sow was the lowest in the organic system, partly because of a longer weaning period and partly because of poorer reproduction results [11]. Larsen and Jorgensen [12] found that poor production results are not related to the fact that sows are kept outside but, probably, are related to the longer lactation period. Lindgren et al. [11] related the lower number of weaned piglets per litter to the opportunity for movement of the sows that result in inadequate nursing and weakening of the piglets as well as crushing by the sow. Growth performance: According to Danielsen et al. [13] organic feeding and access to outdoor run led to a higher proportion of ham muscles in the carcass. These results are much in line with the results of Miller et al. [14], who found that organic housing leads to a higher muscle and back fat thickness. In summer, a feed conversion comparable to indoor conditions has been obtained in some investigations of Sather et al. [15], whereas in other periods of the year or in other investigations, a higher feed consumption per kilogram gain has been reported [15, 16]. Hermansen [17] found a very interesting finding in the strategy with restricted intake in outdoor kept pigs under 80 kg live weight followed by ad libitum indoor. It resulted in a feed conversion rate comparable to indoor feeding, and overall daily gain was only reduced by 10–15% compared with ad libitum feed indoor. Laister and Kondrad [2] investigated behavior, performance, and carcass quality of growing-finishing pigs from three intensive breeds in outdoor circumstances. A significant difference was found between the performances of the three genotypes. Weissmann et al. [18] investigated performance, carcass, and meat quality of different pig genotypes in an extensive outdoor fattening system on grass clover in organic farming. They have been gathering data about daily weight gain, feed conversion ratio, and live weight loss. They calculated feed conversion ratio over all fattening pigs as the total amount of feed in relation to the total amount of body weight gain. Farke and Sundrum [19] investigated growth performance and carcass yield in outdoor fattening systems with grazing possibilities. Their results show that it is possible to obtain acceptable daily live-weight gains and carcass yields in organic pig production under free-range conditions. In their opinion, further studies are needed to estimate the amount of “herbage on demand” and feed intake of crops by the pigs under outdoor conditions. Growth performance of pigs in outdoor production systems can be largely affected by climatic conditions. Honeyman and Harmon [20] found that during the winter, the outdoor pigs require higher energy to keep warm than during the summer, resulting in a slower growth rate. Rodríguez-Estévez et al. [21] investigated average daily gain of Iberian fattening pigs when grazing natural resources. The traditional finishing system of the Iberian pig is linked to the “dehesa” (Quercus sp. open woodlands), to use the abundance of food provided by acorn ripening (called montanera), when pigs only eat grass and fallen acorns [22].

4.3 Social aspects

Rural areas in the New Member States are more dependent on agriculture as a source of income and employment, with opportunities for gainful employment in the non-farm rural economy relatively scarce [23]. To boost competitiveness and profitability, the EU seeks to stimulate enhanced value-added production, drawing on its reputation for quality goods [24]. One potential type of quality goods is Traditional Food Products (TFPs). A traditional food may be classified as: “a product… made accurately in a specific way according to the gastronomic heritage, … and known because of its sensory properties and associated with certain local areas, regions or countries” [25]. These goods generally possess positive images due to superior taste, nostalgia, and/or ethnocentrism [26, 27]. Balogh et al. [28] addresses this central question, building on recent advances in Willingness to Pay (WTP) methodologies, which are applied to an exemplary case of a TFP, namely the Hungarian Mangalica salami. Mangalica salami is an ideal product for exploring Willingness To Pay for a Traditional Food Products as the main motivation for its purchase in Hungary is its indigenous origin and heritage. In their opinion, Mangalica represents an ideal product for investigating consumer behavior relating to Traditional Food Products, as its appeal rests on its long, distinctive history and status as part of Hungary’s gastronomic heritage. The Mangalica breed does not possess any protected status at European level, but there is coordination at the domestic level via the National Association of Mangalica Breeders (NAMB). The NAMB certifies Mangalica pigs, officially guaranteeing the origin of genuine Mangalica products [28]. Certification is important for increasing the customer base as inexperienced consumers and those who have relatively weaker preferences for the good place greater emphasis on quality certification. Unfortunately, many quality labels possess inadequate regulatory systems [29], resulting from inexperience and limited resources. Thus, there is a consequent need to share experiences between successful TFPs, commanding substantial premiums and possessing robust regulatory systems, and those less well developed. In the case of Iberian pigs’ breeders, Iberian Acorn meat (specially ham) is a very demanded and well-considered TFP, and it is subject to very strict regulations to get quality certifications and category labels. The main parameters that are considered for this quality certification are breed and feeding, resulting in different categories depending on the purity of the breed and the way pigs are fed (only acorns, acorns and feedstock, or only feedstock).


5. IoT-monitoring system at field

To achieve high efficiency, productivity, and performance of a precision farm business, the IT infrastructure and IT services have to be robust and reliable. The state-of-the-art key issues along the complete data workflow, i.e., data collection, data storage, data analysis, and data visualization, can be found in the paper of Wolfert et al. [30]. At present, most of the systems of Ordoñez-García [31], Bhargava [32], Dholu [33] are conceptually designed into three layers: data collector, data analysis and processing, and presentation layer. As described in [33], sensors send data through a gateway to the cloud where it is processed and visualized for smartphones to access the agricultural parameter from everywhere. Through the powerful gateway/edge devices, more and more data are processed on premise. Edge Mining not only optimizes memory usage of the sensor device, but also builds a foundation for future real-time responsiveness of the prototype system in [32]. There are several specialized pig farm management systems, such as nedap, CLAAS, Cloudfarms or, but all of them do not monitor the welfare of an individual pig.


6. Certified pig-pork supply chain for the customer

The integration of chain partners in the innovation process enhances the capacity to innovate and reduces the risks involved in implementing innovation [35]. The agri-business sector is characterized by many small and medium-sized enterprises (SMEs) and as a low-tech industry. This applies for the traditional food sector. Only few studies are published that focus particularly on innovations in TFPs [36]. Feasible applications relate to improving the production process to assure quality and traceability [34]. For the successful introduction of innovations in TFPs, it is also important to have a good understanding of customers’ perceptions, expectations, and attitudes toward traditional food products and of consumers’ attitudes toward innovations in TFPs [37]. The pan-European consumer interpretation of the concept of TFPs in six European countries resulted in the following definition [25]: “A traditional food product is a product frequently consumed or associated with specific celebrations and/or seasons, normally transmitted from one generation to another, made accurately in a specific way according to the gastronomic heritage, with little or no processing/manipulation, distinguished and known because of its sensory properties and associated to a certain local area, region or country.” Current progress toward automated detection of health and welfare compromises indicates that the three categories of approaches to automation are emerging. The first category reports only on detecting behaviors using sensors (with RFID, video, or other sensors). The next category applies the detection method over time, records behavioral data, and presents these to staff for monitoring of potential problems, typically in graph form (e.g., on mobile phones). This enables identification of behavioral changes but requires farm staff to identify the change. The third category automatically analyzes the recorded behavior over time to detect behavioral changes and automatically sends alerts to staff advising them of behavioral changes and potentially identification of the compromise and rectification [38]. For the third category, the data analysis methods were capable of automatically detecting behavioral changes in drinking behavior from water flow sensors before diarrhea [39], in feeding visits and consumption with RFID feeding stations before tail biting [40] and movement activity from video before clinical signs of swine fever. According to Berckmans [41], Precision Livestock Farming is defined as: “the application of process engineering principles and techniques to livestock farming to automatically monitor, model and manage animal production” [42]. Demands for transparency of traceability of the products and the treatment practices of pigs are increasing from customers who want to be informed about the complete life cycle of the foot product displayed in a supermarket. In the past, in Europe, this problem was tackled by welfare labeling schemes (e.g., Denmark: DANISH; Netherland: Beter Leven; UK: Red Tractor; Germany: Tierwohl; etc.) that define regulations in each country. These labels stand for compliant farming processes, animal keeping, meat quality, etc. All these labels guarantee the compliance of all labeled products but lack the information about the product along the supply chain to the piglet. The EU strategy and many experts’ surveys, such as [43], are oriented toward considering the development of an instrument to better inform consumers and companies on animal welfare friendly products that could be used by both producers and retailers, ensuring transparency to consumers without overflowing them with information on the label. The blockchain technology is a promising approach to give transparency, such as who was the breeder, how the pig was kept, where the slaughterhouse was, etc. It protocols the pig-pork supply chain. All the important information is put into a blockchain to provide the information to all and everybody, anytime. A blockchain is a distributed, decentralized data structure that stores transactions transparently, chronologically, and unchangeably in a network. The key players in blockchain market include IBM, Microsoft, SAP-SE, Ambrosus (Switzerland), Arc-net (UK), OriginTrail, (US), VeChain (China), Provenance (UK), ChainVine (UK), AgriDigital and AgriChain (Australia). The French retailer Carrefour launched, in June 2018, a traceability project for its premium farm products. And Subway and Tyson are testing the FoodLogiQ ( blockchain traceability project. Like FoodLogiQ is TE-FOOD (, providing a farm to table fresh food traceability ecosystem on blockchain.

The practical application of the above is described in the next subsection as part of a pilot project.


7. A practical solution for individual monitoring of free-range pigs

In free-range systems, as in conventional, it is important to control the breeding and fattening performance and health of the animals. The practical method of collecting individual data requires other IT solutions.

We set the realization of this as the primary research goal. The individual observation of the pigs and the monitoring of their daily activity are studied in a free-range flock. The experiment group is Mangalica breeding sows, whose offspring are also fattened under extensive conditions in this fenced, nearly 7-hectare area.

We started our experiment in the summer of 2020, and it continues to this day. Data are continuously collected and analyzed. In this publication, we present the results of the first 8 months.

7.1 The Mangalica breed

The Mangalica is a native Hungarian pig breed. It is a fat-type, curly-haired swine with relatively low reproductive performance, but strong motherliness and good adaptability to extensive housing conditions. This breed nearly disappeared in the 1970s, since in some traits such as growth rate, feed conversion, reproductive performance, and meat/fat ratio it could not compete with the productivity of commercial white breeds, and its products did not suit the changing dietary habits after the Second World War [44]. Only 34 breeding sows were registered in the herd book in 1975. The race was rescued from extinction by state intervention. It was enacted to breed Mangalica in a gene reserve [45, 46]. After a long interruption, in 1994, the National Association of Mangalica Breeders resumed its activity and reorganized the registration of animals, introduced a certification of origin for every Mangalica product on the market. There is an obligatory blood control of breeding sows and boars. There are noteworthy populations of Mangalica in Switzerland, Germany, Austria, and some breeding animals are kept in Croatia, Serbia, and Romania as well [44].

7.2 The pilot project

The experiment started in July 2020, in a Mangalica breeding stock in northern Hungary. The total area of the pasture is 7 hectares, of which the Mangalica breeding sow population (Figure 1) is kept free on 2.5 hectares. In the remaining 4.5 hectares of the area, piglets of Mangalica sows are fattened, also in free-range technology. Our pilot experiment focuses on the observation of the Mangalica breeding stock. In the 2.5-hectare area, the extensive keeping technology consists of a tank drinker, a wooden feeder, wallowing area (Figure 2), and a wooden building for resting (Figure 3). The housing technology includes five more individual farrowing cottages. All housing technology elements are free to be used by sows. There are shady trees and shrubs in the pasture area, but almost 80% of the area is free land. Supplement feed is given to animals by human effort without automation. The sows destroyed the herbaceous vegetation, and the wallowing site was largely formed by themselves.

Figure 1.

Mangalica breeding sows on pasture.

Figure 2.

Experimental site at wallowing area with reader units.

Figure 3.

Wooden house for resting.

Figure 4.

Daily activity of sows at the wallowing site at each temperature value.

Figure 5.

Average activity during the autumn.

Figure 6.

Average activity during the summer.

Figure 7.

Average activity during the winter.

The average age of 50 breeding sows is 4 years. At the beginning of the experiment, 25 animals were tagged with an ear tag containing passive RFID chips and a monitoring zone was designated in the pasture area. This is a wallowing site often used by sows, to which we have mounted the four reading units on fence posts close to it. These record the appearance and departure of marked sows in the experimental zone. In addition, an installed weather station records temperature, relative humidity, and air pressure values on an hourly basis. The readers’ data and the weather parameters are transmitted to a server located at the Department of Data Science and Engineering, Faculty of Informatics, Eötvös Loránd University. Data analysis is evaluated and analyzed using data science and machine learning techniques, on the one hand, and visualized by various visualization methods, on the other.

7.2.1 Environment and weather effects on pig activity on pasture

Wallowing behavior is an important element in the well-being of pigs. They cover their bodies with mud, thus protecting them against parasites and heat. Complementing this fact, we came to an interesting finding. Examining the entire observation period, the activity data showed that sows were most likely to use the wallowing site when the temperature was in the range of 0 to +4° C (Figure 4). From this we concluded that this behavior also plays an important role in the general welfare of pigs.

Examining the daily activity of sows individually in the summer, autumn, and winter months, respectively, the finding in the literature [47], namely two peaks in the daily activity of pigs, were confirmed, one in the morning and one in the afternoon. The distance between these two peaks varies with day length. For shorter days (Figure 5), the second activity peak falls in the early afternoon, while for longer days, it falls in the late afternoon-early evening period. In the summer, the activity of the sows can be observed until 9 pm, in the winter it decreases to 5 pm (Figures 6 and 7).

7.2.2 Social behavior and ranking

Pigs are social animals, seeking each other’s company. They communicate with each other, recognize their peers, and a social ranking develops among the members of the group, which was determined. In our experiment, we could not determine the total social network between 50 sows because we could mark half of the herd as described above. However, by analyzing the social behavior of 25 sows, we also found interesting correlations.

Examining the activity of the five most active sows, we found that these animals appear simultaneously in the observation zone and largely leave it at the same time. Two to three hours later, another group of five sows appeared, who also spent nearly the same amount of time at the wallowing site. And two sows were in the observation zone independently of them, but also at nearly the same time. The different levels of activity of the sows are shown in the figure. Significant differences in activity between individuals were found in the observation zone.

7.2.3 Pattern mining results

Frequent item set and association rule mining algorithms are able to find numerous patterns depending on the settings of various thresholds for frequency and confidence of the found patterns, mentioned earlier. In the case of our data, depending also on the granularities of various intervals for time as well as weather measurements, there were many hundreds of item sets and association rules found, complete listing of which is out of the range of this chapter. Thus, we will just introduce patterns related to three pigs, numbered 7, 15, and 19, here found by the employed pattern mining techniques and introduced in Table 1 where the time intervals were set up to 3 hours, which means that all the pigs present in the area of RFID readers within the given time interval belong to one record, often called as “transaction.”

no.Antecedent (IF)Consequent (THEN)FrequencyConfidence
5Pig19, Pig15Pig70.1572050.594059
6Pig19, Pig7Pig150.1572050.697674
7Pig15, Pig7Pig190.1572050.676692
8Pig19Pig15, Pig70.1572050.351562
9Pig15Pig19, Pig70.1572050.323160
10Pig7Pig19, Pig150.1572050.427553
1106:00 h–08:59 hPig190.1039300.661111
1206:00 h–08:59 hPig150.1100440.700000

Table 1.

Found patterns related to pigs 7, 15, and 19.

Pigs 7 and 15 (rows 1 and 2 in Table 1) were present in 23.23% of transactions while pigs 7 and 19 (rows 3 and 4) were together less frequently, in 22.5% of transactions. Naturally, three pigs were together the least frequently in 15.72% of transactions, which is attributed to the so-called “monotonicity” of item sets. Interesting item sets are the last two which indicate that pigs 19 and 15 and the time intervals 6:00 h–8:59 h were appearing together in more than 10% of transactions. Given that each 8th transaction, i.e., 12.5% of all transactions, is related to this time interval (24 = 8x3 hours per day), it means that these two pigs were almost every day present in the given area from 6 am to 9 am.

Switching from item sets to rules, we can derive other interesting insights related to the ethology of pigs. The confidence of the rule “IF Pig15 is present THEN Pig7 is present as well” (row 1 in Table 1) is 0.477558, which can be interpreted as “In 47.76% of cases when pig 15 was present in the area also pig 7 was present there.” However, it seems that the other direction of this relationship is stronger, i.e., in 63.18% of cases pig 15 followed pig 7 (second row in Table 1) into the area. On the other hand, if pig 19 comes into the equation, then the relationships look different as can be seen in rows 5 and 10, respectively, of Table 1. Pigs 15 and 19 followed pig 7 in 42.76% of cases (row 10), while pig 7 followed these two in 59.41% of cases (row 5).

These are only illustrations of what types of patterns might be mined from the data. Of course, by setting up different thresholds and granularities, the resulting number and shape of patterns might change. Also, it is important to note that the concrete interpretations of these patterns might be also context-dependent and could be perceived subjectively by various farmers. With additional data about the pigs, we might be able to uncover the reasons for the appearance of these patterns as well.

Even if our research is only in its beginning, we think there are lots of possibilities utilizing pattern mining for uncovering social behavior of animals.

7.3 Future actions

We will continue our investigations, and during 2021 we will place additional reading units in the pasture area, near the rest area. Additional breeding sows are marked with an ear tag containing passive RFID. We further analyze the individual behavior of sows and the effect of weather on their daily activity.


8. Conclusions

The world’s pig technology is characterized by closed, intensive production systems. In addition to this type of farming, free-range pig production systems are also present, focusing on quality pork production instead of quantitative meat production. Monitoring meat production in these organic pig farming systems is equally important to strengthen consumer confidence. One possible solution for direct digital data collection is presented in this chapter. The conditions of data collection and possible methods of data analysis are described. The practical implementation of these is described in the framework of a pilot project in Hungary.



This paper and the research behind it would not have been possible without the support of Eotvos Lorand University, Faculty of Informatics.

“Application Domain Specific Highly Reliable IT Solutions” project has been implemented with the support provided from the National Research, Development and Innovation Fund of Hungary, financed under the Thematic Excellence Programme TKP2020-NKA-06 (National Challenges Subprogramme) funding scheme.

Special thanks to Róbert Lacko, a Hungarian private Mangalica farmer who can carry out the experiments on his farm and who provided us with his own pig herd.

Thanks to Simplexion Informatikai Kft for their cooperation, who provided the necessary tools for digital data collection and continuous consultation assistance.

We thank the president of the National Association of Mangalica Breeders, Mr. Péter Tóth, for his professional support.


Conflict of interest

The authors declare no conflict of interest.


chapter PDF

© 2022 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution 3.0 License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

How to cite and reference

Link to this chapter Copy to clipboard

Cite this chapter Copy to clipboard

Márta Alexy and Tomáš Horváth (January 6th 2022). Tracing the Local Breeds in an Outdoor System – A Hungarian Example with Mangalica Pig Breed [Online First], IntechOpen, DOI: 10.5772/intechopen.101615. Available from:

chapter statistics

33total chapter downloads

More statistics for editors and authors

Login to your personal dashboard for more detailed statistics on your publications.

Access personal reporting

We are IntechOpen, the world's leading publisher of Open Access books. Built by scientists, for scientists. Our readership spans scientists, professors, researchers, librarians, and students, as well as business professionals. We share our knowledge and peer-reveiwed research papers with libraries, scientific and engineering societies, and also work with corporate R&D departments and government entities.

More About Us