<?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 venkatasubramani karthikeyan on Medium]]></title>
        <description><![CDATA[Stories by venkatasubramani karthikeyan on Medium]]></description>
        <link>https://medium.com/@venkykasprov?source=rss-bf026e02f724------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1GOyN2QKbQXMIeZx.jpg</url>
            <title>Stories by venkatasubramani karthikeyan on Medium</title>
            <link>https://medium.com/@venkykasprov?source=rss-bf026e02f724------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:38:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@venkykasprov/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[I recently took a train ride thinking I'd catch up on some peace, podcasts, or just scroll…]]></title>
            <link>https://medium.com/@venkykasprov/i-recently-took-a-train-ride-thinking-id-catch-up-on-some-peace-podcasts-or-just-scroll-7a93c6685ef1?source=rss-bf026e02f724------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a93c6685ef1</guid>
            <dc:creator><![CDATA[venkatasubramani karthikeyan]]></dc:creator>
            <pubDate>Sun, 03 Aug 2025 00:40:40 GMT</pubDate>
            <atom:updated>2025-08-03T00:40:40.839Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently took a train ride thinking I&#39;d catch up on some peace, podcasts, or just scroll aimlessly like the responsible adult I am. But life had other plans—in the form of a talkative uncle.</p><p>He started with a classic opener:</p><p>“Do you work in IT?”</p><p>I said yes and then came the punchline I didn’t ask for:</p><p>“I guessed it. Most IT people are fat and carry a laptop bag”</p><p>I thought in my mind, We’ve known each other for literally 40 seconds, and he’s already body-shaming the entire tech industry.</p><p>I forced a polite laugh and that encouraged him to take that into a lengthy boring conversation. I tried to avoid it but he was very fast with his questions.</p><p>Anyway, the conversation chugged along faster than the train.<br>He asked, “Many people are talking about Generative AI… Do you know what it is?”</p><p>Now I was mildly impressed. Not by the question—but that he said Generative AI without calling it &quot;generator AI&quot; or “that chat robot thing.”</p><p>I replied with my usual analogy:</p><p>“Imagine a person who’s read the whole internet. You ask them to write a story—not just copying stuff but creating new things based on patterns they’ve seen a million times.”</p><p>He nodded like he got it…<br>Then came Instagram Theory 101:</p><p>“If I talk about shoes today, I get shoe ads tomorrow. Is that also this Generative AI?”</p><p>I sighed.</p><p>“No, that’s just creepy tracking. Cookies, microphones, location… Instagram knows more about you than your own family. But it’s not Generative AI. That’s good old targeted advertising.”</p><p>Then he asked about pricing, courses, whether he can learn it, and even asked if his 10th-standard son should get into this field.</p><p>I told him honestly:</p><p>“Right now, it’s trending. Tomorrow? Who knows. But sure, your son can explore it.”</p><p>By this point, my brain was melting. So, in an act of desperation, I took his phone, installed ChatGPT, and told him:</p><p>“Talk into this—in Tamil, English, whatever. It’ll answer. Magic.”</p><p>He tried. asking questions to it.</p><p>But guess what?</p><p>He was too lazy to read the reply.<br>So now I had to explain what ChatGPT told him, to him.<br>I was one question away from jumping off the moving train.</p><p>Desperate times call for desperate measures. I pinged my friend:</p><p>“Please call me. Say it’s urgent. Save me.”</p><p>Did the call come?</p><p>Of course not.<br>Because why would my friend ever check messages on time when I actually need them?</p><p>So I sat through the rest of the journey listening to life advice, fitness tips, and probably the GDP of seven countries—none of which I asked for.</p><p>The lesson?</p><p>Sometimes, the real test of AI isn’t passing the Turing Test. It’s surviving a train ride with a human who thinks you are the AI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a93c6685ef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Series Forecasting: A Comprehensive Analysis Using Various Models for Stock Market Predictions]]></title>
            <link>https://medium.com/@venkykasprov/time-series-forecasting-a-comprehensive-analysis-using-various-models-for-stock-market-predictions-ad955b22960d?source=rss-bf026e02f724------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad955b22960d</guid>
            <category><![CDATA[stock-market]]></category>
            <category><![CDATA[predictions]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[timeseries]]></category>
            <category><![CDATA[plotly]]></category>
            <dc:creator><![CDATA[venkatasubramani karthikeyan]]></dc:creator>
            <pubDate>Mon, 17 Jun 2024 10:39:03 GMT</pubDate>
            <atom:updated>2024-06-17T10:39:03.276Z</atom:updated>
            <content:encoded><![CDATA[<p>In this project, we aim to forecast stock prices using multiple time series forecasting models, each with unique characteristics and applications. We will explore Autoregressive (AR), Moving Average (MA), ARIMA (AutoRegressive Integrated Moving Average), SARIMA (Seasonal ARIMA), Auto ARIMA, Exponential Smoothing, and LightGBM (Light Gradient Boosting Machine) models. Our dataset consists of historical stock prices for Amazon (AMZN), Google (GOOG), Qualcomm (QCOM), and Applied Materials (AMAT), resampled to 12-week intervals.</p><h3>Data Preprocessing</h3><p>The first step involved loading and preprocessing the data. We ensured the data was continuous by filling any missing dates and interpolating the missing values. The data was then resampled to 12-week intervals to match our forecasting period.</p><pre>import pandas as pd<br><br># Load data<br>stock_data = pd.read_csv(&#39;/kaggle/input/yahoo-finance-stock-market-data/pre_processed_data.csv&#39;)<br><br># Convert &#39;Date&#39; column to datetime<br>stock_data[&#39;Date&#39;] = pd.to_datetime(stock_data[&#39;Date&#39;])<br><br># Set &#39;Date&#39; as the index<br>stock_data.set_index(&#39;Date&#39;, inplace=True)<br><br># Resample data bi-weekly and calculate the mean for each group<br>_12_weekly_averages = stock_data.resample(&#39;12W&#39;).mean()</pre><h3>Data Visualization</h3><p>We visualized the stock prices to understand the trends and patterns over time.</p><pre>import plotly.express as px<br><br>fig = px.line(stock_data, x=&#39;Date&#39;, y=[&quot;GOOG&quot;,&quot;AMZN&quot;,&quot;QCOM&quot;,&quot;AMAT&quot;], title=&#39;Stock market data&#39;)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*6RX99UoByMzMvbwRCMQNDA.png" /><figcaption>stock market daily data</figcaption></figure><pre>stock_data[&#39;Date&#39;] = pd.to_datetime(stock_data[&#39;Date&#39;])<br><br># Set &#39;Date&#39; as the index<br>stock_data.set_index(&#39;Date&#39;, inplace=True)<br><br># Resample data bi-weekly and calculate the mean for each group<br>_12_weekly_averages = stock_data.resample(&#39;12W&#39;).mean()<br><br>_12_weekly_averages_df = _12_weekly_averages.reset_index()<br>fig = px.line(_12_weekly_averages_df, x=&#39;Date&#39;, y=[&quot;GOOG&quot;,&quot;AMZN&quot;,&quot;QCOM&quot;,&quot;AMAT&quot;],title=&#39;Stock market data&#39;)<br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_xdRnWPWU9o8mIp2rSkiw.png" /><figcaption>Stock market 12 weekly data</figcaption></figure><h3>Forecasting Models</h3><h4>1. Autoregressive (AR) Model</h4><p>The AR model uses past values to predict future values. We implemented this model to forecast the stock prices.</p><pre>import numpy as np<br>import plotly.graph_objects as go<br>from statsmodels.tsa.ar_model import AutoReg<br>from statsmodels.tsa.arima.model import ARIMA<br><br># Function to fit AR model and forecast the next period<br>def forecast_ar(stock_data):<br>    # Fit an AR model<br>    model = ARIMA(stock_data, order=(1,0,0))  # Equivalent to AR(1) model<br>    model_fit = model.fit()<br>    # Forecast the next bi-weekly period<br>    forecast = model_fit.forecast(steps=1)<br>    <br>    # Fit an AR model<br>    model = ARIMA(stock_data[:-1], order=(1,0,0))  # Equivalent to AR(1) model<br>    model_fit = model.fit()<br>    # Forecast the next bi-weekly period<br>    last_forecast = model_fit.forecast(steps=1)<br>    <br>    return model_fit, forecast,last_forecast[0],stock_data[-1]<br><br># Dictionary to store models and forecasts<br>models_last_forecasts = {}<br>models_future_forecasts = {}<br>df_results=pd.DataFrame(columns=[&#39;Model&#39;,&#39;Company&#39;,&#39;Actual&#39;,&#39;Forecasted&#39;,&#39;Error&#39;])<br># Loop through each stock column and apply the forecasting function<br>for column in _12_weekly_averages.columns:<br>    fit, forecast,last_forecast,actual = forecast_ar(_12_weekly_averages[column])<br>    models_future_forecasts[column] = (fit, forecast)<br>    models_last_forecasts[column]=(fit,[actual,last_forecast,actual-last_forecast])<br>    <br>    df= pd.DataFrame([[&#39;AR&#39;,column,actual,last_forecast,actual-last_forecast]],columns=[&#39;Model&#39;,&#39;Company&#39;,&#39;Actual&#39;,&#39;Forecasted&#39;,&#39;Error&#39;])<br>    df_results=pd.concat([df_results,df])<br>    df_results=df_results.reset_index(drop=True)<br># # Display the forecasted last values for each stock   <br># print({key: val[1] for key, val in models_last_forecasts.items()})<br># Display the forecasted future values for each stock<br>print(&#39;prediction of future date&#39;)<br>print({key: val[1] for key, val in models_future_forecasts.items()})<br>df_results.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*v0uJPZwTy3MuozAtcH8J7A.png" /></figure><pre>import plotly.graph_objects as go<br>from plotly.subplots import make_subplots<br>import pandas as pd<br>from statsmodels.tsa.arima.model import ARIMA<br><br># Assuming &#39;_12_weekly_averages&#39; is your DataFrame<br># Create subplots<br>fig_comparison = make_subplots(rows=2, cols=2, subplot_titles=(&quot;Amazon (AMZN)&quot;, &quot;Google (GOOG)&quot;, &quot;Qualcomm (QCOM)&quot;, &quot;Applied Materials (AMAT)&quot;))<br><br>def plot_ar_forecast_comparison(row, col, stock_name):<br>    # Fit AR(1) model excluding the last bi-weekly data<br>    model = ARIMA(_12_weekly_averages[stock_name][:-1], order=(1,0,0))<br>    model_fit = model.fit()<br>    forecast = model_fit.forecast(steps=1)<br>    forecast_index = _12_weekly_averages.index[-1]<br>    forecast_value = forecast[0]<br>    <br>    # Plot historical data<br>    fig_comparison.add_trace(go.Scatter(x=_12_weekly_averages.index, y=_12_weekly_averages[stock_name], mode=&#39;lines&#39;, name=f&#39;{stock_name} - Historical&#39;), row=row, col=col)<br>    <br>    # Add forecast point<br>    fig_comparison.add_trace(go.Scatter(x=[forecast_index], y=[forecast_value], mode=&#39;markers&#39;, name=f&#39;{stock_name} - Forecast&#39;, marker=dict(color=&#39;red&#39;, size=10)), row=row, col=col)<br>    <br>    # Draw a vertical line at the forecast point<br>    fig_comparison.add_vline(x=forecast_index, line_dash=&quot;dash&quot;, line_color=&quot;green&quot;, row=row, col=col)<br><br>plot_ar_forecast_comparison(1, 1, &#39;AMZN&#39;)<br>plot_ar_forecast_comparison(1, 2, &#39;GOOG&#39;)<br>plot_ar_forecast_comparison(2, 1, &#39;QCOM&#39;)<br>plot_ar_forecast_comparison(2, 2, &#39;AMAT&#39;)<br><br>fig_comparison.update_layout(title_text=&quot;AR MODEL Historical and Predicted Last 12-Weekly Stock Values&quot;, height=800)<br>fig_comparison.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8PnYCU6Kstk53zZVsk_xwQ.png" /><figcaption>AR Model prediction</figcaption></figure><h4>2. Moving Average (MA) Model</h4><p>The MA model predicts future values based on past error terms.</p><pre>import numpy as np<br>import plotly.graph_objects as go<br>import pandas as pd<br>from statsmodels.tsa.arima.model import ARIMA<br><br># Function to fit MA model and forecast the next period<br>def forecast_ma(stock_data):<br>    # Fit an MA model for future prediction<br>    model_future = ARIMA(stock_data, order=(0,0,1))  # Equivalent to MA(1) model<br>    model_future_fit = model_future.fit()<br>    future_forecast = model_future_fit.forecast(steps=1)<br><br>    # Fit an MA model excluding the last data point for last period prediction<br>    model_last = ARIMA(stock_data[:-1], order=(0,0,1))  # Equivalent to MA(1) model<br>    model_last_fit = model_last.fit()<br>    last_forecast = model_last_fit.forecast(steps=1)<br><br>    actual = stock_data[-1]<br>    return model_future_fit, future_forecast, last_forecast[0], actual<br><br># Dictionary to store models and forecasts<br>models_last_forecasts = {}<br>models_future_forecasts = {}<br><br># Loop through each stock column and apply the forecasting function<br>for column in _12_weekly_averages.columns:<br>    fit, future_forecast, last_forecast, actual = forecast_ma(_12_weekly_averages[column])<br>    models_future_forecasts[column] = (fit, future_forecast)<br>    models_last_forecasts[column] = (fit, [actual, last_forecast, actual - last_forecast])<br>    <br>    df = pd.DataFrame([[&#39;MA&#39;, column, actual, last_forecast, actual - last_forecast]], columns=[&#39;Model&#39;, &#39;Company&#39;, &#39;Actual&#39;, &#39;Forecasted&#39;, &#39;Error&#39;])<br>    df_results = pd.concat([df_results, df])<br>    <br>df_results = df_results.drop_duplicates()<br>df_results = df_results.reset_index(drop=True)<br># Display the forecasted future values for each stock<br>print(&#39;Prediction of future date&#39;)<br>print({key: val[1] for key, val in models_future_forecasts.items()})<br><br>df_results[df_results[&#39;Model&#39;]==&#39;MA&#39;].head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*svl5G6N4o074Y0gIYkHpxw.png" /></figure><pre>import plotly.graph_objects as go<br>from plotly.subplots import make_subplots<br>import pandas as pd<br>from statsmodels.tsa.arima.model import ARIMA<br><br># Assuming &#39;_12_weekly_averages&#39; is your DataFrame<br># Create subplots<br>fig_comparison = make_subplots(rows=2, cols=2, subplot_titles=(&quot;Amazon (AMZN)&quot;, &quot;Google (GOOG)&quot;, &quot;Qualcomm (QCOM)&quot;, &quot;Applied Materials (AMAT)&quot;))<br><br>def plot_ma_forecast_comparison(row, col, stock_name):<br>    # Fit MA(1) model excluding the last 12-weekly data<br>    model = ARIMA(_12_weekly_averages[stock_name][:-1], order=(0,0,1))<br>    model_fit = model.fit()<br>    forecast = model_fit.forecast(steps=1)<br>    forecast_index = _12_weekly_averages.index[-1]<br>    forecast_value = forecast[0]<br>    <br>    # Plot historical data<br>    fig_comparison.add_trace(go.Scatter(x=_12_weekly_averages.index, y=_12_weekly_averages[stock_name], mode=&#39;lines&#39;, name=f&#39;{stock_name} - Historical&#39;), row=row, col=col)<br>    <br>    # Add forecast point<br>    fig_comparison.add_trace(go.Scatter(x=[forecast_index], y=[forecast_value], mode=&#39;markers&#39;, name=f&#39;{stock_name} - Forecast&#39;, marker=dict(color=&#39;red&#39;, size=10)), row=row, col=col)<br>    <br>    # Draw a vertical line at the forecast point<br>    fig_comparison.add_vline(x=forecast_index, line_dash=&quot;dash&quot;, line_color=&quot;green&quot;, row=row, col=col)<br><br>plot_ma_forecast_comparison(1, 1, &#39;AMZN&#39;)<br>plot_ma_forecast_comparison(1, 2, &#39;GOOG&#39;)<br>plot_ma_forecast_comparison(2, 1, &#39;QCOM&#39;)<br>plot_ma_forecast_comparison(2, 2, &#39;AMAT&#39;)<br><br>fig_comparison.update_layout(title_text=&quot;MA MODEL Historical and Predicted Last 12-Weekly Stock Values&quot;, height=800)<br>fig_comparison.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3CDl2rk5yU7bWdZPjksFw.png" /><figcaption>MA Model Prediction</figcaption></figure><h4>3. ARIMA Model</h4><p>ARIMA combines AR and MA models and adds differencing to make the data stationary.</p><pre>import numpy as np<br>import plotly.graph_objects as go<br>import pandas as pd<br>from statsmodels.tsa.arima.model import ARIMA<br><br># Function to fit ARIMA model and forecast the next period<br>def forecast_arima(stock_data):<br>    # Fit an ARIMA model for future prediction<br>    model_future = ARIMA(stock_data, order=(1,1,1))  # ARIMA(1,1,1) model<br>    model_future_fit = model_future.fit()<br>    future_forecast = model_future_fit.forecast(steps=1)<br><br>    # Fit an ARIMA model excluding the last data point for last period prediction<br>    model_last = ARIMA(stock_data[:-1], order=(1,1,1))  # ARIMA(1,1,1) model<br>    model_last_fit = model_last.fit()<br>    last_forecast = model_last_fit.forecast(steps=1)<br><br>    actual = stock_data[-1]<br>    return model_future_fit, future_forecast, last_forecast[0], actual<br><br># Dictionary to store models and forecasts<br>models_last_forecasts = {}<br>models_future_forecasts = {}<br><br># Assuming &#39;_12_weekly_averages&#39; is your DataFrame<br># Loop through each stock column and apply the forecasting function<br>for column in _12_weekly_averages.columns:<br>    fit, future_forecast, last_forecast, actual = forecast_arima(_12_weekly_averages[column])<br>    models_future_forecasts[column] = (fit, future_forecast)<br>    models_last_forecasts[column] = (fit, [actual, last_forecast, actual - last_forecast])<br>    <br>    df = pd.DataFrame([[&#39;ARIMA&#39;, column, actual, last_forecast, actual - last_forecast]], columns=[&#39;Model&#39;, &#39;Company&#39;, &#39;Actual&#39;, &#39;Forecasted&#39;, &#39;Error&#39;])<br>    df_results = pd.concat([df_results, df])<br><br>df_results = df_results.drop_duplicates()<br>df_results = df_results.reset_index(drop=True)<br><br># Display the forecasted future values for each stock<br>print(&#39;Prediction of future date&#39;)<br>print({key: val[1] for key, val in models_future_forecasts.items()})<br><br>df_results[df_results[&#39;Model&#39;]==&#39;ARIMA&#39;].head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*SutSQk6JMqJyZs4QJJAjVg.png" /></figure><pre>import plotly.graph_objects as go<br>from plotly.subplots import make_subplots<br>import pandas as pd<br>from statsmodels.tsa.arima.model import ARIMA<br><br># Assuming &#39;_12_weekly_averages&#39; is your DataFrame<br># Create subplots<br>fig_comparison = make_subplots(rows=2, cols=2, subplot_titles=(&quot;Amazon (AMZN)&quot;, &quot;Google (GOOG)&quot;, &quot;Qualcomm (QCOM)&quot;, &quot;Applied Materials (AMAT)&quot;))<br><br>def plot_arima_forecast_comparison(row, col, stock_name):<br>    # Fit ARIMA(1,1,1) model excluding the last 12-weekly data<br>    model = ARIMA(_12_weekly_averages[stock_name][:-1], order=(1,1,1))<br>    model_fit = model.fit()<br>    forecast = model_fit.forecast(steps=1)<br>    forecast_index = _12_weekly_averages.index[-1]<br>    forecast_value = forecast[0]<br>    <br>    # Plot historical data<br>    fig_comparison.add_trace(go.Scatter(x=_12_weekly_averages.index, y=_12_weekly_averages[stock_name], mode=&#39;lines&#39;, name=f&#39;{stock_name} - Historical&#39;), row=row, col=col)<br>    <br>    # Add forecast point<br>    fig_comparison.add_trace(go.Scatter(x=[forecast_index], y=[forecast_value], mode=&#39;markers&#39;, name=f&#39;{stock_name} - Forecast&#39;, marker=dict(color=&#39;red&#39;, size=10)), row=row, col=col)<br>    <br>    # Draw a vertical line at the forecast point<br>    fig_comparison.add_vline(x=forecast_index, line_dash=&quot;dash&quot;, line_color=&quot;green&quot;, row=row, col=col)<br><br>plot_arima_forecast_comparison(1, 1, &#39;AMZN&#39;)<br>plot_arima_forecast_comparison(1, 2, &#39;GOOG&#39;)<br>plot_arima_forecast_comparison(2, 1, &#39;QCOM&#39;)<br>plot_arima_forecast_comparison(2, 2, &#39;AMAT&#39;)<br><br>fig_comparison.update_layout(title_text=&quot;ARIMA(1,1,1) MODEL Historical and Predicted Last 12-Weekly Stock Values&quot;, height=800)<br>fig_comparison.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h4ZR5Q6u23xdEIS1ju3hPA.png" /><figcaption>ARIMA Model Prediction</figcaption></figure><h4>4. SARIMA Model</h4><p>SARIMA accounts for seasonality in the data.</p><pre>import numpy as np<br>import plotly.graph_objects as go<br>import pandas as pd<br>from statsmodels.tsa.statespace.sarimax import SARIMAX<br><br># Function to fit SARIMA model and forecast the next period<br>def forecast_sarima(stock_data):<br>    # Fit a SARIMA model for future prediction<br>    model_future = SARIMAX(stock_data, order=(1,1,1), seasonal_order=(1,1,1,12))  # SARIMA(1,1,1)(1,1,1)[12]<br>    model_future_fit = model_future.fit()<br>    future_forecast = model_future_fit.forecast(steps=1)<br><br>    # Fit a SARIMA model excluding the last data point for last period prediction<br>    model_last = SARIMAX(stock_data[:-1], order=(1,1,1), seasonal_order=(1,1,1,12))  # SARIMA(1,1,1)(1,1,1)[12]<br>    model_last_fit = model_last.fit()<br>    last_forecast = model_last_fit.forecast(steps=1)<br><br>    actual = stock_data[-1]<br>    return model_future_fit, future_forecast, last_forecast[0], actual<br><br># Dictionary to store models and forecasts<br>models_last_forecasts = {}<br>models_future_forecasts = {}<br><br># Assuming &#39;_12_weekly_averages&#39; is your DataFrame<br># Loop through each stock column and apply the forecasting function<br>for column in _12_weekly_averages.columns:<br>    fit, future_forecast, last_forecast, actual = forecast_sarima(_12_weekly_averages[column])<br>    models_future_forecasts[column] = (fit, future_forecast)<br>    models_last_forecasts[column] = (fit, [actual, last_forecast, actual - last_forecast])<br>    <br>    df = pd.DataFrame([[&#39;SARIMA&#39;, column, actual, last_forecast, actual - last_forecast]], columns=[&#39;Model&#39;, &#39;Company&#39;, &#39;Actual&#39;, &#39;Forecasted&#39;, &#39;Error&#39;])<br>    df_results = pd.concat([df_results, df])<br><br>df_results = df_results.reset_index(drop=True)<br><br># Display the forecasted future values for each stock<br>print(&#39;Prediction of future date&#39;)<br>print({key: val[1] for key, val in models_future_forecasts.items()})<br><br>df_results[df_results[&#39;Model&#39;]==&#39;SARIMA&#39;].head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*0rhmmrqCrJbG3_kjS0cuYg.png" /></figure><pre>import plotly.graph_objects as go<br>from plotly.subplots import make_subplots<br>import pandas as pd<br>from statsmodels.tsa.statespace.sarimax import SARIMAX<br><br># Assuming &#39;_12_weekly_averages&#39; is your DataFrame<br># Create subplots<br>fig_comparison = make_subplots(rows=2, cols=2, subplot_titles=(&quot;Amazon (AMZN)&quot;, &quot;Google (GOOG)&quot;, &quot;Qualcomm (QCOM)&quot;, &quot;Applied Materials (AMAT)&quot;))<br><br>def plot_sarima_forecast_comparison(row, col, stock_name):<br>    # Fit SARIMA model excluding the last 12-weekly data<br>    model = SARIMAX(_12_weekly_averages[stock_name][:-1], order=(1,1,1), seasonal_order=(1,1,1,12))  # SARIMA(1,1,1)(1,1,1)[12] model<br>    model_fit = model.fit()<br>    forecast = model_fit.forecast(steps=1)<br>    forecast_index = _12_weekly_averages.index[-1]<br>    forecast_value = forecast[0]<br>    <br>    # Plot historical data<br>    fig_comparison.add_trace(go.Scatter(x=_12_weekly_averages.index, y=_12_weekly_averages[stock_name], mode=&#39;lines&#39;, name=f&#39;{stock_name} - Historical&#39;), row=row, col=col)<br>    <br>    # Add forecast point<br>    fig_comparison.add_trace(go.Scatter(x=[forecast_index], y=[forecast_value], mode=&#39;markers&#39;, name=f&#39;{stock_name} - Forecast&#39;, marker=dict(color=&#39;red&#39;, size=10)), row=row, col=col)<br>    <br>    # Draw a vertical line at the forecast point<br>    fig_comparison.add_vline(x=forecast_index, line_dash=&quot;dash&quot;, line_color=&quot;green&quot;, row=row, col=col)<br><br>plot_sarima_forecast_comparison(1, 1, &#39;AMZN&#39;)<br>plot_sarima_forecast_comparison(1, 2, &#39;GOOG&#39;)<br>plot_sarima_forecast_comparison(2, 1, &#39;QCOM&#39;)<br>plot_sarima_forecast_comparison(2, 2, &#39;AMAT&#39;)<br><br>fig_comparison.update_layout(title_text=&quot;SARIMA(1,1,1)(1,1,1)[12] MODEL Historical and Predicted Last 12-Weekly Stock Values&quot;, height=800)<br>fig_comparison.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Xw1xQKCxcO64xswYpEEhw.png" /><figcaption>SARIMA model Prediction</figcaption></figure><h4>5. Auto ARIMA</h4><p>Auto ARIMA automates the process of finding the best ARIMA model parameters.</p><pre>import numpy as np<br>import plotly.graph_objects as go<br>import pandas as pd<br>from pmdarima.arima import auto_arima<br><br># Function to fit auto_arima model and forecast the next period<br>def forecast_auto_arima(stock_data):<br>    # Fit an auto_arima model for future prediction<br>    model_future = auto_arima(stock_data, seasonal=True, m=1, trace=False,<br>                              error_action=&#39;ignore&#39;, suppress_warnings=True,<br>                              stepwise=True)<br>    future_forecast = model_future.predict(n_periods=1)<br><br>    # Fit an auto_arima model excluding the last data point for last period prediction<br>    model_last = auto_arima(stock_data[:-1], seasonal=True, m=1, trace=False,<br>                            error_action=&#39;ignore&#39;, suppress_warnings=True,<br>                            stepwise=True)<br>    last_forecast = model_last.predict(n_periods=1)<br><br>    actual = stock_data[-1]<br>    return model_future, future_forecast[0], last_forecast[0], actual<br><br># Dictionary to store models and forecasts<br>models_last_forecasts = {}<br>models_future_forecasts = {}<br><br># Assuming &#39;_12_weekly_averages&#39; is your DataFrame<br># Loop through each stock column and apply the forecasting function<br>for column in _12_weekly_averages.columns:<br>    fit, future_forecast, last_forecast, actual = forecast_auto_arima(_12_weekly_averages[column])<br>    models_future_forecasts[column] = (fit, future_forecast)<br>    models_last_forecasts[column] = (fit, [actual, last_forecast, actual - last_forecast])<br>    <br>    df = pd.DataFrame([[&#39;Auto-ARIMA&#39;, column, actual, last_forecast, actual - last_forecast]], columns=[&#39;Model&#39;, &#39;Company&#39;, &#39;Actual&#39;, &#39;Forecasted&#39;, &#39;Error&#39;])<br>    df_results = pd.concat([df_results, df])<br><br>df_results = df_results.drop_duplicates()<br>df_results = df_results.reset_index(drop=True)<br><br># Display the forecasted future values for each stock<br>print(&#39;Prediction of future date&#39;)<br>print({key: val[1] for key, val in models_future_forecasts.items()})<br><br>df_results[df_results[&#39;Model&#39;]==&#39;Auto-ARIMA&#39;].head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HqFoc3XG1iRvAcDyyZ5Hdg.png" /></figure><pre>import plotly.graph_objects as go<br>from plotly.subplots import make_subplots<br>import pandas as pd<br>from pmdarima.arima import auto_arima<br><br># Create subplots<br>fig_comparison = make_subplots(rows=2, cols=2, subplot_titles=(&quot;Amazon (AMZN)&quot;, &quot;Google (GOOG)&quot;, &quot;Qualcomm (QCOM)&quot;, &quot;Applied Materials (AMAT)&quot;))<br><br>def plot_auto_arima_forecast_comparison(row, col, stock_name):<br>    # Fit auto_arima model excluding the last 12-weekly data<br>    model = auto_arima(_12_weekly_averages[stock_name][:-1], seasonal=True, m=1, trace=False,<br>                       error_action=&#39;ignore&#39;, suppress_warnings=True, stepwise=True)<br>    forecast = model.predict(n_periods=1)<br>    forecast_index = _12_weekly_averages.index[-1]<br>    forecast_value = forecast[0]<br>    <br>    # Plot historical data<br>    fig_comparison.add_trace(go.Scatter(x=_12_weekly_averages.index, y=_12_weekly_averages[stock_name], mode=&#39;lines&#39;, name=f&#39;{stock_name} - Historical&#39;), row=row, col=col)<br>    <br>    # Add forecast point<br>    fig_comparison.add_trace(go.Scatter(x=[forecast_index], y=[forecast_value], mode=&#39;markers&#39;, name=f&#39;{stock_name} - Forecast&#39;, marker=dict(color=&#39;red&#39;, size=10)), row=row, col=col)<br>    <br>    # Draw a vertical line at the forecast point<br>    fig_comparison.add_vline(x=forecast_index, line_dash=&quot;dash&quot;, line_color=&quot;green&quot;, row=row, col=col)<br><br>plot_auto_arima_forecast_comparison(1, 1, &#39;AMZN&#39;)<br>plot_auto_arima_forecast_comparison(1, 2, &#39;GOOG&#39;)<br>plot_auto_arima_forecast_comparison(2, 1, &#39;QCOM&#39;)<br>plot_auto_arima_forecast_comparison(2, 2, &#39;AMAT&#39;)<br><br>fig_comparison.update_layout(title_text=&quot;Auto-ARIMA Model Historical and Predicted Last 12-Weekly Stock Values&quot;, height=800)<br>fig_comparison.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_EWxUrsmSRxw7cQWZ93TQ.png" /><figcaption>Auto-ARIMA Model Prediction</figcaption></figure><h4>6. Exponential Smoothing</h4><p>This model applies weighted averages of past observations, with weights decaying exponentially.</p><pre>from darts import TimeSeries<br>from darts.models import ExponentialSmoothing<br><br>def forecast_auto_ets(stock_data, seasonal_period=4):<br>    # Convert to numpy array if needed<br>    values = stock_data.values if isinstance(stock_data, pd.Series) else np.array(stock_data)<br><br>    # Create a TimeSeries object from the values<br>    series = TimeSeries.from_values(values)<br><br>    # Check data length against twice the seasonal period for seasonal modeling<br>    if len(values) &gt;= 2 * seasonal_period:<br>        # Enough data for seasonal modeling<br>        model = ExponentialSmoothing(seasonal_periods=seasonal_period)<br>        model_last = ExponentialSmoothing(seasonal_periods=seasonal_period)<br>    else:<br>        # Not enough data for seasonal modeling, use non-seasonal model<br>        print(f&quot;Not enough data for seasonal modeling for series with length {len(values)} and seasonal period {seasonal_period}.&quot;)<br>        model = ExponentialSmoothing(seasonal_periods=None)<br>        model_last = ExponentialSmoothing(seasonal_periods=None)<br><br>    # Fit the models and make predictions<br>    model.fit(series)<br>    future_forecast = model.predict(n=1)<br>    <br>    # For last period prediction, create a TimeSeries object from all but the last value<br>    series_last = TimeSeries.from_values(values[:-1])<br>    model_last.fit(series_last)<br>    last_forecast = model_last.predict(n=1)<br><br>    actual = values[-1]<br>    return future_forecast.values()[0][0], last_forecast.values()[0][0], actual<br><br># Example usage assuming &#39;_12_weekly_averages&#39; is a DataFrame with each column as a time series<br>models_future_forecasts = {}<br>models_last_forecasts = {}<br><br>for column in _12_weekly_averages.columns:<br>    future_forecast, last_forecast, actual = forecast_auto_ets(_12_weekly_averages[column])<br>    models_future_forecasts[column] = future_forecast<br>    models_last_forecasts[column] = [actual, last_forecast, actual - last_forecast]<br><br>    df = pd.DataFrame([[&#39;AutoETS&#39;, column, actual, last_forecast, actual - last_forecast]], columns=[&#39;Model&#39;, &#39;Company&#39;, &#39;Actual&#39;, &#39;Forecasted&#39;, &#39;Error&#39;])<br>    df_results = pd.concat([df_results, df])<br><br>df_results = df_results.drop_duplicates().reset_index(drop=True)<br><br># Display the forecasted future values for each stock<br>print(&#39;Prediction of future date&#39;)<br>print({key: val for key, val in models_future_forecasts.items()})<br>df_results[df_results[&#39;Model&#39;]==&#39;AutoETS&#39;].head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1m-ASbn36PHBydjFay6UOQ.png" /></figure><pre>import plotly.graph_objects as go<br>from plotly.subplots import make_subplots<br>import pandas as pd<br>from darts import TimeSeries<br>from darts.models import ExponentialSmoothing<br><br># Create subplots<br>fig_comparison = make_subplots(rows=2, cols=2, subplot_titles=(&quot;Amazon (AMZN)&quot;, &quot;Google (GOOG)&quot;, &quot;Qualcomm (QCOM)&quot;, &quot;Applied Materials (AMAT)&quot;))<br><br>def forecast_auto_ets(stock_data, seasonal_period=4):<br>    # Convert to numpy array if needed<br>    values = stock_data.values if isinstance(stock_data, pd.Series) else np.array(stock_data)<br><br>    # Create a TimeSeries object from the values<br>    series = TimeSeries.from_values(values)<br><br>    # Check data length against twice the seasonal period for seasonal modeling<br>    if len(values) &gt;= 2 * seasonal_period:<br>        # Enough data for seasonal modeling<br>        model = ExponentialSmoothing(seasonal_periods=seasonal_period)<br>        model_last = ExponentialSmoothing(seasonal_periods=seasonal_period)<br>    else:<br>        # Not enough data for seasonal modeling, use non-seasonal model<br>        print(f&quot;Not enough data for seasonal modeling for series with length {len(values)} and seasonal period {seasonal_period}.&quot;)<br>        model = ExponentialSmoothing(seasonal_periods=None)<br>        model_last = ExponentialSmoothing(seasonal_periods=None)<br><br>    # Fit the models and make predictions<br>    model.fit(series)<br>    future_forecast = model.predict(n=1)<br>    <br>    # For last period prediction, create a TimeSeries object from all but the last value<br>    series_last = TimeSeries.from_values(values[:-1])<br>    model_last.fit(series_last)<br>    last_forecast = model_last.predict(n=1)<br><br>    actual = values[-1]<br>    return future_forecast.values()[0][0], last_forecast.values()[0][0], actual<br><br>def plot_exponential_smoothing_forecast_comparison(row, col, stock_name):<br>    # Apply the Exponential Smoothing model<br>    future_forecast, last_forecast, actual = forecast_auto_ets(_12_weekly_averages[stock_name])<br>    forecast_index = _12_weekly_averages.index[-1]<br>    forecast_value = last_forecast<br>    <br>    # Plot historical data<br>    fig_comparison.add_trace(go.Scatter(x=_12_weekly_averages.index, y=_12_weekly_averages[stock_name], mode=&#39;lines&#39;, name=f&#39;{stock_name} - Historical&#39;), row=row, col=col)<br>    <br>    # Add forecast point<br>    fig_comparison.add_trace(go.Scatter(x=[forecast_index], y=[forecast_value], mode=&#39;markers&#39;, name=f&#39;{stock_name} - Forecast&#39;, marker=dict(color=&#39;red&#39;, size=10)), row=row, col=col)<br>    <br>    # Draw a vertical line at the forecast point<br>    fig_comparison.add_vline(x=forecast_index, line_dash=&quot;dash&quot;, line_color=&quot;green&quot;, row=row, col=col)<br><br>plot_exponential_smoothing_forecast_comparison(1, 1, &#39;AMZN&#39;)<br>plot_exponential_smoothing_forecast_comparison(1, 2, &#39;GOOG&#39;)<br>plot_exponential_smoothing_forecast_comparison(2, 1, &#39;QCOM&#39;)<br>plot_exponential_smoothing_forecast_comparison(2, 2, &#39;AMAT&#39;)<br><br>fig_comparison.update_layout(title_text=&quot;Exponential Smoothing Model Historical and Predicted Last 12-Weekly Stock Values&quot;, height=800)<br>fig_comparison.show()<br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JvdGmhfEgVwGJveQVjnT4Q.png" /><figcaption>Exponential Smoothing model prediction</figcaption></figure><h4>7. LightGBM</h4><p>LightGBM is a gradient boosting framework that uses tree-based learning algorithms.</p><pre>import numpy as np<br>import pandas as pd<br>from darts import TimeSeries<br>from darts.models import RegressionModel<br>from darts.utils.timeseries_generation import datetime_attribute_timeseries<br>from lightgbm import LGBMRegressor<br><br>def train_lightgbm_forecast(series, lags, forecast_horizon=1):<br>    &quot;&quot;&quot;<br>    Train a LightGBM model using Darts&#39; RegressionModel wrapper and forecast the next time steps.<br>    &quot;&quot;&quot;<br>    # Create a TimeSeries object if not already<br>    if not isinstance(series, TimeSeries):<br>        series = TimeSeries.from_series(series)<br><br>    # Define the LightGBM model<br>    model = LGBMRegressor()<br><br>    # Darts RegressionModel wrapper around LightGBM<br>    reg_model = RegressionModel(<br>        model=model,<br>        lags=lags,  # specify lags: this can be a list of lags or an integer<br>        output_chunk_length=forecast_horizon<br>    )<br><br>    # Fit the model<br>    reg_model.fit(series)<br><br>    # Perform prediction<br>    forecast = reg_model.predict(n=forecast_horizon)<br><br>    return reg_model, forecast<br><br># Example usage with a time series data<br>models = {}<br>forecasts = {}<br><br># Assuming &#39;_12_weekly_averages&#39; is a DataFrame with time series data in each column<br>for column in _12_weekly_averages.columns:<br>    series = TimeSeries.from_series(_12_weekly_averages[column])<br>    model, forecast = train_lightgbm_forecast(series, lags=12)  # Assuming using past 12 periods as features<br>    models[column] = model<br>    forecasts[column] = forecast<br>    <br>    # Storing results<br>    actual = _12_weekly_averages[column][-1]  # last known value<br>    predicted = forecast.values()[-1][0]  # last predicted value<br>    df = pd.DataFrame([[&#39;LightGBM&#39;, column, actual, predicted, actual - predicted]], columns=[&#39;Model&#39;, &#39;Company&#39;, &#39;Actual&#39;, &#39;Forecasted&#39;, &#39;Error&#39;])<br>    df_results = pd.concat([df_results, df])<br><br>df_results = df_results.reset_index(drop=True)<br><br># Display results<br>print(&#39;Forecast results using LightGBM:&#39;)<br>df_results[df_results[&#39;Model&#39;]==&#39;LightGBM&#39;].head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*BdywPjQjoMxrLqyWqW7iRQ.png" /></figure><pre>import plotly.graph_objects as go<br>from plotly.subplots import make_subplots<br>import pandas as pd<br>from darts import TimeSeries<br>from darts.models import RegressionModel<br>from lightgbm import LGBMRegressor<br><br># Create subplots<br>fig_comparison = make_subplots(rows=2, cols=2, subplot_titles=(&quot;Amazon (AMZN)&quot;, &quot;Google (GOOG)&quot;, &quot;Qualcomm (QCOM)&quot;, &quot;Applied Materials (AMAT)&quot;))<br><br>def train_lightgbm_forecast(series, lags, forecast_horizon=1):<br>    &quot;&quot;&quot;<br>    Train a LightGBM model using Darts&#39; RegressionModel wrapper and forecast the next time steps.<br>    &quot;&quot;&quot;<br>    # Create a TimeSeries object if not already<br>    if not isinstance(series, TimeSeries):<br>        series = TimeSeries.from_series(series)<br><br>    # Define the LightGBM model<br>    model = LGBMRegressor()<br><br>    # Darts RegressionModel wrapper around LightGBM<br>    reg_model = RegressionModel(<br>        model=model,<br>        lags=lags,  # specify lags: this can be a list of lags or an integer<br>        output_chunk_length=forecast_horizon<br>    )<br><br>    # Fit the model<br>    reg_model.fit(series)<br><br>    # Perform prediction<br>    forecast = reg_model.predict(n=forecast_horizon)<br><br>    return reg_model, forecast<br><br>def plot_lightgbm_forecast_comparison(row, col, stock_name):<br>    # Convert the column data to a TimeSeries object<br>    series = TimeSeries.from_series(_12_weekly_averages[stock_name])<br>    <br>    # Train the LightGBM model excluding the last 12-weekly data<br>    _, forecast = train_lightgbm_forecast(series[:-1], lags=12)<br>    forecast_index = _12_weekly_averages.index[-1]<br>    forecast_value = forecast.values()[-1][0]<br>    <br>    # Plot historical data<br>    fig_comparison.add_trace(go.Scatter(x=_12_weekly_averages.index, y=_12_weekly_averages[stock_name], mode=&#39;lines&#39;, name=f&#39;{stock_name} - Historical&#39;), row=row, col=col)<br>    <br>    # Add forecast point<br>    fig_comparison.add_trace(go.Scatter(x=[forecast_index], y=[forecast_value], mode=&#39;markers&#39;, name=f&#39;{stock_name} - Forecast&#39;, marker=dict(color=&#39;red&#39;, size=10)), row=row, col=col)<br>    <br>    # Draw a vertical line at the forecast point<br>    fig_comparison.add_vline(x=forecast_index, line_dash=&quot;dash&quot;, line_color=&quot;green&quot;, row=row, col=col)<br><br>plot_lightgbm_forecast_comparison(1, 1, &#39;AMZN&#39;)<br>plot_lightgbm_forecast_comparison(1, 2, &#39;GOOG&#39;)<br>plot_lightgbm_forecast_comparison(2, 1, &#39;QCOM&#39;)<br>plot_lightgbm_forecast_comparison(2, 2, &#39;AMAT&#39;)<br><br>fig_comparison.update_layout(title_text=&quot;LightGBM Model Historical and Predicted Last 12-Weekly Stock Values&quot;, height=800)<br>fig_comparison.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dLdTQS6MlH9LVbkM9cZgeQ.png" /><figcaption>LightGBM model Prediction</figcaption></figure><h3>Results and Comparison</h3><p>We compared the performance of all models by forecasting the last known stock prices and calculating the error.</p><pre>print(&#39;Final results comparison&#39;)<br>print(df_results)</pre><pre>Final results comparison<br>         Model Company      Actual  Forecasted      Error<br>0           AR    AMZN   97.830002  101.222115  -3.392113<br>1           AR    GOOG  105.220001  100.845243   4.374758<br>2           AR    QCOM  120.269997  121.372908  -1.102911<br>3           AR    AMAT  113.160004  113.510634  -0.350630<br>4           MA    AMZN   97.830002  114.973522 -17.143520<br>5           MA    GOOG  105.220001   97.362835   7.857166<br>6           MA    QCOM  120.269997  123.432427  -3.162430<br>7           MA    AMAT  113.160004  106.906355   6.253649<br>8        ARIMA    AMZN   97.830002   97.797648   0.032354<br>9        ARIMA    GOOG  105.220001  103.297876   1.922125<br>10       ARIMA    QCOM  120.269997  121.961419  -1.691422<br>11       ARIMA    AMAT  113.160004  115.514663  -2.354659<br>12      SARIMA    AMZN   97.830002   98.360939  -0.530937<br>13      SARIMA    GOOG  105.220001  118.433662 -13.213661<br>14      SARIMA    QCOM  120.269997   89.036852  31.233145<br>15      SARIMA    AMAT  113.160004  138.998331 -25.838327<br>16  Auto-ARIMA    AMZN   97.830002  101.221458  -3.391456<br>17  Auto-ARIMA    GOOG  105.220001  100.371322   4.848679<br>18  Auto-ARIMA    QCOM  120.269997  121.372899  -1.102902<br>19  Auto-ARIMA    AMAT  113.160004  112.366741   0.793263<br>20     AutoETS    AMZN   97.830002  101.667354  -3.837352<br>21     AutoETS    GOOG  105.220001  105.741093  -0.521092<br>22     AutoETS    QCOM  120.269997  111.198804   9.071193<br>23     AutoETS    AMAT  113.160004  110.651414   2.508590<br>24    LightGBM    AMZN   97.830002  102.705220  -4.875218<br>25    LightGBM    GOOG  105.220001  102.603487   2.616514<br>26    LightGBM    QCOM  120.269997  121.933637  -1.663640<br>27    LightGBM    AMAT  113.160004  109.872451   3.287553<br></pre><pre>import plotly.express as px<br><br># Assuming df_results is already defined and contains the results<br># Calculate the absolute errors<br>df_results[&#39;Absolute Error&#39;] = df_results[&#39;Error&#39;].abs()<br><br># Create a bar plot for the absolute errors<br>fig = px.bar(df_results, x=&#39;Company&#39;, y=&#39;Absolute Error&#39;, color=&#39;Model&#39;, barmode=&#39;group&#39;,<br>             title=&#39;Absolute Errors of Different Models for Stock Price Predictions&#39;,<br>             labels={&#39;Absolute Error&#39;: &#39;Absolute Error&#39;, &#39;Company&#39;: &#39;Stock&#39;})<br><br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnCLii-4RjJ27m31xg5xgA.png" /></figure><h3>Conclusion</h3><p>This comprehensive analysis provided insights into the strengths and weaknesses of different time series forecasting models. Each model has its unique advantages, and the choice of model depends on the specific characteristics of the data and the forecasting requirements.</p><p>By using a variety of models, we can compare their performances and choose the best-suited model for our time series data, ensuring accurate and reliable forecasts.</p><p>This project demonstrates the importance of model selection in time series forecasting and highlights the potential of advanced models like LightGBM for handling complex patterns in the data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad955b22960d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Cricket Player Profile Database with Web Scraping and MongoDB from Cricbuzz website]]></title>
            <link>https://medium.com/@venkykasprov/building-a-cricket-player-profile-database-with-web-scraping-and-mongodb-from-cricbuzz-website-0154156aca9e?source=rss-bf026e02f724------2</link>
            <guid isPermaLink="false">https://medium.com/p/0154156aca9e</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-mining]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[venkatasubramani karthikeyan]]></dc:creator>
            <pubDate>Thu, 13 Jun 2024 16:30:13 GMT</pubDate>
            <atom:updated>2024-06-13T16:30:13.350Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AQWTTSRZ67TSBYbFbYPHKw.png" /></figure><p>In this blog post, we’ll walk through a project that involves scraping cricket player profiles from Cricbuzz and storing the data in a MongoDB database. This project is a great example of how web scraping can be combined with database operations to create a rich data source for analysis or application development.</p><h3>Project Overview</h3><p>The project consists of three main parts:</p><ol><li><strong>Setting up the MongoDB connection</strong></li><li><strong>Web scraping cricket player profiles from Cricbuzz</strong></li><li><strong>Inserting the scraped data into the MongoDB database</strong></li></ol><p>Let’s dive into each part in detail.</p><h3>1. Setting Up the MongoDB Connection</h3><h3>Prerequisites</h3><ul><li>A MongoDB Atlas account</li><li>MongoDB Python driver (pymongo)</li></ul><p>First, we need to set up a connection to a MongoDB Atlas cluster. MongoDB Atlas is a cloud-based database service that provides a fully managed MongoDB cluster. You can create an account and set up a cluster at <a href="https://www.mongodb.com/cloud/atlas">MongoDB Atlas</a>.</p><p>Once you have your cluster set up, you’ll need the connection string to connect to your database. This string typically looks something like this:</p><pre>mongodb+srv://&lt;username&gt;:&lt;password&gt;@&lt;cluster-url&gt;/?retryWrites=true&amp;w=majority</pre><p>Replace &lt;username&gt;, &lt;password&gt;, and &lt;cluster-url&gt; with your actual credentials and cluster URL.</p><h4><strong>Connecting to MongoDB</strong></h4><pre>from pymongo import MongoClient, errors<br><br>try:<br>    # Replace &lt;username&gt;, &lt;password&gt;, and &lt;cluster-url&gt; with your actual MongoDB Atlas credentials and cluster URL<br>    client = MongoClient(&quot;mongodb+srv://&lt;username&gt;:&lt;password&gt;@&lt;cluster-url&gt;/&lt;database&gt;?retryWrites=true&amp;w=majority&#39;&quot;)<br>    db = client[&#39;cricket_db&#39;]<br>    collection = db[&#39;profiles&#39;]<br>except errors.ConfigurationError as e:<br>    print(f&quot;ConfigurationError: {e}&quot;)<br>    exit(1)</pre><h3>2. Web Scraping Cricket Player Profiles from Cricbuzz</h3><h3>Prerequisites</h3><ul><li>requests library for sending HTTP requests</li><li>beautifulsoup4 library for parsing HTML content</li></ul><h3>Loop Through Profile IDs</h3><p>We aim to scrape profiles from Cricbuzz, a popular cricket website. Each profile is identified by a unique ID in the URL. We’ll loop through the first 1500 IDs and scrape the profiles.</p><pre>import requests<br>from bs4 import BeautifulSoup<br><br>for i in range(0, 1500):<br>    try:<br>        # URL of the cricbuzz profile<br>        url = &#39;https://www.cricbuzz.com/profiles/&#39; + str(i) + &#39;/&#39;<br>        <br>        # Send a GET request to the URL<br>        response = requests.get(url)<br>        print(f&quot;Profile ID {i} status code: {response.status_code}&quot;)<br><br>        if response.status_code == 200:<br>            # Parse the HTML content of the page<br>            soup = BeautifulSoup(response.content, &#39;html.parser&#39;)<br>            <br>            profile = {}<br><br>            # Extracting Personal Information<br>            profile[&#39;Full Name&#39;] = soup.find(&#39;h1&#39;, class_=&#39;cb-font-40&#39;).text.strip() if soup.find(&#39;h1&#39;) else None<br>            if profile[&#39;Full Name&#39;] == &#39;&#39;:<br>                continue<br>            profile[&#39;Born&#39;] = soup.find(&#39;div&#39;, string=&#39;Born&#39;).find_next_sibling(&#39;div&#39;).text.strip() if soup.find(&#39;div&#39;, string=&#39;Born&#39;) else None<br>            profile[&#39;Birth Place&#39;] = soup.find(&#39;div&#39;, string=&#39;Birth Place&#39;).find_next_sibling(&#39;div&#39;).text.strip() if soup.find(&#39;div&#39;, string=&#39;Birth Place&#39;) else None<br>            profile[&#39;Height&#39;] = soup.find(&#39;div&#39;, string=&#39;Height&#39;).find_next_sibling(&#39;div&#39;).text.strip() if soup.find(&#39;div&#39;, string=&#39;Height&#39;) else None<br>            profile[&#39;Role&#39;] = soup.find(&#39;div&#39;, string=&#39;Role&#39;).find_next_sibling(&#39;div&#39;).text.strip() if soup.find(&#39;div&#39;, string=&#39;Role&#39;) else None<br>            profile[&#39;Batting Style&#39;] = soup.find(&#39;div&#39;, string=&#39;Batting Style&#39;).find_next_sibling(&#39;div&#39;).text.strip() if soup.find(&#39;div&#39;, string=&#39;Batting Style&#39;) else None<br>            profile[&#39;Bowling Style&#39;] = soup.find(&#39;div&#39;, string=&#39;Bowling Style&#39;).find_next_sibling(&#39;div&#39;).text.strip() if soup.find(&#39;div&#39;, string=&#39;Bowling Style&#39;) else None<br><br>            # ICC Rankings<br>            icc_rankings = {}<br>            ranking_labels = [&#39;Test&#39;, &#39;ODI&#39;, &#39;T20&#39;]<br>            ranking_values = []<br><br>            # Find all ranking values<br>            for ranking_value in soup.find_all(&#39;div&#39;, class_=&#39;cb-col cb-col-25 cb-plyr-rank text-right&#39;):<br>                ranking_values.append(ranking_value.text.strip())<br><br>            # Split ranking values into batting and bowling<br>            batting_ranks = ranking_values[:3]<br>            bowling_ranks = ranking_values[3:]<br><br>            # Construct the ICC Rankings dictionary<br>            icc_rankings[&#39;Batting&#39;] = {ranking_labels[i]: batting_ranks[i] for i in range(len(ranking_labels))}<br>            icc_rankings[&#39;Bowling&#39;] = {ranking_labels[i]: bowling_ranks[i] for i in range(len(ranking_labels))}<br><br>            # Extract Career Information<br>            career_information = {}<br>            career_information_section = soup.find(&#39;div&#39;, class_=&#39;cb-col cb-col-100 cb-font-16 text-bold cb-ttl-vts&#39;)<br><br>            if career_information_section:<br>                teams_label = career_information_section.find_next_sibling(&#39;div&#39;, class_=&#39;cb-col cb-col-40 text-bold cb-lst-itm-sm&#39;)<br>                teams_value = teams_label.find_next_sibling(&#39;div&#39;, class_=&#39;cb-col cb-col-60 cb-lst-itm-sm&#39;)<br>                career_information[&#39;Teams&#39;] = teams_value.text.strip() if teams_value else None<br>            profile[&#39;ICC Rankings&#39;] = icc_rankings<br>            profile[&#39;Career Information&#39;] = career_information<br><br>            def extract_table_data(table):<br>                headers = [th.text.strip() for th in table.find_all(&#39;th&#39;)[1:]]<br>                data = {}<br>                for row in table.find_all(&#39;tr&#39;)[1:]:<br>                    cells = row.find_all(&#39;td&#39;)<br>                    format_name = cells[0].text.strip()<br>                    values = [cell.text.strip() for cell in cells[1:]]<br>                    data[format_name] = {<br>                        **dict(zip(headers, values))<br>                    }<br>                return data<br><br>            # Extract batting career summary<br>            batting_table = soup.find(&#39;div&#39;, string=&#39;Batting Career Summary&#39;).find_next(&#39;table&#39;) if soup.find(&#39;div&#39;, string=&#39;Batting Career Summary&#39;) else None<br>            if batting_table:<br>                batting_summary = extract_table_data(batting_table)<br>                profile[&#39;Batting Career Summary&#39;] = batting_summary<br>            <br>            # Extract bowling career summary<br>            bowling_table = soup.find(&#39;div&#39;, string=&#39;Bowling Career Summary&#39;).find_next(&#39;table&#39;) if soup.find(&#39;div&#39;, string=&#39;Bowling Career Summary&#39;) else None<br>            if bowling_table:<br>                bowling_summary = extract_table_data(bowling_table)<br>                profile[&#39;Bowling Career Summary&#39;] = bowling_summary<br>            <br>            # Extract Key Career Milestones<br>            career_info_div = soup.find(&#39;div&#39;, class_=&#39;cb-col cb-col-100&#39;)<br>            career_info = {}<br><br>            if career_info_div:<br>                titles = career_info_div.find_all(&#39;div&#39;, class_=&#39;cb-col cb-col-16 text-bold cb-ftr-lst&#39;)<br>                details = career_info_div.find_all(&#39;a&#39;, class_=&#39;cb-text-link&#39;)<br><br>                for title, detail in zip(titles, details):<br>                    key = title.text.strip().replace(&#39; &#39;, &#39;_&#39;).lower()<br>                    value = detail.text.strip()<br>                    career_info[key] = value<br>                profile[&#39;Key Career Milestones&#39;] = career_info<br><br>    except requests.RequestException as e:<br>        print(f&quot;Request failed for profile ID {i}: {e}&quot;)<br>    except Exception as e:<br>        print(f&quot;An error occurred for profile ID {i}: {e}&quot;)</pre><p>In this code, we loop through profile IDs from 0 to 1499 and scrape various pieces of information such as personal details, ICC rankings, career information, and career summaries. We use BeautifulSoup to parse the HTML content and extract the necessary data.</p><h3>3. Inserting the Scraped Data into MongoDB</h3><p>Once we have the data, the next step is to insert it into our MongoDB collection. We’ll use the insert_one method to insert each profile.</p><pre>from pymongo import errors<br><br># Assuming the previous code block exists here and we&#39;re inside the for loop<br>try:<br>    # Insert the profile data into MongoDB<br>    collection.insert_one(profile)<br>    print(f&quot;Data for profile ID {i} inserted successfully&quot;)<br>except errors.PyMongoError as e:<br>    print(f&quot;Data insertion failed for profile ID {i}: {e}&quot;)</pre><p>In this code, we handle any potential errors that might occur during data insertion, ensuring that our script continues to run smoothly even if a particular insertion fails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JU2t6hL0mx3sHSon2KXuJg.png" /></figure><p>The reason why we have only 514 records for first 1500 profiles is in the below picture we can see that the entire page is empty for id=1 and this happens to multiple ID’s. In fact first 24 ID’s are empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IpQzXxYcuKQxgk_Zw6QBCw.png" /></figure><p>When Id = 25, Then comes the first entry to the data base, That’s none other than the God of cricket Sachin Tendulkar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*46-iKvluNbyXDe4hTO2skg.png" /></figure><h3>Conclusion</h3><p>By combining web scraping with MongoDB, we’ve created a robust process for collecting and storing cricket player profiles from Cricbuzz. This data can be used for various purposes, such as statistical analysis, application development, or simply as a reference. This project showcases the power of Python in automating data collection and storage tasks.</p><p>I hope you found this walkthrough helpful. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0154156aca9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How is IOT going to be the future and What did Joseph Fourier do ?]]></title>
            <link>https://medium.com/@venkykasprov/how-is-iot-going-to-be-the-future-and-what-did-joseph-fourier-do-7ef3064281f2?source=rss-bf026e02f724------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ef3064281f2</guid>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <category><![CDATA[fourier-transform]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[fourier-series]]></category>
            <dc:creator><![CDATA[venkatasubramani karthikeyan]]></dc:creator>
            <pubDate>Wed, 05 May 2021 12:22:17 GMT</pubDate>
            <atom:updated>2021-05-05T16:52:10.195Z</atom:updated>
            <content:encoded><![CDATA[<h3>How is IOT going to be the future and What did Joseph Fourier do ? How Fourier’s findings will have a huge impact in IOT ?</h3><p>Many engineering students having or had backlogs in Engineering Mathematics would definitely remember this guy for their lifetime. Many people may not know by his first name but I guess many might know him by his last name.</p><p>Yes, many of us read about Fourier series, Fourier transform without knowing the application behind that. He is a pure mathematician, he found out that any function that can be drawn in a graph can be represented in the form of F(X) = a Cos(X) + b Sin(X) + c</p><p>Many of us studied at an exam perspective and answered all the questions related to Fourier series and Fourier transformation and then cleared our Engineering Mathematics paper.</p><h3>What would have happened if Fourier didn’t do his research?</h3><p>Many students would have cleared engineering mathematics exam easily but If Fourier didn’t do his research, by now we won’t have many real time applications like</p><ol><li>heat transfer and vibrations in the field of mechanical engineering.</li><li>Digital signal processing won’t be there. Without digital signal processing we cannot have communication field. Fourier series plays a major role in converting all the signals into electric signals and vice versa.</li><li>Again without digital signal processing, we can’t use any electronic devices like computer, grinder, washing machine etc.</li><li>In field of mobile technology, we won’t have anything called Bluetooth, WiFi etc. Without Fourier series.</li></ol><p>Can you think of a life without any of these electronic devices in a day to day life? If you cannot, Then we all are very thankful to Fourier for his findings.</p><h3>What is IOT?</h3><p>The acronym of IOT is Internet of things. It means all the electronic devices will become smart devices. The devices can control itself with the sensors and transducers.</p><p>As of now IOT is in nascent stage. Where we use mobile apps and bots like Alexa, Google home, etc to control all the devices in our home.</p><p>But how the future of IOT will be like is those electronic devices will be automatically controlled by the climatic conditions, environment and also give us even more comfort. For example, the fan can adjust the speed itself according to the weather in your location, washing machines will automatically switch on itself after all the clothes are loaded, AC will automatically switch on itself by sensing the hot climate outside and also the light can reduce the intensity based on the light available inside the room. All the devices would work only when at least on person is inside the house.</p><p>In future IOT will be widely used in banking sectors, retail sector, sports training, farming, manufacturing sectors. The cyber threat will be very dangerous and overcoming that will be a very big problem in future.</p><p>Definitely IOT are going to make us more lazy than ever and give us a lot of comfort and also we should be aware of the cyber threats that could happen due to the lack of enough idea on the technology.</p><p>It is very important that everyone should have some basic idea about IOT. Also only Fourier series alone cannot help the entire IOT transition in our world. We need a lot of semiconductor devices, sensors and transducers and most importantly data. We should also be aware that many countries are closing their manufacturing units due to unavailability of the semiconductor chips. So the country which becomes the semiconductor manufacturing hub of the world will become very rich and dominant.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ef3064281f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why everyone is going behind bitcoins? Why is Elon musk being an ambassador for bitcoin?]]></title>
            <link>https://medium.com/@venkykasprov/why-everyone-is-going-behind-bitcoins-why-is-elon-musk-being-an-ambassador-for-bitcoin-54b07f30efc7?source=rss-bf026e02f724------2</link>
            <guid isPermaLink="false">https://medium.com/p/54b07f30efc7</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[elon-musk]]></category>
            <category><![CDATA[india-on-cryptocurrency]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[venkatasubramani karthikeyan]]></dc:creator>
            <pubDate>Sun, 02 May 2021 18:27:19 GMT</pubDate>
            <atom:updated>2021-05-02T18:27:19.877Z</atom:updated>
            <content:encoded><![CDATA[<p>Today the time when I started writing this blog. The cost of 1 bitcoin is around 42lakh Indian rupees. Everyone will be thinking what is a bitcoin? Is it a real coin? Why is it valued so high?</p><p>To know the answers for all those questions, you need to know a technology called block chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNx9EgUhEHe8N0ckRCm8UQ.jpeg" /></figure><p>To know what is block chain, you need to know what is a block? To know what is a block you need to know what is a transaction?</p><p>So let’s start, transaction is where there is a sender, receiver and amount (currency). When the sender is sending currency to the receiver and the receiver is receiving the currency, then the transaction is completed. So what a block will contain is an unique (anonymous) ID for sender and receiver and also the amount that has been transferred. The block can hold upto 2000 transaction details. If all the 2000 transaction details are stored then it adds a new block in chain to the old block. Forming a huge chain with millions of blocks is called Blockchain</p><p>All those information in the blocks are stored forever. Most important thing is, while transfering currency through Blockchain. If you have mistakenly sent to someone. You can never get it back, unless the receiver sends you.</p><p>Now we will come to bitcoin. This bitcoin is a decentralised currency. That means no government can take the ownership of this currency. If no government is taking the ownership? Then why should I even use that currency?</p><p>To know answers to these questions, we need to know, these bitcoins are not actually physical coins but they are digital currencies and also how this bitcoin works. I don’t want you to bore you with the history of bitcoins rather that I would tell you how it works. To know how it works, we need to know four important things.</p><ol><li>Block chain</li><li>Miner</li><li>Running Node</li><li>Wallet</li></ol><p>Now we already know what is a block chain. Miner is a set of people who are involved in creating the cryptocurrency. There would be a math problem that cannot be solved by a single computer. Those problems are designed in a manner that every miners computer is used to solve the math problem. The computers that work on solving this math problem are called running Node. On solving the math problem, then 50 bitcoins would be added to the wallet. So Wallet is where our bitcoins will be stored.</p><p>Then everyone will think so if the number of miners are increased then we can easily mine more bitcoins right? It is not so because when the miners are increasing the difficulty of the math problems are also increased and the mining time remains the same.</p><p>We need to know another important term called bitcoin halving. So basically, the bitcoin halving is done for every once in four years (I.e: after creating 2,10,000 blocks) . As I told above that on solving a problem 50 bitcoins will be added to the wallet. From 2008–2012 it was adding 50 bitcoins to the wallet. From 2012–2016 it was adding 25 bitcoins to the wallet. 2016–2020 it was adding 12.5 bitcoins to the wallet and now currently it is adding 6.25 bitcoins to the wallet.</p><p>The total number of bitcoins that can be mined are 21 millions. Till date it has mined around 18.5 million bitcoins. Just 3.5 million bitcoins are yet to be mined but the problem is here we are using the reverse compounding effect. So the complete mining of the bitcoin would end after 120 years. That is in the year 2128. This happens because every once is four years we are halving the bitcoin.</p><p>Now a great entrepreneur like Elon Musk has bought a huge amount of bitcoin and also many companies and also some financial institutions have started investing a lot in cryptocurrency.</p><p>Why did they invest in this or why should someone consider to invest in bitcoins?</p><p>Everyone can invest in bitcoins because of 2 main reasons.</p><ol><li>Bitcoin has been globally accepted as a medium of exchange.</li><li>It is also considered as an asset, similar to gold. When you purchase 1gm of gold and put it in a locker after few years it be just 1gm again but the value of the asset raises over the time.</li></ol><p>Why should someone not consider to invest in it?</p><ol><li>Even though the currency rate cannot be modified by the government. The government can decide to ban the cryptocurrency in their country.</li><li>These Blockchain technology works well only when all the users are actively accepting this cryptocurrency as a medium of exchange. Now many people are accepting but later some people may not.</li></ol><p>What is my final insight is as many companies have already started investing huge amount on cryptocurrency and accepting as a medium of exchange. Now it will be very easy to trade all the products and services from one country to another with a common currency.</p><h3>Will India ban on cryptocurrency?</h3><p>The countries which are banning the cryptocurrency will face a very big issue in the trading thier products and services in the international market in future.</p><p>It will be like all the countries end using bitcoins or all the countries accept using bitcoins. If not then there will be a issue in the business and especially the trade between two countries.</p><p>This cryptocurrency is more volatile than the share market. So take calculated risks to invest in the cryptocurrency. Many experts say that, most probably the value of bitcoin can touch 1 crore by the next decade.</p><p>There are also lot of counties wanting to avoid cryptocurrency because they cannot be monitored from their point of view.</p><p>You can buy bitcoins in a fraction as low as 500 rupees. But if you wish to invest all your wealth, you can directly play gambling sport betting all your wealth so that you could know the result as early as possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54b07f30efc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Machines can replace humans in all the fields?]]></title>
            <link>https://medium.com/@venkykasprov/how-machines-can-replace-humans-in-all-the-fields-8d776f8a1839?source=rss-bf026e02f724------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d776f8a1839</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[venkatasubramani karthikeyan]]></dc:creator>
            <pubDate>Wed, 28 Apr 2021 11:03:15 GMT</pubDate>
            <atom:updated>2021-04-28T11:03:15.434Z</atom:updated>
            <content:encoded><![CDATA[<p>The decisions made by humans are done by seeing the data around us. We try to link the data, what we see around us, how we feel, what is the impact of us on environment and vice versa.</p><p>Now the machines can also do almost everything we do. Those who think that my work is not repetitive so my work cannot be replaced by machines. This article is for you.</p><p>What ever decision we make can be imitated by the machines. They follow different types of algorithm to achieve the results. As I told that we are making all our decisions on data. Similarly the machines too would.</p><p>We can briefly classify all the algorithm into three different types.</p><ol><li>Classification.</li><li>Regression.</li><li>Clustering.</li></ol><h3>Classification :</h3><p>Where the computer will try to classify the data based on the behaviour. For example, we are having two jars. One contains apple and other contains orange. Suddenly you see an orange somewhere down. What would you do? May be if I would have seen that probably I would have eaten that orange. But few people tend to take that orange and put it back to the jar containing orange. Here we are making the decision to take the oranges to put it inside the jar containing orange instead of apple.</p><p>So from the above example, when you have all the possibilities in front of you and you need to choose one. This is known as classification algorithm.</p><h3>Regression:</h3><p>Regression is used when we have to decide or calculate something in numbers. For example, the multiplication tables we use in our day to day life. If 1 apple cost 10 rupees then how much does 5 apple cost? So we would say 50 rupees.</p><p>So from the above example, when you need to calculate and need a numerical value as a decision then you need to apply math and statistics to find the value. In more precise when you know the physics formulae, basic mathematics formula and what to find using what. This is known as regression algorithm.</p><h3>Clustering:</h3><p>Clustering is grouping something based on some features. For example, In India we have something called states and central. India is divided into many states based on language, culture, festival etc.</p><p>So from the above example, when you need to segregate large data into few groups. In order to understand their features even more clearly. This is known as clustering algorithm.</p><p>Almost all the decisions taken by human beings are also following any one of the algorithm above. In that case why is that humans are making mistakes?</p><p>Here is the answer after all we are humans and we tend to make mistakes. If the floor is slippery and you fall down once or see someone else fall down and then from the next time onwards you will be cautious. It’s not that machines can never make a mistake. Even they will also make mistake, if they don’t have enough data as we do!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d776f8a1839" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>