<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Functional Data Analysis for the Internet of Things in Streaming Analytics</title>
    <link>https://communities.sas.com/t5/Streaming-Analytics/Functional-Data-Analysis-for-the-Internet-of-Things/m-p/958680#M332</link>
    <description>&lt;H1&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;What is functional data?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P&gt;&lt;FONT size="4"&gt;We work with data that is typically represented as discrete measurements at specific points in time or space. An example shown below informs us that for each product/batch ID, we have readings available for variables &lt;EM&gt;x1&lt;/EM&gt; and &lt;EM&gt;x2&lt;/EM&gt;. &amp;nbsp;We can predict &lt;STRONG&gt;y&lt;/STRONG&gt; using the variables &lt;EM&gt;x1&lt;/EM&gt; and &lt;EM&gt;x2&lt;/EM&gt; at the ID level using supervised learning techniques.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table 1: Regular structured data" style="width: 373px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104473i65DB47A952A15670/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure1_blog.png" alt="Table 1: Regular structured data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Table 1: Regular structured data&lt;/span&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;What if we encounter a scenario where instead of discrete values, we are given continuous curves to predict the same target &lt;STRONG&gt;y&lt;/STRONG&gt;? In the table below, we have a scenario where &lt;EM&gt;x2&lt;/EM&gt; is replaced with continuous curves i.e. multiple measurements for &lt;EM&gt;x2&lt;/EM&gt; are available for each ID. These continuous curves could be a function of time or any other metric such as wavelength, voltage, etc. &amp;nbsp;&amp;nbsp;These types of data are called functional data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table 2: Functional data" style="width: 378px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104474i8623D701831125A5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure2_blog.png" alt="Table 2: Functional data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Table 2: Functional data&lt;/span&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The key difference between the two scenarios is that while regular data only provides snapshots at specific points, functional data captures the changes of a phenomena across a continuum. In this article we will investigate functional data analysis for IoT in SAS Viya.&lt;/FONT&gt;&lt;/P&gt;
