<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sena Ozgunay on Medium]]></title>
        <description><![CDATA[Stories by Sena Ozgunay on Medium]]></description>
        <link>https://medium.com/@senaozgunay?source=rss-9b8118249811------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-f86xJLRO_2RoOfNtZUeCg.jpeg</url>
            <title>Stories by Sena Ozgunay on Medium</title>
            <link>https://medium.com/@senaozgunay?source=rss-9b8118249811------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 14:16:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@senaozgunay/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Isolation Forest for Anomaly Detection]]></title>
            <link>https://medium.com/@senaozgunay/isolation-forest-for-anomaly-detection-4d7437b66c13?source=rss-9b8118249811------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d7437b66c13</guid>
            <category><![CDATA[binary-tree]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[isolation-forests]]></category>
            <category><![CDATA[anomaly-detection]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Sena Ozgunay]]></dc:creator>
            <pubDate>Mon, 27 Mar 2023 08:16:34 GMT</pubDate>
            <atom:updated>2023-03-27T08:16:34.317Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CItMEDowfmOnP7GHYLyLow.jpeg" /></figure><p>Isolation is separating one or more specific observations in the entire dataset which is done by successive splits of the dataset. In anomaly detection, we want to identify or isolate abnormal data that behave differently from the majority. In this context, there exists a method widely used: Isolation Forest.</p><h4><strong>What is Isolation Forest?</strong></h4><p>Isolation Forest or shortly IForest is an unsupervised learning method used in anomaly detection. It uses the principle that anomalies are rare and distinct, so they are easier to identify.</p><h4>How does it work?</h4><p>IForest is based on splitting the feature space to detect anomalies. Indeed, it works similarly to the decision tree algorithm. In decision trees, the splitting is based on the information gained, whereas in the IForest, it is randomized.</p><p>IForest builds trees by randomly choosing a random split value between the minimum and maximum values of a feature randomly chosen from the given set of features. The splittings continue until all the observations are isolated or the specified number of limit splitting is reached.</p><p>In fact, this random splitting of features produces shorter paths in the trees for anomalous observations, thus separating them from the rest of the data. Anomalies require less splitting because the density around them is low.</p><p>The main idea of IForest for anomaly detection is to compute an anomaly score for each observation of the dataset and then compare these scores in a second step to isolate the anomalies. Note that for each observation, distinct scores will be calculated for each tree in the forest.</p><p>The model uses two input parameters to calculate the anomaly score:</p><ul><li>ψ: the sample size randomly selected from the entire dataset.</li><li><em>t</em>: the number of trees in the forest.</li></ul><p>Anomaly detection with IForest has two main steps:</p><p>1. Training step which involves constructing the forest.</p><p>2. Scoring step in which the anomaly score of every data observation is calculated.</p><p><strong>Training Step:</strong></p><p>It is based on the construction of a forest of random and independent binary trees which are called an isolation tree<em> (iTree)</em>.</p><p>The construction of an <em>iTree</em> is made by the following substeps:</p><ul><li>IForest chooses randomly a subset of ψ observations which set up a sample for the construction of an <em>iTree</em>. Note that each sample is used for only one <em>iTree</em>.</li><li>Initially, the root node contains all the observations of the sample. To split a node<em> i</em>, IForest randomly chooses a feature <em>fᵢ. </em>Then, the split value <em>vᵢ</em> is also randomly selected between <em>min(fᵢ) </em>and <em>max(fᵢ)</em>. The elements of node <em>i</em> are then split into two groups (left and right) by comparing their values to <em>vᵢ. </em>This continues until all sample observations are isolated or the tree reaches its maximum depth which is equal to log₂(ψ).</li></ul><p>To construct<em> t </em>trees of the forest, these substeps are repeated <em>t </em>times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*g5oHmxRgof5BvR0D7YhbyA.png" /><figcaption>An example of isolating an anomalous point in 2D. Source: <a href="https://en.wikipedia.org/wiki/Isolation_forest">wiki</a>.</figcaption></figure><p><strong>Scoring Step:</strong></p><ul><li>During this phase, a score for every data observation is calculated. This score represents the degree of aberrance of the data point.</li><li>Let <em>x </em>be an observation<em>. </em>To compute its anomaly score <em>x</em> has to visit each <em>iTree</em> of the forest. <em>x</em> will certainly fail in an external node of each tree, depending on the splitting criteria. The number of edges the data observation has passed through from the root node to reach its external node is called the path length of <em>x</em> and is denoted<em> h(x).</em></li><li>Once <em>x</em> has been passed through all the trees of the forest, IForest computes the average length of the <em>t</em> paths of <em>x</em> noted <em>E(h(x))</em>.</li><li>The anomaly score can be calculated as follows</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*Wo48Tg9c13ehyb_AD7DCUQ.png" /></figure><p>where</p><p><em>n</em> is the number of data observations,</p><p><em>C(n) = 2H(n-1) — (2(n-1)/n)</em> is the average length of the <em>t</em> paths of an unsuccessful search in a <a href="https://en.wikipedia.org/wiki/Binary_search_tree">binary search tree</a> and</p><p><em>H(x)= ln(x) + 0.5772156649</em> (<em>Euler constant</em>).</p><p>The approximation of the average length is made by using <em>C(n)</em> since the trees are similar to <a href="https://en.wikipedia.org/wiki/Binary_search_tree">binary search trees</a>. Note that <em>C(n)</em> is used to normalize the score between<em> 0 </em>and <em>1 </em>to evaluate it as a probability.</p><ul><li>When <em>E(h(x))</em> tends to <em>C(n)</em>, <em>s </em>tends to 0.5. A score of <em>s</em> ≈ 0.5 means that there is a 50% chance the observation is an anomaly. So there is no significant distinction from normal observations. If all the observations have this score then the dataset does not contain any identifiable anomalies.</li><li>When <em>E(h(x))</em> tends to 0, <em>s</em> tends to 1. If an observation has a score <em>s</em> very close to 1, then it is an anomaly.</li><li>When <em>E(h(x))</em> tends to <em>n-1</em>, <em>s </em>tends to 0. If an observation has a score <em>s</em> very smaller than 0.5, then it is normal.</li></ul><p>Before seeing a real-life example, as you know, anomaly detection is used in various areas such that</p><ul><li>fraud detection in the banking and finance sector by identifying suspicious activities and transactions,</li><li>failure detection in manufacturing by identifying abnormal behavior of machines,</li><li>intrusion detection into networks by identifying sudden changes in network traffic that may be due to cyber-attacks or other unauthorized access.</li></ul><h4>Python example 1</h4><p>Now, let’s start with our first example. We want to detect the anomalies in <a href="https://drive.google.com/file/d/1tI7DOx57sF1MwhNGTyx9IImKX-pxqm9S/view?usp=sharing">New York Taxi dataset </a>in which the observations are time series. If you don’t know much about time series, you can check <a href="https://www.analyticsvidhya.com/blog/2021/10/a-comprehensive-guide-to-time-series-analysis/">here</a>.</p><p>This dataset shows the number of taxi rides in 30-minute intervals for six months from July 2014 to February 2015.</p><p>First, we import the libraries.</p><pre>import pandas as pd<br>import numpy as np<br>from datetime import datetime<br>from sklearn.ensemble import IsolationForest<br>import matplotlib as mpl<br>import matplotlib.pyplot as plt<br>import plotly.express as px<br><br>import holoviews as hv<br>from holoviews import opts<br>hv.extension(&#39;bokeh&#39;)<br>from bokeh.models import HoverTool<br>from IPython.display import HTML, display</pre><p>We read the data and see it.</p><pre>df = pd.read_csv(&#39;taxi_rides.csv&#39;)<br>(df.head(10)<br>.style<br>.set_caption(&#39;New York City Taxi Demand&#39;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*MgwtBozEMT49lmwPjD4o2A.png" /><figcaption>New York City Taxi Rides</figcaption></figure><p>The <strong>timestamp</strong> column shows the time of recording. The <strong>value </strong>column indicates the number of taxi rides.</p><pre>df.info()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*EA7HNwVTZ3LJe0ww4V7EiA.png" /><figcaption>Data information</figcaption></figure><p>The dataset has 10320 taxi rides records and 2 variables. As we see here, the <strong>timestamp </strong>column is in the type object. We need to convert it to the DateTime format to perform easily time-series analysis.</p><pre>df[&#39;timestamp&#39;]=pd.to_datetime(df[&#39;timestamp&#39;])<br>df.info()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*Hp6npSn8yBzwLkjoaD6FlA.png" /></figure><p>Now, we want to make a time-series analysis within hourly intervals. This way, we will be able to visualize all the records belong these intervals. To do this, we resample the dataset and aggregate it to hourly intervals.</p><pre>df=df.set_index(&#39;timestamp&#39;).resample(&quot;H&quot;).mean().reset_index()<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*ruK89cenia1xSWXhFDl1Lg.png" /></figure><p>Now, let’s see visually taxi rides hourly, daily, and weekly.</p><pre>hourly = hv.Curve(df.set_index(&#39;timestamp&#39;).resample(&#39;H&#39;).mean()).opts(<br>    opts.Curve(title=&quot;New York City Taxi Demand Hourly&quot;, xlabel=&quot;&quot;, ylabel=&quot;Demand&quot;,<br>               width=700, height=300,tools=[&#39;hover&#39;],show_grid=True))<br><br>daily = hv.Curve(df.set_index(&#39;timestamp&#39;).resample(&#39;D&#39;).mean()).opts(<br>    opts.Curve(title=&quot;New York City Taxi Demand Daily&quot;, xlabel=&quot;&quot;, ylabel=&quot;Demand&quot;,<br>               width=700, height=300,tools=[&#39;hover&#39;],show_grid=True))<br><br>weekly = hv.Curve(df.set_index(&#39;timestamp&#39;).resample(&#39;W&#39;).mean()).opts(<br>    opts.Curve(title=&quot;New York City Taxi Demand Weekly&quot;, xlabel=&quot;Date&quot;, ylabel=&quot;Demand&quot;,<br>               width=700, height=300,tools=[&#39;hover&#39;],show_grid=True))<br><br><br>(hourly + daily + weekly).opts(shared_axes=False).cols(1)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*5d2RFtje9BSDuGnPjops7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*DgXMDWAYTLCLftU0jOkhcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*-pRKadli3qvRma8jTP93IQ.png" /><figcaption>Visualizations of taxi rides by hour, day, and week.</figcaption></figure><p>We want to add two new columns ‘<strong>hour</strong> ’ and <strong>‘weekday’ </strong>to be extracted from the <strong>timestamp </strong>column to make easier our time-series analysis and to have more details about outliers to be determined by IForest implementation.</p><pre>df[&#39;hour&#39;]=df.timestamp.dt.hour<br>df[&#39;weekday&#39;]=pd.Categorical(df.timestamp.dt.strftime(&#39;%A&#39;), categories=[&#39;Monday&#39;,&#39;Tuesday&#39;,&#39;Wednesday&#39;,&#39;Thursday&#39;,&#39;Friday&#39;,&#39;Saturday&#39;, &#39;Sunday&#39;], ordered=True)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*0Kkzrb2gwtF4xzfYmKJZbw.png" /></figure><p>Our goal is to detect abnormal taxi rides. It will correspond to the <strong>‘value’</strong> column. Let’s make some more visualization for this variable.</p><pre>(hv.Distribution(df[&#39;value&#39;])<br>.opts(opts.Distribution(title=&quot;Value Distribution&quot;,<br>                        xlabel=&quot;Value&quot;,<br>                        ylabel=&quot;Density&quot;,<br>                        width=700, height=300,<br>                        tools=[&#39;hover&#39;],show_grid=True)))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*JL5WBoMDK1vbaOrFhYBsag.png" /><figcaption>The distribution of the number of taxi rides.</figcaption></figure><pre>df[[&#39;value&#39;,&#39;weekday&#39;]].groupby(&#39;weekday&#39;).mean().plot()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*dFXlY5EHTVqVjaQ_l7vDkw.png" /><figcaption>The number of taxi rides recorded during each day.</figcaption></figure><pre>df[[&#39;value&#39;,&#39;hour&#39;]].groupby(&#39;hour&#39;).mean().plot()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*FoJGjnlZrTcZE3lCs6ufsg.png" /><figcaption>The number of taxi rides recorded during each hour of the day.</figcaption></figure><p>Let’s see a general visualization of taxi rides records by time series.</p><pre>fig = px.line(df.reset_index(), x=&#39;timestamp&#39;, y=&#39;value&#39;, title=&#39;TAXI RIDES&#39;,template = &#39;plotly_dark&#39;)<br>fig.update_xaxes(<br>    rangeslider_visible=True,<br>)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4C1HmdkI_WXdv2LgqEuvjA.png" /></figure><p>Now we can construct our Isolation Forest model to detect anomalies in taxi rides.</p><p>Isolation Forest can be used by importing <em>IsolationForest </em>from <em>sklearn.ensemble</em> library. <em>IsolationForest </em>has some important parameters such as:</p><ul><li>‘<strong>n_estimators’: </strong>The number of base estimators in the dataset i.e. the number of trees to use in the construction of the forest.</li><li><strong>‘max_samples’: </strong>The number of samples drawn from the dataset to train each tree.</li><li><strong>‘max_features’:</strong> Number of features to train each tree.</li><li><strong>‘contamination’:</strong> The proportion of outliers in the data set.</li></ul><p>For more information about all the parameters and attributes of <em>IsolationForest,</em> you can see <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.IsolationForest.html">scikit-learn</a>.</p><p>We initialize and fit data.</p><pre>iforest =  IsolationForest(contamination=0.004).fit(df[[&#39;value&#39;]])</pre><p>Now, we can make predictions.</p><pre>if_pred = iforest.predict(df[[&#39;value&#39;]])</pre><p>The predict function returns 1 or -1 where -1 corresponds to anomalies in our dataset. We can detect the anomalies and save them in a new column in the dataset as follows</p><pre>df[&#39;outliers&#39;]=pd.Series(if_pred).apply(lambda x: &#39;yes&#39; if (x == -1) else &#39;no&#39; )</pre><p>We can now show all the anomalies in the dataset.</p><pre>df.query(&#39;outliers==&quot;yes&quot;&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*Sxt1bBFA5Y4_p_QapcFisQ.png" /><figcaption>The outliers in the taxi rides dataset.</figcaption></figure><p>We can show them in the following line chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xsqZTIpIVeEcyRdUCFGSSg.png" /><figcaption>The number of taxi rides.</figcaption></figure><p>In the line chart above, blue points represent the normal data while orange ones are the outliers.</p><h4>Python example 2</h4><p>In this example, we will study industrial machine anomaly detection.</p><p>For this, we will use a dataset about machine temperature and system failure from <a href="https://www.kaggle.com/datasets/boltzmannbrain/nab?resource=download-directory&amp;select=realKnownCause">Numenta Anomaly Benchmark(NAB)</a>.</p><p>We have the following information about our dataset:</p><ul><li>It consists of temperature sensor data of an internal component of a large, industrial machine.</li><li>The first anomaly is a planned shutdown of the machine.</li><li>The second anomaly is difficult to detect and directly led to the third anomaly, a catastrophic failure of the machine.</li></ul><p>We start by importing libraries.</p><pre>import numpy as np<br>import pandas as pd<br>from datetime import datetime<br>import holoviews as hv<br>from holoviews import opts<br>hv.extension(&#39;bokeh&#39;)<br>from matplotlib import pyplot as plt<br>from sklearn.ensemble import IsolationForest<br>import plotly.express as px<br>from IPython.display import HTML, display</pre><p>We read and see the data.</p><pre>df = pd.read_csv(&quot;machine_temperature_system_failure.csv&quot;)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*-Fg1DD2tx5kE9f7ppRXMFw.png" /></figure><p>We convert the <strong>timestamp </strong>column to <em>DateTime</em> format.</p><pre>df[&#39;timestamp&#39;] = pd.to_datetime(df[&#39;timestamp&#39;])</pre><p>We can extract important values from the <strong>timestamp </strong>column.</p><pre>df[&#39;year&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.year)<br>df[&#39;month&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.month)<br>df[&#39;day&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.day)<br>df[&#39;hour&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.hour)<br>df[&#39;minute&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.minute)<br>df.index = df[&#39;timestamp&#39;]<br>df.drop([&#39;timestamp&#39;], axis=1, inplace=True)<br>df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*bUKNus8wYTY3jcrpcgIfZQ.png" /></figure><p>Now let’s make some visualizations to understand our dataset better.</p><pre>Hourly = hv.Curve(df.set_index(&#39;timestamp&#39;).resample(&#39;H&#39;).mean()).opts(<br>    opts.Curve(title=&quot;Hourly Temperature of The Machine&quot;, xlabel=&quot;&quot;, ylabel=&quot;Demand&quot;,<br>               width=700, height=300,tools=[&#39;hover&#39;],show_grid=True))<br><br>Daily = hv.Curve(df.set_index(&#39;timestamp&#39;).resample(&#39;D&#39;).mean()).opts(<br>    opts.Curve(title=&quot;Daily Temperature of The Machine&quot;, xlabel=&quot;&quot;, ylabel=&quot;Demand&quot;,<br>               width=700, height=300,tools=[&#39;hover&#39;],show_grid=True))<br><br><br>(Hourly + Daily).opts(shared_axes=False).cols(1)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*P3VQ4du7U6RXYLn_Nmm_Fg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*u3zY4tpNnf9JX9x7CzJ5YA.png" /></figure><pre>df[&#39;year&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.year)<br>df[&#39;month&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.month)<br>df[&#39;day&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.day)<br>df[&#39;hour&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.hour)<br>df[&#39;minute&#39;] = df[&#39;timestamp&#39;].apply(lambda x : x.minute)<br>df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*dIjbbpqEFeE8NzjH39SQBA.png" /></figure><p>Now let’s see some distribution histograms of temperature values.</p><pre>(hv.Distribution(df[&#39;value&#39;])<br>.opts(opts.Distribution(title=&quot;Temperature Distribution&quot;,<br>                        xlabel=&quot;Value&quot;,<br>                        ylabel=&quot;Density&quot;,<br>                        width=700, height=300,<br>                        tools=[&#39;hover&#39;],show_grid=True)))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*KxCAwCgMMG6YFUlfrcvqpQ.png" /></figure><pre>((hv.Distribution(df.loc[df[&#39;year&#39;]==2013,&#39;value&#39;], label=&#39;2013&#39;) * hv.Distribution(df.loc[df[&#39;year&#39;]==2014,&#39;value&#39;], label=&#39;2014&#39;)).opts(title=&quot;Temperature by Year&quot;, legend_position=&#39;bottom&#39;) + \<br>(hv.Distribution(df.loc[df[&#39;month&#39;]==12,&#39;value&#39;], label=&#39;12&#39;) * hv.Distribution(df.loc[df[&#39;month&#39;]==1,&#39;value&#39;], label=&#39;1&#39;) \<br>     * hv.Distribution(df.loc[df[&#39;month&#39;]==2,&#39;value&#39;], label=&#39;2&#39;)).opts(title=&quot;Temperature by Month&quot;, legend_position=&#39;bottom&#39;)) \<br>     .opts(opts.Distribution(xlabel=&quot;Temperature&quot;, ylabel=&quot;Density&quot;, width=380, height=300,tools=[&#39;hover&#39;],show_grid=True))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*El7U_uA6TRTksrzgqCdM_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*0HBAKPFQPQqqjzH7eU_Y1g.png" /><figcaption>Temperature distribution by month and year.</figcaption></figure><p>Model fitting and prediction:</p><pre>iforest =  IsolationForest(contamination=0.05).fit(df[[&#39;value&#39;]])<br>if_pred = iforest.predict(df[[&#39;value&#39;]])<br>df[&#39;outliers&#39;]=pd.Series(if_pred).apply(lambda x: &#39;yes&#39; if (x == -1) else &#39;no&#39; )<br>df.query(&#39;outliers==&quot;yes&quot;&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*WVBhVm4mF2y6m98kgtLoPQ.png" /></figure><p>We visualize the anomalies.</p><pre>fig = px.scatter(df.reset_index(), x=&#39;timestamp&#39;, y=&#39;value&#39;, color=&#39;outliers&#39;, hover_data=[&#39;day&#39;], title=&#39;Temperature Anomalies&#39;)<br>fig.update_xaxes(<br>    rangeslider_visible=True,<br>)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*BDPzqN3AkUkygj_TF6fwdw.png" /></figure><h4>Limites of IForest</h4><ul><li>In the IForest algorithm, there is no precise and fixed <strong>threshold </strong>at which the data should be considered abnormal. That’s why, finding the right threshold value for the data may take time.</li><li><strong>Swamping</strong>: If there exists a very small difference between normal instances and anomalies, the number of splits required to separate anomalies increases, so it’s more difficult for iForest to discriminate between anomalies and normal instances.</li><li><strong>Masking</strong>: If there are a huge number of anomalies hiding their own presence, they may be grouped in a dense and large cluster which makes it more difficult to isolate and detect them as anomalies.</li><li><strong>High dimensionality: </strong>If the instances are of too high dimensions, in their high dimensional space they are sparse, so using a distance-based measure of separation may be really ineffective.</li></ul><h4><strong>Summary</strong></h4><p>Isolation forest is an unsupervised technique for anomaly detection that is based on the isolation of anomalies from the construction of multiple random binary trees.</p><p>Depending on the data, IForest may perform better and faster in comparison to other anomaly detection methods such as <a href="https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.LocalOutlierFactor.html">Local Outlier Factor</a> or <a href="https://medium.com/@senaozgunay/one-class-support-vector-machine-for-anomaly-detection-c999fefcafb3">OC-SVM</a>.</p><h4>References</h4><ul><li><a href="https://theses.hal.science/tel-03966951/document">https://theses.hal.science/tel-03966951/document</a></li><li><a href="https://hal.science/hal-03765550/file/RJCIA22_paper16.pdf">https://hal.science/hal-03765550/file/RJCIA22_paper16.pdf</a></li><li><a href="https://www.analyticsvidhya.com/blog/2021/07/anomaly-detection-using-isolation-forest-a-complete-guide/">https://www.analyticsvidhya.com/blog/2021/07/anomaly-detection-using-isolation-forest-a-complete-guide/</a></li><li><a href="https://www.lama.univ-savoie.fr/mediawiki/index.php/D%C3%A9tection_d%E2%80%99anomalies_par_Isolation_Forest_:_application_pour_l%E2%80%99industrie_4.0">https://www.lama.univ-savoie.fr/mediawiki/index.php/D%C3%A9tection_d%E2%80%99anomalies_par_Isolation_Forest_:_application_pour_l%E2%80%99industrie_4.0</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d7437b66c13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One-Class Support Vector Machine for Anomaly Detection]]></title>
            <link>https://medium.com/@senaozgunay/one-class-support-vector-machine-for-anomaly-detection-c999fefcafb3?source=rss-9b8118249811------2</link>
            <guid isPermaLink="false">https://medium.com/p/c999fefcafb3</guid>
            <category><![CDATA[anomaly-detection]]></category>
            <category><![CDATA[one-class-svm]]></category>
            <category><![CDATA[one-class-learning]]></category>
            <category><![CDATA[svm]]></category>
            <category><![CDATA[outlier-detection]]></category>
            <dc:creator><![CDATA[Sena Ozgunay]]></dc:creator>
            <pubDate>Wed, 08 Mar 2023 12:44:38 GMT</pubDate>
            <atom:updated>2023-03-08T12:47:25.677Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<p>An anomaly is an observation or group of observations that behave very differently from most of the data. <br>Anomaly detection is based on modeling the normal behavior exhibited by the vast majority of observations in order to discover which ones or groups of them behave differently. Today, anomaly detection is an issue at the crossroads of Big Data, AI, and cybersecurity. In this article, we will discuss One-Class Support Vector Machine (OC-SVM) for anomaly detection.</p><p>In the case of large class imbalance when only a very few observations from a class are available, standard classification algorithms may be biased. They may fail to correctly predict the minority class. So, One-Class SVM is a practical alternative. It’s an unsupervised algorithm for anomaly detection in which we don’t have target labels for the model training process.</p><p>Unlike the original SVM binary classification where the information is given on positive and negative classes, in one-class SVM we have only one class that is positive in which we have positive(normal) samples. In fact, it learns the boundary for normal data points and identifies data outside the boundary as anomalies.</p><p>In the training stage of One-Class SVM, first, the model projects the training samples to the higher dimensional feature space and then tries to separate most of the training samples from the origin by a maximum margin hyperplane as far away from the origin as possible.</p><p>We start by giving the mathematical background of this algorithm.</p><blockquote>Let’s suppose that our input data is</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*p80k5A95n9dv6s7h69hPUA.png" /></figure><blockquote>where we have samples from positive class only. Let ϕ be a non-linear transformation. In order to determine maximum margin hyperplane, we need to find the parameters <em>w ∈ ℝⁿ </em>and <em>b∈ ℝ </em>by solving the following minimisation problem:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*B9Qr9byWrdFgnwct9y9ujQ.png" /></figure><blockquote>where ξᵢ are slack variables. The parameter ν ∈ (0,1] is the upper-bound of the ratio of training samples that fall into the anomaly region. It tells us how many anomalies we want to allow. We solve this minimisation problem by its Lagrange dual as follows</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*bODcTnLMU6fVHJcVzy8d8g.png" /></figure><blockquote>Here, <em>K </em>is a kernel function such that <em>K(x,y) = </em>⟨ ϕ(<em>x</em>), ϕ(<em>y</em>) ⟩ which can transform non-linearly separable patterns into a new feature space where the patterns are linearly separable with high probability. We find αᵢ* from the dual problem, and p* from the primal problem. Finally we obtain the decision function</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*p7t5huu30NbpiF7PLHFW5A.png" /></figure><blockquote>A negative value of <em>f(x) </em>means that <em>x </em>is an anomaly. Note that xᵢ for which we have 0&lt;αᵢ* &lt; 1/νn are support vectors of OC-SVM.</blockquote><p>Now let’s see a simple example in Python.</p><p>We import the libraries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*oUnUHmD0E-p5fzGAsXsVGQ.png" /></figure><p>First, we generate training data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*ngH-qRgmLDrp4-L6ixJaiQ.png" /></figure><p>Then, we generate some regular and abnormal novel (test) observations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*O9p-HQkZHW_X_1GdjnsItA.png" /></figure><p>Visualization of the data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*77K_qIctTaraRJQDU3AH5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*zor8N1ro41SB-ij2XvzmnQ.png" /></figure><p>Model training:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*xiAoLLFO8bjaaSVjR3z6zg.png" /></figure><p>Here are some important parameters of <strong>OneClassSVM</strong>:</p><ul><li>‘<strong><em>kernel</em></strong>’: specifies the kernel type to be used in the algorithm. If none is given, ‘<em>rbf</em>’ will be used by default. Radial basis kernel function (<em>rbf</em>) is given by:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*kNkFsCJUWb2zqHImOFKxUw.png" /></figure><p>or common definition as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*VyCyPVsH7wqnnpM838MGtg.png" /></figure><ul><li>‘<strong><em>degree</em></strong>’: gives the degree of the polynomial if the polynomial kernel function (‘<em>poly</em>’) is used.</li><li>‘<strong><em>nu</em></strong>’ (<em>ν</em>): upper bound on the fraction of training errors and a lower bound of the fraction of support vectors as we mentioned earlier. By default <em>ν= 0.5.</em></li><li>‘<strong><em>gamma</em></strong>’ (γ): gives the kernel coefficient for kernels ‘<em>rbf</em>’, ‘<em>poly</em>’, and ‘<em>sigmoid</em>’.</li></ul><p>Now, we define two functions for visualization and classification report of OneClassSVM classifier as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*KyM6sD4w_8emh9DkR6teXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLYEMewwhj2_36L75boe_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*ItsDp8uPPQ8Bm8LZIooH6w.png" /></figure><ul><li>As we remember that the parameter <em>ν</em> tells us how many anomalies we want to allow. At first, we have <em>ν = 0.5</em> which means that we allow half of the training data to be anomalous by staying outside this boundary. We can expand this boundary by changing <em>ν</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*Tmx2CjrGLm5McZ0LgsZFsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*KzGit4KwRhNc2NRlEgDNAA.png" /></figure><ul><li>As we see, we expanded the boundary region and the accuracy score of the test increased while decreasing <em>ν</em>.</li></ul><p>Now, let’s change the σ parameter in the ‘<em>rbf</em>’ kernel function. First, we want to reduce σ. To do this, we need to increase the parameter γ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*44iAIgMpQnoZcLCDI2cV6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*qchIgInpAWgQIC8ppJxXsw.png" /></figure><ul><li>By reducing σ (or increasing γ) we obtain an overfitting on the train set.</li></ul><p>Now, we will increase σ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*hDQLHkQtWzPfDtjkpYbGFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*FHrVuBsZj82FTbQ9r2FSWw.png" /></figure><ul><li>By increasing σ, we see here that the complexity of the feature space is not that complicated, so the classifier cannot distinguish well between normal and abnormal observations.</li></ul><h4>Summary:</h4><ul><li>One-Class SVM is a widely used method for anomaly detection.</li><li>It tries to classify new data as similar or different to the training set by searching for a boundary for the training set.</li><li>It is crucial to choose good values of <em>ν</em> and <em>γ </em>with respect to the kernel<em>.</em></li></ul><p><em>Implementation reference: </em><a href="https://scikit-learn.org/stable/auto_examples/svm/plot_oneclass.html#sphx-glr-auto-examples-svm-plot-oneclass-py"><em>click here</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c999fefcafb3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Big Data]]></title>
            <link>https://medium.com/@senaozgunay/an-introduction-to-big-data-79c5bc6a0668?source=rss-9b8118249811------2</link>
            <guid isPermaLink="false">https://medium.com/p/79c5bc6a0668</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Sena Ozgunay]]></dc:creator>
            <pubDate>Tue, 27 Sep 2022 07:18:47 GMT</pubDate>
            <atom:updated>2022-10-04T15:57:13.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpM8evjnTLWyx3GOlFmKUg.jpeg" /><figcaption>source: <a href="https://tdwi.org/articles/2020/03/03/adv-all-how-accounting-teams-can-leverage-big-data.aspx">Ludovic Rembert</a> via <a href="https://tdwi.org/articles/2020/03/03/adv-all-how-accounting-teams-can-leverage-big-data.aspx">tdwi</a></figcaption></figure><h3>What is Big Data?</h3><p>With the continuous development of technology day by day, the internet has become an indispensable part of our lives. We interact with the internet every day, every hour, and almost every minute. The number of internet-enabled devices we use is increasing. And these devices record massive amounts of data about us. The form of this data that is analyzed and made meaningful and processable is called <em>Big Data</em>. This can include emails, databases, social media posts, images, videos, audio, texts, e-commerce transactions, GPS signals, and any kind of data we can think of.</p><p>Due to its massive size and complexity, big data cannot be stored and processed efficiently by traditional data management tools.</p><p>Ernst and Young (EY) defines big data as: “<em>The dynamic, large and disparate volumes of data being created by people, tools, and machines. It requires new, innovative, and scalable technology to collect, host, and analytically process the vast amount of data gathered to derive real-time business insights relating to consumers, risk, profit, performance, productivity management, and enhanced shareholder value.</em>”</p><h3>History of Big data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*JZ-ZfDpW4sHN4icSxoP7Nw.jpeg" /><figcaption>source: <a href="https://www.istockphoto.com/fr/photo/concept-dintelligence-artificielle-gm1188293935-335996121?utm_medium=organic&amp;utm_source=google&amp;utm_campaign=iptcurl">MF3d</a> via <a href="https://www.istockphoto.com/fr/photo/concept-dintelligence-artificielle-gm1188293935-335996121?utm_medium=organic&amp;utm_source=google&amp;utm_campaign=iptcurl">istock</a></figcaption></figure><p>Big Data is not something entirely new or something that has only existed in the last two decades. The first trace of big data can be traced back to 1663 when John Graunt was dealing with vast amounts of information while investigating the bubonic plague that was ravaging Europe at the time. He was the first statistician to use statistical data analysis.</p><p>After, the problem of huge data aggregation first appeared in the world in 1880. The US Census Bureau announced that they estimated it would take eight years to process the data collected during the census program that year. In 1881, Herman Hollerith, an employee at the Bureau, invented the Hollerith Tabulating Machine, which reduced the computational work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*GV10tYssTBG2xgeKtm375Q.jpeg" /><figcaption><a href="https://en.wikipedia.org/wiki/Herman_Hollerith">Herman Hollerith</a></figcaption></figure><p>The term ‘Big Data’ has been used since the early 1990s. From the 20th century onwards, in parallel with the development of technology, data began to evolve at an incredible speed. The world’s per capita technological information storage capacity has nearly doubled every 40 months since the 1980s; as of 2012, 2.5 exabytes (2.5×260 bytes) of data are generated daily. International Data Corporation (IDC) predicts that by 2025 the global data volume will be <em>163 zettabytes</em>.</p><h3>Fields of use</h3><p>Big data is used in almost every industry, especially in the ones where customer behavior is very important and needs to be tracked. It is used to grow businesses, understand customer behavior, answer questions, find solutions to complex problems, etc.</p><p>On the other hand, big data is not only helpful in the business world it also helps to change our world positively. Here are some fields in which big data is used.</p><ul><li><strong>Finance: </strong>Financial industries use big data with predictive analytics to analyze customers’ financial situations, and develop appropriate strategies for financial decisions, risk assessments, and credit rankings.</li><li><strong>Health:</strong> The use of big data contributes greatly to the improvement and advancement of healthcare for hospitals, researchers, pharmaceutical companies, etc. Access to and analysis of large amounts of patient records and medical images can improve treatments for diseases, enable more effective research and early detection of diseases, and develop new medicines.</li><li><strong>Media &amp; Entertainment:</strong> Media companies like Netflix, Hulu, etc. use big data to predict customer preferences. To do this, they analyze customers’ past reading, watching, and listening habits, preferences, or the company products and services they have used.</li><li><strong>More fields of use: </strong>Social media, agriculture, advertising &amp; marketing, e-commerce, education, natural &amp; man-made disasters, etc.</li></ul><h3>Types of Big data</h3><h4><strong>Structured data</strong></h4><p>Any data that can be stored, accessed, and processed in a fixed format is called ‘structured’ data. Data is stored in the form of rows and columns. Structured data can include names, dates, addresses, credit card numbers, stock information, etc.</p><p>Structured data is highly organized and easily understood by machine language. The most common source of structured data is <em>relational database management systems</em> (RDBMS). Here are some examples of the source of structured data:</p><ul><li>SQL databases</li><li>Spreadsheets</li><li>Online forms</li><li>Sensors such as GPS or RFID</li><li>Network and web server logs</li></ul><h4>Unstructured data</h4><p>Unstructured data is information that is not organized according to a predetermined data model or schema. Therefore, its format and structure are unknown. Therefore, it cannot be stored in a traditional relational database or RDBMS.</p><p>80% of the data being generated is unstructured data. Today, organizations and companies receive a lot of data in a raw or unstructured format, but they do not know how to extract value from it or what information to access. Examples of unstructured data:</p><ul><li>Web pages</li><li>Social media feeds</li><li>Images in varied file formats</li><li>Videos and audio files</li><li>Documents such as PDF</li><li>Presentations such as Microsoft PowerPoint</li><li>Media logs</li><li>Surveys</li></ul><h4>Semi-structured data</h4><p>Semi-structured data contains both structured and unstructured data. We can see semi-structured data as formally structured, but it cannot be defined with the table definition in RDBMS.</p><p>Semi-structured data has some organizing qualities, making it easier to parse and analyze. It has internal tags and markings which allow for grouping and hierarchies. Examples of semi-structured data:</p><ul><li>E-mails</li><li>Zipped files</li><li>Markup languages such as XML</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*-1BYg25p8wO7eV5JVMu8eQ.jpeg" /><figcaption>Data Structures. Image from <a href="https://e-skillsbusinesstoolbox.webnode.nl/big-data/voorbij-de-hype/">eskills</a></figcaption></figure><h3>V’s of Big data</h3><p>Information extraction and decisions from big data are characterized by the 5 V’s: <em>Velocity, volume, variety, veracity,</em> and <em>value</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*I_PYRFh47l4-Ha-R1vDtEw.jpeg" /><figcaption>5 V’s of Big Data. Source via <a href="https://dotnettutorials.net/lesson/5-vs-of-big-data/">dotnettutorials</a></figcaption></figure><h4>Velocity</h4><p>Velocity refers to the speed at which data is generated and accumulated. Data is generated very quickly to meet demands in a non-stop process.</p><p>Big Data Velocity relates to the rate at which data flows from sources such as business processes, application logs, networks, and social media sites, sensors, mobile devices. The flow of data is huge and continuous.</p><p>Everything about big data is fast, from the speed at which it is created to the time it takes to analyze it.</p><h4>Volume</h4><p>Volume is the scale of data or the increase in the amount of data stored. It is known that Big Data is all about massive size. The size of the data plays a crucial role in determining the value derived from it.</p><p>Also, whether a particular data can really be considered Big Data depends on the volume of the data. Hence, volume is an attribute to consider when dealing with Big Data solutions.</p><p>While traditional data is measured in known sizes such as megabytes, gigabytes, and terabytes, big data is stored in petabytes (<em>=1000 terabytes</em>) and zettabytes (<em>=1000000 petabytes</em>). The world’s population is about seven billion and most of them now use digital devices; cell phones, desktop and laptop computers, wearables, etc. All these devices generate, capture and store data — about 2.5 quintillion bytes every day. This is equivalent to 10 million Blu-ray DVDs.</p><h4>Variety</h4><p>Variety is the diversity of data that refers to heterogeneous sources and the nature of both structured and unstructured data. Traditional data types have been structured which fit neatly into rows and columns in relational databases.</p><p>With the rise of Big Data, data is not necessarily structured. Unstructured and semi-structured data are not organized in a predefined way, such as texts, numbers, images, video, and audio.</p><p>Variety also reflects the fact that data comes from different sources, machines, people, and processes, both inside and outside organizations and companies.</p><h4>Veracity</h4><p>Veracity represents the quality of the data and its source’s conformity to the facts and accuracy. Attributes include consistency, completeness, integrity, and uncertainty.</p><p>In this digital age, where vast amounts of data are available, the data must contain reliable and accurate information. Inaccurate and meaningless records in the data must be cleaned to get healthy results. Inaccurate data cannot be converted into meaningful information. For example, when evaluating the speed of vehicles traveling in traffic, if the average speed of some vehicles appears to be negative, the speed sensors of the vehicles should be deactivated considering that the speed sensors of the vehicles are faulty.</p><h4>Value</h4><p>The most important component of big data is value. Value is the ability and needs to transform data into value. Value includes customer, employee, or personal satisfaction as well as medical or social benefits.</p><p>The main reason to spend time understanding Big Data is to extract value from it. The data obtained and processed is meaningful if it adds value to the organization. Therefore, analyzing and simulating big data in the right way and ensuring that it benefits the organization should be prioritized.</p><h3>Big Data Ecosystem</h3><p>The term <em>ecosystem</em> is defined in the scientific literature as a complex network or interconnected system. Big data architecture consists of four main layers: Ingestion &amp; Collection, Storage &amp; Integration, Processing, and Analysis &amp; User Interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*fWqJ-Gnb4iVOqlI3jC_aZg.jpeg" /><figcaption>Big Data Architecture</figcaption></figure><h4>1. Ingestion &amp; Collection Layer</h4><p>The ingestion layer is the first step in the extraction of raw data which must be first ingested and collected from sources.</p><p>With the increasing data sources such as smartphone data, network data, sensor data, social media data, etc., a collection layer is needed to integrate multi-source, structured, semi-structured, and unstructured data for further management. This is all about collecting information from multiple sources and putting it somewhere it can be accessed.</p><p>Data can be streamed in real-time or ingested in batches.</p><ul><li><strong>Batch:</strong> Batch involves collecting large data groups and then delivering them together. Data collection can be driven by circumstances, initiated on a schedule, or it can be temporary. After this process, we have accumulated historical data which will be stored in the Storage layer for further analysis in the Analysis layer.</li><li><strong>Streaming: </strong>It means a continuous flow of data. This stage, which is essential for real-time data analytics, locates and pulls data as it is generated. Then, the streaming data is fed into the processing layer.</li></ul><h4>2. Storage &amp; Integration Layer</h4><p>This layer contains storing, transforming, and merging extracted data. It provides storage of historical data. Storage technologies for big data should have the following characteristics: reliable, scalable, high-performing, and cost-efficient.</p><h4>3. Processing Layer</h4><p>The data processing layer is the core of big data architecture. Generally, it includes data validations, and data transformations such as structuring, normalization, denormalization, data cleaning, etc.</p><h4>4. Analysis &amp; User interface Layer</h4><p>Big data architecture requires some data analytics tools for querying and programming based on user requirements. After that, big data systems can build various interfaces for different users. For example, business intelligence, stock analysis, and prediction interfaces. The outputs of these applications help users to make fast decisions.</p><h3>Big Data Processing Technologies</h3><p>Big Data processing technologies provide ways to analyze, process, and extract information from large sets of structured, semi-structured, and unstructured data so that value can be derived from big data. These include NoSQL databases, Data Lakes, and open-source technologies such as Apache Hadoop, Apache Hive, and Apache Spark.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*jtRsWFkv0ozjc19-eq3_fg.jpeg" /><figcaption>Examples of Big Data processing tools</figcaption></figure><h4>1. NoSQL Databases</h4><p>In the world of Big Data, relational databases which use SQL are no longer suitable. To handle the immense volumes of data, store, and analyze them, it is crucial to rely on new solutions. This is where NoSQL comes into the picture. NoSQL which signifies “Not only SQL” is a non-relational database that does not have a fixed schema.</p><p>NoSQL systems are compatible with a wide variety of technologies allowing the storage and analysis of structured, unstructured, and semi-structured data. Therefore, they are highly scalable and are most suitable for the Big Data ecosystem. They make the analysis of Big Data easier.</p><p>There are four types of NoSQL databases:</p><ul><li><strong>Key-value store: </strong>Here, big data is stored as key-attribute pairs. This allows the support of large volumes of data and heavy loads. The data is stored in a “hash” array in which each key is unique. It allows storing data more easily without schema.</li><li><strong>Document-based:</strong> They also store and retrieve data as a key-attribute pair. However, the attribute value is stored as a document in JSON or XML format and can be found using a query.</li><li><strong>Column-based: </strong>This type of NoSQL database is based on the BigTable model from Google. Each column is processed separately, and the values are stored adjacently.</li><li><strong>Graph-based: </strong>They store the entities and the relations between these entities. The entity is stored as a node and the relations as borders. This makes it easy to visualize the relationships between the nodes. Each node and each edge have a unique identifier.</li></ul><h4>2. Data Lakes</h4><p>A data lake is a method of storing massive data used by big data. These data are kept in their original formats or are minimally transformed. The data lake prioritizes fast and large storage of heterogeneous data.</p><p>Data lakes are usually built on low-cost commodity hardware, making it economically viable to store terabytes and even petabytes of data. Data lakes can ingest the volume, variety, and velocity of data and stages and catalog them centrally.</p><h4>3. Open-source Technologies</h4><p><strong>Apache Hadoop</strong></p><p>Hadoop is a set of tools that allow for the storage and processing of large data distributions. It is an open-source Java framework. Hadoop presents a reliable, scalable, and cost-effective solution for data storage without formatting user requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*xSsv3lm5GSbVVQR3_kxOJA.jpeg" /></figure><p>In a distributed Hadoop system, a node is a single computer, and a set of nodes forms a cluster. Hadoop scales from a single node to any number of nodes, each providing local storage, and computation.</p><p>One of the core components of Hadoop is the <em>Hadoop Distributed File System</em>, or HDFS, a storage system for big data that provides scalable and reliable storage by distributing files across multiple nodes. It distributes large files on multiple computers and gives them parallel access. Therefore, computations can be performed parallel to each data storage node. It also replicates blocks of files across multiple nodes to avoid data loss. HDFS allows a Hadoop cluster to divide work into smaller chunks and run those jobs across all servers in the cluster for better scalability.</p><p><strong>Apache Hive</strong></p><p>Hive is a data warehouse for data queries and analysis based on Hadoop. It is an open-source data warehouse software for reading, writing, and managing large data sets that are stored directly in either HDFS or other data storage systems such as Apache HBase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/111/1*IgmvhNp3R5ZahkSCCdnfNA.jpeg" /></figure><p>Hadoop is intended for long sequential scans, so it is less suitable for applications that need very fast response times. On the other hand, Hive is read-based, and therefore not suitable for transaction processing that typically involves a high percentage of write operations. Hive is better suited for data warehousing tasks such as ETL, reporting, and data analysis and includes tools that enable easy access to data via SQL.</p><p><strong>Apache Spark</strong></p><p>Spark is a general-purpose data processing engine designed for mining and processing big data for a wide range of applications, including interactive analytics, stream processing, machine learning, data integration, and ETL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/132/1*iNBe8fJv8zcdIahh5duiCQ.jpeg" /></figure><p>It uses in-memory processing to greatly increase the speed of calculations and only transfers them to a disk when memory is limited. Spark has interfaces to major programming languages, including Java, Scala, Python, R, and SQL.</p><p>It can run on its standalone clustering technology as well as on top of other infrastructure like Hadoop. It can also access data across multiple data sources, including HDFS and Hive, making it very versatile.</p><p>The ability to quickly process streaming data and perform complex analytics in real time is an important use case for Apache Spark.</p><h3>Impact of Big Data on Data Engineering</h3><p>Big data has had a huge impact on data engineering, making it a much more diverse and richer field. With all the data that companies and organizations are collecting these days, it is becoming more and more important to understand data and gain insight from it.</p><p>Today, data scientists derive insights from big data and solve the problems posed by these large data sets. Due to the amount of data collected, it is not possible to use traditional data analysis tools. However, alternative tools that use distributed computing power can overcome this problem. Tools like Apache Spark, Hadoop, and its ecosystem provide ways to extract, load, analyze, and process the data across distributed computing resources, providing new insights. This gives companies more opportunities to connect with their customers and enrich the services they offer.</p><h3>Limitations of Big Data</h3><p>Big Data analytics is a powerful tool to help companies make business decisions and find solutions to problems; however, there are limitations to the use of Big Data.</p><h4>1. Non-significant correlations</h4><p>When dealing with big data, it is an important and delicate issue to extract inferences from it and to find relationships, such as correlations, between data variables. The enormous size of the data being analyzed can sometimes make it difficult to uncover <strong>meaningful</strong> correlations. There may be many correlations between different variables in the data, but not all of them may be significant or meaningful. The important thing is to find those correlations that have a causal relationship.</p><h4>2. Wrong questions</h4><p>Big data analysis is being done to find solutions to many business problems. Many insights and answers can be found from the data, but the important thing is that they must be consistent with the business objective and actually solve the problem. Therefore, the right questions should be asked within the scope of the business objective.</p><p>The wrong answer to the right question or the right answer to the wrong question can lead to problems between companies and their clients.</p><h4>3. Data security</h4><p>Like any data, big data is at risk of a data breach. Important information and inferences from the data can be leaked to clients and competitors. That’s why data must have additional layers of security, and everyone who works with it must adhere to them.</p><h4>4. Transferability</h4><p>Big data needs to be secured with firewalls or private clouds, so only experts can access and use it. Transferring data between groups can therefore be difficult to transfer accurately. Data transfers need to be consistent.</p><h4>5. Inconsistency in data collection</h4><p>The tools used to collect big data may not be entirely effective and efficient. There is so much data today, and so many different ways to collect it. Data collection tools have many settings that change the process of searching for data. So there is a tendency to get different search results each time. This can result in different data sets each time, which can lead to different data analyses and variable correlations.</p><h3>To go further…</h3><p>Here are some links if you want to explore the world of big data and work with it.</p><ul><li><em>20 Big Data projects with source code:</em> <a href="https://www.projectpro.io/article/top-20-big-data-project-ideas-for-beginners-in-2021/426">https://www.projectpro.io/article/top-20-big-data-project-ideas-for-beginners-in-2021/426</a></li><li><em>A free online course to learn the basics of Apache Spark:</em> <a href="https://www.simplilearn.com/learn-apache-spark-basics-free-course-skillup">https://www.simplilearn.com/learn-apache-spark-basics-free-course-skillup</a></li><li><em>A free introductory course to Hadoop:</em> <a href="https://www.simplilearn.com/introduction-to-hadoop-free-course-skillup">https://www.simplilearn.com/introduction-to-hadoop-free-course-skillup</a></li><li><em>A brief introduction to Big Data 5Vs characteristics and Hadoop technology:</em> <a href="https://www.sciencedirect.com/science/article/pii/S1877050915006973">https://www.sciencedirect.com/science/article/pii/S1877050915006973</a></li><li><em>A survey of open source tools for machine learning with big data in the Hadoop ecosystem:</em> <a href="https://journalofbigdata.springeropen.com/articles/10.1186/s40537-015-0032-1">https://journalofbigdata.springeropen.com/articles/10.1186/s40537-015-0032-1</a></li><li><em>Big Data, Hadoop, and cloud computing in genomics:</em> <a href="https://www.sciencedirect.com/science/article/pii/S1532046413001007">https://www.sciencedirect.com/science/article/pii/S1532046413001007</a></li></ul><p><em>Hope you enjoyed it!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79c5bc6a0668" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistical Tests Used in Machine Learning]]></title>
            <link>https://medium.com/@senaozgunay/figure-rejection-regions-for-hypothesis-testing-by-critical-value-approach-541db55bdf0c?source=rss-9b8118249811------2</link>
            <guid isPermaLink="false">https://medium.com/p/541db55bdf0c</guid>
            <category><![CDATA[statistical-test]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[z-test]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Sena Ozgunay]]></dc:creator>
            <pubDate>Mon, 26 Sep 2022 20:51:04 GMT</pubDate>
            <atom:updated>2022-09-26T21:09:52.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*u5BlptjvSUN9yLOLN1-wOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*BEIqmUBdhqZav5QKbnXChg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*ya5o77RJ8C959yK8Oxnzqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*Cl5mzeHWGUpySCdcXJlbZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*qcEccC-xlrOJkD5tS63iuQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*5-1mUI968vbC4u8MdC_qow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*qwmFWvy0OE3uUtyMWYcnhA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*VY8qTNhifbmvkXxZfT6CtQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*KrypnKIz7etN1S8nf750sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*orh3OXwttgZajzKuU7DgQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*4_6Obouv4KjwrtbgtP2Mrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*r4_Wo3i3PpUelejzxlIlXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/171/1*wAVoM8l3PQvpTzaQaJ-osA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*FrVTtsAoTnX3GUD67aK8jA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*-6VnRcSkBYIwA_mM0S0rGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*Onehmona_b3j0aAZ45eEFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*uaPoJyVEl_yxcwLeO9IqNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*rap9agGJKTclbf4yO6NiwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*VMVHf0IyfTmwwwfKE0aI8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*Z7kCdvZ9hjUJNQDLHvPAVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*A5gzqJbBWuoV996yWJ49aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*u8TgQxqf7wY9MdMFASFU2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*x8J0756kMbOPMjgkbjdxZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*0qcc6aDHx8BJTwAlnGGlWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*MlAvixOOVH2m5gwK0j0R6A.png" /><figcaption>Figure: Rejection regions for hypothesis testing by critical value approach. Blue areas represent the rejection regions for the null hypothesis which mean that in those areas we reject 𝐻₀. In the remaining areas, we do not reject 𝐻₀.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*ipEuxaDSQfUKnvKYJBaLwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*s3kgTYOTYgG86NC2M81a7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*sny6ZS2B91Qg8hDLTGKxMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*Qqwj3zigDm1IIYLWoHtyPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*yYk1NAwZwMfkMglUgH9QmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*GiTMM-kiYcc_kkmKV0Dqnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*Y-jMUzce1OK5l3ZA7cB89g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*18hXeb2YXrtEVjwzfkMitg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*ciEgCy5BjEE4lgXDljozpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*-Ei71w5X8imrNnZPocRZmg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*DOcM-2g5NGoMsmyAjkJZwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*FaLrmZJd_H1_V91lrzQAWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*pEH6Y1oruz_yBoLg5oTnMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*GeZi_BGkDpDIXc4H2RLSjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*SSkIOAVuKSMqxgUnZ8PXcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*UmDsoQf2mdShKGdpD2mUKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*qCiWGYwsaGXDsioCnBnyrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*V5_s-BqCuRFN90tDfxnbog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*l0mu0nAcDAvH15w4fC5S0w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*HRcPMxjVubIWU_KVdGVc1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*mV0x77QH1eSl6y7qxe3yJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*1n0DIcadoUctocgw-n2yOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*zVSsbOs7P4jN3pyIvb2CZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*nlOlbVIk7520sBd02ONizw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*dLBhuJhK_ornBIxQJE_k9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*olhjoogI56VJnD3mb9Rqag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*e1mXrZhHf_Sl42dNLR3BxQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*yKoPmpj9i-Y0xF8BF9K5ow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*7NR6V5nBBwReD3Wxu6PxIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*D2IjoDHym7HWZ-S_UAjVBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*2IGG9r2zydJYWjoxRqfsEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*jTC6WBWM6_eYrpnY7ZsRUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*z9-PyOZZp8zIWEhAsgQrpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*pC3dWLMa7eGiXOePLDDUYQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*sAYdVkzedEKf6qCLf7Rpvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*gTIE3G3nhkthhoEdZRgbgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*2ovBCG_muLj5luZG-sdiVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*00gbpRsQpWDMInZAmBHMfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*nGm2Li2q-FJ9YXNcfLD8Tg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*hjkC_-fHdXHqwtvTBMJ0uQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*slMIjlWZCueElqlGoVNh5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*xgwvtMgoYQEEG1pHkqIRkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*Or5km_a7D-sM8JKCNi6eqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*wW3uGMtsoToaJFU8Gst5PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*s6ckxnbQNlDaiSvYxtxxpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*KXbHD6d01Isw54ZUAt0n3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*mUvxe-kZj9ClQNrdWy6NHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*SvOJqp6Ppu-kL0LCjt5uqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*abvAoJPySl1yofDjlFbOlQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*RMIePMNKelEsP6Go55fu3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*yj10kDRFB2426TStZFYfzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*oK1DRAAuFr5cID5r5HLqFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*d4ByZAmxirnFS_HVHT0JDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*cWMRZa8rzSPcm7Sx_CfoHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*WVGdIrQIg5ZzXJZtaNTXfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*bNPCmhff5Uiosdm-iUf2_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*yEY5shJ8x8kwe6nfGYL81A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*I17wxb8bzB2Pi_3OqLzBeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*pLUyGAChgKwLtMNPyAFU4w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=541db55bdf0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>