<?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 Hugo Abreu on Medium]]></title>
        <description><![CDATA[Stories by Hugo Abreu on Medium]]></description>
        <link>https://medium.com/@hugoabreu1002?source=rss-b6f45123d013------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JaDZys3QUkONTTr0PmFCdQ.jpeg</url>
            <title>Stories by Hugo Abreu on Medium</title>
            <link>https://medium.com/@hugoabreu1002?source=rss-b6f45123d013------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 17:48:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hugoabreu1002/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[SARIMAX — ACO Search]]></title>
            <link>https://hugoabreu1002.medium.com/sarimax-aco-search-2b698a00289e?source=rss-b6f45123d013------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b698a00289e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[optimization-algorithms]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <category><![CDATA[sarimax]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Hugo Abreu]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 19:20:51 GMT</pubDate>
            <atom:updated>2020-12-23T21:48:43.273Z</atom:updated>
            <content:encoded><![CDATA[<h3>SARIMAX — ACO Search</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*SMaQdLuK7IAqm2W7ue1YTw.png" /></figure><p>Hello,</p><p>I want to share with you guys a very usefull implemantation of ACO Algorithm.</p><p>In Machine learning, more specifically SARIMAX is a time series model that uses Seasonal Information and Exogenous Variables to perform a forecast, diferent from ARIMA wich only uses old data from the series itself to predict the future. As I like to make my article very simple, and don’t like repetitions of informations, you can read more about SARIMAX models in here: <a href="https://www.statsmodels.org/dev/examples/notebooks/generated/statespace_sarimax_stata.html">https://www.statsmodels.org/dev/examples/notebooks/generated/statespace_sarimax_stata.html</a></p><p>In python there is some implementations of autoarima, in a package called <a href="https://github.com/alkaline-ml/pmdarima">pmdarima </a>that perforces an autoarima, using the same algorithm as in R <a href="https://otexts.com/fpp2/arima-r.html">autorima</a>.</p><p>Ok, thats good for arima, but for SARIMAX there’s no automation at this same level of popularity, at leat none that I know (if you know, please leave a comment). So, my intention is to use ACO (Ant Colony Optimization) to implement an autosarimax.</p><p>The code bellow is an ACO.py implementation. The algorithm consists of ants whose depose on the points of the graph some ferormone based in the fitness function evaluated for the X represent by the point on the graph.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/196431f5b1b8e8ceee9adcd2a883e877/href">https://medium.com/media/196431f5b1b8e8ceee9adcd2a883e877/href</a></iframe><p>I have an example of how to use the ACO optimization algorithm over an function, please take a look.</p><p><a href="https://github.com/hugoabreu1002/mlopt/blob/master/examples/ACO.ipynb">hugoabreu1002/mlopt</a></p><p>Knowing that the ACO can optimize a function looking over a discrete space, the challenge was to implement a SARIMAX_ACO_Search function to use the SARIMAX output from each graph possibiliy and update the informations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6998a50b2e67585e1207618a015adb1a/href">https://medium.com/media/6998a50b2e67585e1207618a015adb1a/href</a></iframe><p>Some functions called from the code above are token from my <a href="https://github.com/hugoabreu1002/mlopt/blob/master/TimeSeriesUtils.py">TimeSeriesUtils.py</a>.</p><p>Finally I made an <a href="https://github.com/hugoabreu1002/mlopt/blob/e5e1b7b0d0db56586339edb7fcde3680150cfcaf/examples/SARIMAX-ACO-Search.ipynb">example </a>on how to use the sarimax_aco_search to find the best sarimax model for some fake arrays.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b698a00289e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing SkLearn Ensembles (with homogeneous weights)]]></title>
            <link>https://medium.com/analytics-vidhya/optimizing-sklearn-ensembles-with-homogeneous-weights-2db698a72b7a?source=rss-b6f45123d013------2</link>
            <guid isPermaLink="false">https://medium.com/p/2db698a72b7a</guid>
            <category><![CDATA[sklearn]]></category>
            <category><![CDATA[genetic-algorithm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ensemble-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Hugo Abreu]]></dc:creator>
            <pubDate>Mon, 28 Oct 2019 14:23:42 GMT</pubDate>
            <atom:updated>2019-11-07T08:26:06.126Z</atom:updated>
            <content:encoded><![CDATA[<h3>Optimizing Sklearn Ensembles (with homogeneous weights)</h3><p>Everybody knows the incredible potential of Python’s Scikit-Learn package. Among its resources, there is a type of regressor that acts by voting (averaging) of a committee of regressors. That is the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.VotingRegressor.html">Voting Regressor</a>.</p><p>In this short article I’ll show one way to chose the best regressors to integrate a committee or regressors with Genetic Algorithm.</p><p>First, what will the Genetic Algorithm optimize ? — The parameters of every regressor in a regressors set, than it will look for the best set of regressors to integrate the committee. So let’s get it started.</p><p>I’ll be making a Python class caled <strong>ensemble_search.</strong></p><pre>import numpy as np<br>import random<br>from tqdm import tqdm<br>from sklearn.metrics import mean_absolute_error as mae<br>from sklearn.metrics import mean_squared_error as mse<br>from sklearn.linear_model import LinearRegression as LR<br>from sklearn.ensemble import RandomForestRegressor as RFR<br>from sklearn.svm import SVR <br>from sklearn.ensemble import AdaBoostRegressor as ADA<br>from sklearn.ensemble import BaggingRegressor as BAG<br>from sklearn.ensemble import GradientBoostingRegressor as GBR<br>from sklearn.linear_model import RANSACRegressor as RAN<br>from sklearn.linear_model import PassiveAggressiveRegressor as PAR<br>from sklearn.linear_model import SGDRegressor as SGD<br>from sklearn.model_selection import train_test_split<br>from sklearn.ensemble import VotingRegressor<br>from sklearn.datasets import make_regression<br>from sklearn import preprocessing</pre><p>Above is the packages and regressors models that will be using. The more regressors models, the best.</p><p>This class will be initialized with the train/test parts of your data, the size of your population and the max number of epochs you want it to be run.</p><p>The full code of the class and an example of how to run it over some regression data is shown below. Each method is explained latter down. Here is a link for the <a href="https://github.com/hugoabreu1002/Optimizaded_Ensemble_Sklean">code</a> in github.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/616e6459855f4850dfb9450942ae5b29/href">https://medium.com/media/616e6459855f4850dfb9450942ae5b29/href</a></iframe><p>The <strong>gen_population</strong> as it says, is used to generate the population, which is a list of lists. Every list inside the population list is made of another list, now of regeressors names, objects and its parameters (which is a dictionary). The individual (list) inside the population (list) is the concatenation of a number of models, that are further parametrized in a for loop. The models can be repeated.</p><p>Every individual in the population is initialized with some random parameters. The number of regressors is also a parameter to be optimized.</p><p>The <strong>set_fitness</strong> method is used to give to each individual of the population one fitness value, here it is used the MAE (Mean Absolute Error) between the predicted regression and the real y set (y_test).</p><p>The <strong>next_population </strong>method role is to perform the crossover on the population. Before the call of this method, the population must be sorted from the best individual to the worst. Than, the method, mix the parameters of each regressor inside of the individuals of the population.</p><p><strong>early_stop </strong>is to stop the algorithm before it completes all epochs, the algorithm is only stopped if the fitness over epochs reaches a minimum. The mean of the last 2 second derivative are greater than zero, and the mean of the first derivative is close to zero.</p><p><strong>search_best </strong>is the method that sticks everything together, generating the population for a given size, setting the fitness for every individual in the population, sorting the individuals to know the best and worst and perform the crossover. All those steps are done in a loop while the max number of epochs or stop condition are not reached.</p><p>Finally, to see if the algorithms works, one test is made over a make_regression sample.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2db698a72b7a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/optimizing-sklearn-ensembles-with-homogeneous-weights-2db698a72b7a">Optimizing SkLearn Ensembles (with homogeneous weights)</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>