&lt;H1&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;Where do we encounter functional data?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The simple answer is that functional data is encountered whenever measurements are recorded continuously over a domain rather than at isolated points. Consider an IoT use case in the semiconductor manufacturing industry where wafer analysis plays a critical role in ensuring high-quality chips and optimizing production processes. Functional Data Analysis (FDA) offers a powerful framework for examining continuous, high-dimensional data, making it particularly valuable in wafer inspection, metrology, and process control.&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="4"&gt;During semiconductor fabrication, wafers undergo multiple processes, including lithography, deposition, doping, metrology, etc. In the deposition process, sensors continuously record key metrics such as gas flow, temperature, heater modes, power monitors, and others throughout the operation, capturing their variations as continuous functions over time. FDA can leverage these functional inputs from the deposition step to predict wafer thickness during the subsequent metrology stage, enabling more accurate process optimization and defect detection.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Other areas of IoT where functional data occurs quite commonly (but not limited to) include:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;IoT-enabled wearables and medical devices collect real-time functional data on heart rate, blood pressure, glucose levels, oxygen level, etc. which enables early diagnosis of conditions and preventative care.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;In smart agriculture and precision farming, IoT sensors gather functional data on environmental elements such as soil, moisture, humidity, etc. which can be used to reduce resource consumption and improve yield.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;In supply chain and logistics optimization, IoT enabled trackers collect functional data on temperature, humidity, location, and handling conditions for cold chain monitoring in pharmaceutical and food supply chains.&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;H1&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;How do we analyze functional data?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The easiest way to work with functional data is perform summarization of the curves such as mean, min, median, max, etc. Additionally, we can summarize the shape of the curve itself such as slope, inflection point, and others. This however comes at the expense of throwing away a lot of the information from the original curves thereby losing temporal trends and inherent structure.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Available as part of SAS Viya 2024.11, functional principal component analysis (FPCA) is a technique appropriate for analyzing functional data. FPCA is an extension of Principal Component Analysis (PCA), a widely used dimensionality reduction technique. PCA identifies principal components—vectors that maximize variance along their direction—where each component captures a portion of the total variance in the data. FPCA, while conceptually similar, differs in that it operates on functions rather than vectors. Consequently, the principal components in FPCA are also functions or curves, reflecting the continuous nature of functional data. There are two &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_059/allprodsactions/actionsByName.htm" target="_blank"&gt;CAS actions&lt;/A&gt; available for SAS Viya users &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpca.htm" target="_blank"&gt;fPca&lt;/A&gt; and &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpcascore.htm" target="_blank"&gt;fPcaScore&lt;/A&gt;. Let’s understand how these CAS actions work on functional data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Consider a simple example where we have ten curves (&lt;EM&gt;x1, x2..., x10&lt;/EM&gt;) measured at equally spaced timestamps with their own intrinsic characteristic shape features represented in Fig 1 below.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Fig 1: Functional data represented by curves x1-x10" style="width: 624px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104475iCD3E9B5CC0291336/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure3_blog.png" alt="Fig 1: Functional data represented by curves x1-x10" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Fig 1: Functional data represented by curves x1-x10&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The CAS action &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpca.htm" target="_blank"&gt;fPca&lt;/A&gt; trains the data on the input curves such that every individual function/curve above can be reconstructed by a combination of the mean curve and the functional principal component scores along with the eigenfunctions that are generated by the code snippet below.&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;result = s.fPca(
    table={"name": "fpca_train_data"},
    output={"casout": {"name": "SCORE", "replace": True}, "npc": 2},
    eigenVec={"name": "EIGENVEC", "replace": True},
    eigenVal={"name": "EIGENVAL", "replace": True},
    saveState={"name": "trainStore", "replace": True}
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT size="4"&gt;In the above code ‘npc’ specifies the number of principal components which has been set to 2 in this case. The code produces four different output tables&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;“output” -contains the principal component scores of the training data&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;“eigenVal” – contains the eigenvalue matrix&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;“eigenVec” - contains the eigenvector matrix&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;&amp;nbsp;“saveState” – contains the state of eigenvector matrix for scoring&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Using the output tables, we can approximate the original curves from Fig 1 by using a combination of the mean function with the corresponding eigenfunctions and their respective principal component scores. Figure 2 below shows the reconstruction of the curves &lt;EM&gt;x1&lt;/EM&gt; and &lt;EM&gt;x10&lt;/EM&gt; using this technique.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Fig 2: Reconstruction of curves x1 and x10 using FPCA" style="width: 624px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104477i4B16FA485E02FDED/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure4_blog.png" alt="Fig 2: Reconstruction of curves x1 and x10 using FPCA" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Fig 2: Reconstruction of curves x1 and x10 using FPCA&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&lt;FONT size="4"&gt;The two eigenfunctions encapsulate the variability of all individual curves in two distinct directions, while the principal component scores quantify each curve's specific contribution to these eigenfunctions. Throughout this process, the mean function and eigenfunctions remain consistent across all curves, with differentiation arising from the principal component scores. This transformation reduces a function to a few key numerical values, simplifying its representation. For instance, the curve &lt;EM&gt;x1&lt;/EM&gt;​ can now be characterized solely by the scores &lt;EM&gt;PC_1 Score1&lt;/EM&gt; and &lt;EM&gt;PC_1Score2&lt;/EM&gt;.&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="4"&gt;Following this process, one can reconstruct all ten signals from Figure 1 as shown below.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Fig 3: Reconstruction of curves x1 through x10 using FPCA" style="width: 639px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104478i0CB9A4598FC87838/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure5_blog.png" alt="Fig 3: Reconstruction of curves x1 through x10 using FPCA" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Fig 3: Reconstruction of curves x1 through x10 using FPCA&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;An additional CAS action available for functional data analysis is &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpcascore.htm" target="_blank"&gt;fPcaScore&lt;/A&gt;. This&amp;nbsp;action scores new functional data based on eigenfunctions that are derived from a prior FPCA training analysis. The table saved from the “savestate” parameter in the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpca.htm" target="_blank"&gt;fPca&lt;/A&gt; CAS action needs to be invoked in this step.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Let’s go back to the original problem we posed at the beginning of the article that stems from working with data of the form below where instead of discrete values, we have continuous curves to predict the target &lt;STRONG&gt;y.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table 2: Functional Data" style="width: 378px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104479iDC12568BC0CA8430/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure2_blog.png" alt="Table 2: Functional Data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Table 2: Functional Data&lt;/span&gt;&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;We can now use &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpca.htm" target="_blank"&gt;fPca&lt;/A&gt; to represent the structural patterns of the curves within variable &lt;EM&gt;x2&lt;/EM&gt; by their functional principal components (2 components used) &amp;nbsp;and reformat the same dataset into the form below. These fpca scores combined with variable &lt;EM&gt;x1&lt;/EM&gt; can easily predict &lt;STRONG&gt;y&lt;/STRONG&gt; using any of the supervised learning techniques from SAS.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table 3: Representation of functional data using  fpca scores only" style="width: 535px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104480i66696B1051714B96/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure6_blog.png" alt="Table 3: Representation of functional data using  fpca scores only" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Table 3: Representation of functional data using  fpca scores only&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Functional Data Analysis (FDA) is critical in IoT because it provides a structured way to handle complex, continuous data streams efficiently. By leveraging FDA techniques, IoT systems can enhance accuracy, reduce storage costs, improve decision-making, and enable real-time monitoring—critical for the success of smart and connected technologies.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Feb 2025 17:25:44 GMT</pubDate>
    <dc:creator>Juthika</dc:creator>
    <dc:date>2025-02-07T17:25:44Z</dc:date>
    <item>
      <title>Functional Data Analysis for the Internet of Things</title>
      <link>https://communities.sas.com/t5/Streaming-Analytics/Functional-Data-Analysis-for-the-Internet-of-Things/m-p/958680#M332</link>
      <description>&lt;H1&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;What is functional data?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P&gt;&lt;FONT size="4"&gt;We work with data that is typically represented as discrete measurements at specific points in time or space. An example shown below informs us that for each product/batch ID, we have readings available for variables &lt;EM&gt;x1&lt;/EM&gt; and &lt;EM&gt;x2&lt;/EM&gt;. &amp;nbsp;We can predict &lt;STRONG&gt;y&lt;/STRONG&gt; using the variables &lt;EM&gt;x1&lt;/EM&gt; and &lt;EM&gt;x2&lt;/EM&gt; at the ID level using supervised learning techniques.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table 1: Regular structured data" style="width: 373px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104473i65DB47A952A15670/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure1_blog.png" alt="Table 1: Regular structured data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Table 1: Regular structured data&lt;/span&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;What if we encounter a scenario where instead of discrete values, we are given continuous curves to predict the same target &lt;STRONG&gt;y&lt;/STRONG&gt;? In the table below, we have a scenario where &lt;EM&gt;x2&lt;/EM&gt; is replaced with continuous curves i.e. multiple measurements for &lt;EM&gt;x2&lt;/EM&gt; are available for each ID. These continuous curves could be a function of time or any other metric such as wavelength, voltage, etc. &amp;nbsp;&amp;nbsp;These types of data are called functional data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table 2: Functional data" style="width: 378px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104474i8623D701831125A5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure2_blog.png" alt="Table 2: Functional data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Table 2: Functional data&lt;/span&gt;&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The key difference between the two scenarios is that while regular data only provides snapshots at specific points, functional data captures the changes of a phenomena across a continuum. In this article we will investigate functional data analysis for IoT in SAS Viya.&lt;/FONT&gt;&lt;/P&gt;
&lt;H1&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;Where do we encounter functional data?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The simple answer is that functional data is encountered whenever measurements are recorded continuously over a domain rather than at isolated points. Consider an IoT use case in the semiconductor manufacturing industry where wafer analysis plays a critical role in ensuring high-quality chips and optimizing production processes. Functional Data Analysis (FDA) offers a powerful framework for examining continuous, high-dimensional data, making it particularly valuable in wafer inspection, metrology, and process control.&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="4"&gt;During semiconductor fabrication, wafers undergo multiple processes, including lithography, deposition, doping, metrology, etc. In the deposition process, sensors continuously record key metrics such as gas flow, temperature, heater modes, power monitors, and others throughout the operation, capturing their variations as continuous functions over time. FDA can leverage these functional inputs from the deposition step to predict wafer thickness during the subsequent metrology stage, enabling more accurate process optimization and defect detection.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Other areas of IoT where functional data occurs quite commonly (but not limited to) include:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;IoT-enabled wearables and medical devices collect real-time functional data on heart rate, blood pressure, glucose levels, oxygen level, etc. which enables early diagnosis of conditions and preventative care.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;In smart agriculture and precision farming, IoT sensors gather functional data on environmental elements such as soil, moisture, humidity, etc. which can be used to reduce resource consumption and improve yield.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;In supply chain and logistics optimization, IoT enabled trackers collect functional data on temperature, humidity, location, and handling conditions for cold chain monitoring in pharmaceutical and food supply chains.&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;H1&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;How do we analyze functional data?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H1&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The easiest way to work with functional data is perform summarization of the curves such as mean, min, median, max, etc. Additionally, we can summarize the shape of the curve itself such as slope, inflection point, and others. This however comes at the expense of throwing away a lot of the information from the original curves thereby losing temporal trends and inherent structure.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Available as part of SAS Viya 2024.11, functional principal component analysis (FPCA) is a technique appropriate for analyzing functional data. FPCA is an extension of Principal Component Analysis (PCA), a widely used dimensionality reduction technique. PCA identifies principal components—vectors that maximize variance along their direction—where each component captures a portion of the total variance in the data. FPCA, while conceptually similar, differs in that it operates on functions rather than vectors. Consequently, the principal components in FPCA are also functions or curves, reflecting the continuous nature of functional data. There are two &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_059/allprodsactions/actionsByName.htm" target="_blank"&gt;CAS actions&lt;/A&gt; available for SAS Viya users &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpca.htm" target="_blank"&gt;fPca&lt;/A&gt; and &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpcascore.htm" target="_blank"&gt;fPcaScore&lt;/A&gt;. Let’s understand how these CAS actions work on functional data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Consider a simple example where we have ten curves (&lt;EM&gt;x1, x2..., x10&lt;/EM&gt;) measured at equally spaced timestamps with their own intrinsic characteristic shape features represented in Fig 1 below.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Fig 1: Functional data represented by curves x1-x10" style="width: 624px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104475iCD3E9B5CC0291336/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure3_blog.png" alt="Fig 1: Functional data represented by curves x1-x10" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Fig 1: Functional data represented by curves x1-x10&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;The CAS action &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpca.htm" target="_blank"&gt;fPca&lt;/A&gt; trains the data on the input curves such that every individual function/curve above can be reconstructed by a combination of the mean curve and the functional principal component scores along with the eigenfunctions that are generated by the code snippet below.&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;result = s.fPca(
    table={"name": "fpca_train_data"},
    output={"casout": {"name": "SCORE", "replace": True}, "npc": 2},
    eigenVec={"name": "EIGENVEC", "replace": True},
    eigenVal={"name": "EIGENVAL", "replace": True},
    saveState={"name": "trainStore", "replace": True}
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT size="4"&gt;In the above code ‘npc’ specifies the number of principal components which has been set to 2 in this case. The code produces four different output tables&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;“output” -contains the principal component scores of the training data&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;“eigenVal” – contains the eigenvalue matrix&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;“eigenVec” - contains the eigenvector matrix&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT size="4"&gt;&amp;nbsp;“saveState” – contains the state of eigenvector matrix for scoring&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Using the output tables, we can approximate the original curves from Fig 1 by using a combination of the mean function with the corresponding eigenfunctions and their respective principal component scores. Figure 2 below shows the reconstruction of the curves &lt;EM&gt;x1&lt;/EM&gt; and &lt;EM&gt;x10&lt;/EM&gt; using this technique.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Fig 2: Reconstruction of curves x1 and x10 using FPCA" style="width: 624px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104477i4B16FA485E02FDED/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure4_blog.png" alt="Fig 2: Reconstruction of curves x1 and x10 using FPCA" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Fig 2: Reconstruction of curves x1 and x10 using FPCA&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&lt;FONT size="4"&gt;The two eigenfunctions encapsulate the variability of all individual curves in two distinct directions, while the principal component scores quantify each curve's specific contribution to these eigenfunctions. Throughout this process, the mean function and eigenfunctions remain consistent across all curves, with differentiation arising from the principal component scores. This transformation reduces a function to a few key numerical values, simplifying its representation. For instance, the curve &lt;EM&gt;x1&lt;/EM&gt;​ can now be characterized solely by the scores &lt;EM&gt;PC_1 Score1&lt;/EM&gt; and &lt;EM&gt;PC_1Score2&lt;/EM&gt;.&amp;nbsp;&lt;/FONT&gt;&lt;FONT size="4"&gt;Following this process, one can reconstruct all ten signals from Figure 1 as shown below.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Fig 3: Reconstruction of curves x1 through x10 using FPCA" style="width: 639px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104478i0CB9A4598FC87838/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure5_blog.png" alt="Fig 3: Reconstruction of curves x1 through x10 using FPCA" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Fig 3: Reconstruction of curves x1 through x10 using FPCA&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;An additional CAS action available for functional data analysis is &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpcascore.htm" target="_blank"&gt;fPcaScore&lt;/A&gt;. This&amp;nbsp;action scores new functional data based on eigenfunctions that are derived from a prior FPCA training analysis. The table saved from the “savestate” parameter in the &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpca.htm" target="_blank"&gt;fPca&lt;/A&gt; CAS action needs to be invoked in this step.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Let’s go back to the original problem we posed at the beginning of the article that stems from working with data of the form below where instead of discrete values, we have continuous curves to predict the target &lt;STRONG&gt;y.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table 2: Functional Data" style="width: 378px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104479iDC12568BC0CA8430/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure2_blog.png" alt="Table 2: Functional Data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Table 2: Functional Data&lt;/span&gt;&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;We can now use &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_059/casactml/cas-fpca-fpca.htm" target="_blank"&gt;fPca&lt;/A&gt; to represent the structural patterns of the curves within variable &lt;EM&gt;x2&lt;/EM&gt; by their functional principal components (2 components used) &amp;nbsp;and reformat the same dataset into the form below. These fpca scores combined with variable &lt;EM&gt;x1&lt;/EM&gt; can easily predict &lt;STRONG&gt;y&lt;/STRONG&gt; using any of the supervised learning techniques from SAS.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table 3: Representation of functional data using  fpca scores only" style="width: 535px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104480i66696B1051714B96/image-size/large?v=v2&amp;amp;px=999" role="button" title="Figure6_blog.png" alt="Table 3: Representation of functional data using  fpca scores only" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Table 3: Representation of functional data using  fpca scores only&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Functional Data Analysis (FDA) is critical in IoT because it provides a structured way to handle complex, continuous data streams efficiently. By leveraging FDA techniques, IoT systems can enhance accuracy, reduce storage costs, improve decision-making, and enable real-time monitoring—critical for the success of smart and connected technologies.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 17:25:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Streaming-Analytics/Functional-Data-Analysis-for-the-Internet-of-Things/m-p/958680#M332</guid>
      <dc:creator>Juthika</dc:creator>
      <dc:date>2025-02-07T17:25:44Z</dc:date>
    </item>
  </channel>
</rss>

