<?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 Pablo Gonzalez on Medium]]></title>
        <description><![CDATA[Stories by Pablo Gonzalez on Medium]]></description>
        <link>https://medium.com/@pgonzalezcarrizo?source=rss-5f1245838208------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2-4uLPMj0-hKfoT8.</url>
            <title>Stories by Pablo Gonzalez on Medium</title>
            <link>https://medium.com/@pgonzalezcarrizo?source=rss-5f1245838208------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 10:46:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pgonzalezcarrizo/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[Introduction to BigML: Our first Kaggle submission without writing a line of code]]></title>
            <link>https://medium.com/@pgonzalezcarrizo/introduction-to-bigml-our-first-kaggle-submission-without-writing-a-line-of-code-5f5ad4a4ca62?source=rss-5f1245838208------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f5ad4a4ca62</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[bigml]]></category>
            <dc:creator><![CDATA[Pablo Gonzalez]]></dc:creator>
            <pubDate>Tue, 31 Jul 2018 22:00:00 GMT</pubDate>
            <atom:updated>2018-08-02T13:39:55.554Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we will learn how to create a Deep Learning model, and make a Kaggle submission for a competition <strong>without writing a line of code</strong>. Yes, it is possible! <a href="https://bigml.com/">BigML</a> helps us to do it.</p><p><strong>Warning</strong> This post is not a tutorial, I will omit some information about how things are done. It´s just a demostration of how powerful can this tool be. In 3 or 4 hours, you can know perfectly all the platform with <a href="https://youtube.com/playlist?list=PL1bKyu9GtNYHAk0PUojkLYZzASoYVcsTQ">these videos</a></p><h3>What is BigML</h3><p>BigML is a Machine Learning platform with a simple and clear mission: make Machine Learning easy, beautiful, and understandable for everybody. Without any profound knowledge of Machine Learning, and in just 3 or 4 clicks, as we will see later, you can create a ML model with a performance similar to the state-of-the-art-models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*MPmZDpSRafht3Pqr.png" /></figure><h3>Creating our dataset</h3><p>We want to make a submission to <a href="https://kaggle.com/c/fake-news">this <strong>fake news</strong> detection competition</a>. Seems to be a big challenge! First of all, we will download <strong>train.csv</strong> and <strong>test.csv</strong> files from Kaggle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/0*9BRti6FdENhnZF9z.png" /></figure><p>Now, we should upload them to BigML. BigML distinguishes between <strong>Sources</strong> and <strong>Datasets</strong>, so, the first thing we should do is uploading the CSV files to Sources. We will navigate to the <a href="https://bigml.com/dashboard">Dashboard page</a> and click on the <strong>Sources</strong> tab. Then, we will upload our <strong>train.csv</strong> and <strong>test.csv</strong> files. We will rename the sources to <strong>FakeNews</strong> and <strong>FakeNews Kaggle Test</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/0*jREXRG5oVqiKt23V.png" /></figure><p>After making some comprobations of the data type of all fields, we sould click on <strong>1-Click dataset</strong> to create our dataset from each one of the sources. Now, our datasets will appear on <strong>Datasets</strong> tab. If we click on one of them, we can see some useful information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/0*d2WSgIGrDxwO5epM.png" /></figure><p>Creating train/test split is as easy as clicking this button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/0*B9l_mvdtq3GlByHL.png" /></figure><h3>Creating Deep Learning Model</h3><p>Creating our <strong>Deep Neural Network model</strong> will only consist on clicking this icon in the training dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/0*0CnJv-kcjXv5zl3V.png" /></figure><p>Only one click to create a fully functional deep learning model!</p><p>If we open <strong>Deepnets</strong> option inside Supervised menu tab, we will see <em>after some minutes</em> our model. With only one more click, we will be able to perform the evaluation, using the test dataset (the one that comes from the train/test split). Actually, this would be <strong>Validation</strong> dataset. The <strong>Test</strong> dataset would be the one that we have obtained, without labels, from Kaggle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/0*pr87iN5IJ9uSLrU6.png" /></figure><p>As we can see, we have achieved an accuracy of 97.7% in the test set. Taking into account that we have made 5 or 6 clicks, this is such a very good result!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/0*CguUMShRWfcc9GQq.png" /></figure><p><strong>Info</strong> You can use <strong>OptiML</strong> to automatically find the best model and hyperparameters.</p><h3>Test prediction</h3><p>Finally, let´s test our model with the Kaggle test dataset. We will click on <strong>Create Batch Prediction</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/0*uLsqug1OcugHBNxg.png" /></figure><p>We will configure it to generate the output needed for the competition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/0*3wQtS1haXpsIpdtK.png" /></figure><p>After the evaluation is finished, we should click on <strong>Download batch prediction</strong> and upload the generated CSV into the Kaggle competition submission tab. <strong>We have achieved an score of 0.97564</strong> so we would be in the <strong>third position of the ranking</strong> with only one submission!</p><p>Sadly, the competition finished few months ago…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/0*tgRxHB0KHnyEdEBI.png" /></figure><h3>One more thing…Topic modelling</h3><p>BigML has also some very interesting <strong>Unsupervised Learning tools</strong>. We will try one of them: <strong>Topic Model</strong>. This is a clustering algorithm that creates groups of similar words (that belongs to the same topic). We want to see the most usual topics of fake news. We will start filtering only fake news.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/0*8_76wzSYG_J3sipq.png" /></figure><p>We will use this filter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/0*8k2vCkbnas9k1efW.png" /></figure><p>With this new dataset, we will create a <strong>Topic Model</strong> with these options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/0*9JAeCTShIU2Qk0za.png" /></figure><p>As we can see below, there are 6 different groups of words, relationated to 6 different topics. We have manually assigned a name to each topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/0*2LEvXysr9B5yaLH0.gif" /></figure><p>Let´s see how powerful is this tool, Let´s write some invented titles, and see how the model is able to classify them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/0*Pp-XtMjcmEVBPcGJ.gif" /></figure><p><em>Originally published at </em><a href="https://unmonoqueteclea.github.io/deep-learning/bigml/kaggle/bigml/"><em>unmonoqueteclea.github.io</em></a><em> on July 31, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f5ad4a4ca62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chiquito Or Not: Deep Learning para detectar imágenes de Chiquito de la Calzada]]></title>
            <link>https://medium.com/@pgonzalezcarrizo/chiquito-or-not-deep-learning-para-detectar-im%C3%A1genes-de-chiquito-de-la-calzada-97cf697e5e0c?source=rss-5f1245838208------2</link>
            <guid isPermaLink="false">https://medium.com/p/97cf697e5e0c</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Pablo Gonzalez]]></dc:creator>
            <pubDate>Wed, 18 Jul 2018 22:00:00 GMT</pubDate>
            <atom:updated>2018-07-22T12:17:03.760Z</atom:updated>
            <content:encoded><![CDATA[<p>Hoy vamos a hacer nuestro primer proyecto basado en <strong>Deep Learning</strong>, y como la ocasión lo merece, el clasificador que realizaremos será capaz de detectar imágenes en las que aparezca <strong>Chiquito de la Calzada</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*K_u82OAozrzzEgLN.gif" /></figure><p>Para ello, vamos a usar la librería de <a href="http://fast.ai/"><strong>Fast AI</strong></a>. Esta librería, que funciona sobre <a href="https://pytorch.org/"><strong>PyTorch</strong></a>, nos ofrece funciones de muy alto nivel que encapsulan una gran cantidad de líneas de código para realizar proyectos de Deep Learning. Como veremos después, con 3 líneas de código podemos realizar un clasificador que nos proporcione unos resultados bastante decentes. Este artículo está basado en las dos primeras lecciones del curso <a href="http://course.fast.ai/">Practical Deep Learning for Coders</a>.</p><p><strong>Info</strong> Este artículo requiere unos ciertos conocimientos básicos previos de Machine Learning y de Deep Learning.</p><p>Con este método conseguiremos un <strong>porcentaje de acierto del 98%</strong>.</p><p><strong>Info</strong> La libreta de Jupyter que acompaña a este artículo se puede descargar y consultar <a href="https://colab.research.google.com/drive/1euOY5_mxvJv7RQwMtKo1QWU3Vhog6yEa">aquí</a>.</p><h3>Obteniendo imágenes</h3><p>Por desgracia, que sepamos, no existe ningún dataset público de imágenes de Chiquito. Por lo tanto, tendremos que obtener nosotros todas las imágenes que podamos. Por suerte, alguien pensó en nosotros y creó <a href="https://github.com/hardikvasa/google-images-download">esta librería</a> que permite automatizar la descarga de imágenes de Google Imágenes.</p><p>La librería es muy fácil de usar. La instalaremos mediante <strong>pip</strong>:</p><pre>pip install google_images_download</pre><p>Tras ello, crearemos nuestro archivo de configuración, que llamaremos <strong>config.json</strong>, y tendrá el siguiente contenido:</p><pre>{ &quot;Records&quot;: [ <br>   {&quot;keywords&quot;: &quot;chiquito de la calzada&quot;, <br>    &quot;limit&quot;: 800, <br>    &quot;print_urls&quot;: true,       <br>    &quot;chromedriver&quot;:&quot;C:\\path\\to\\chromedriver.exe&quot;                                                              <br>   } <br>]}</pre><p>Con esta configuración, estamos diciendo al programa que queremos que realice una búsqueda del término “<em>chiquito de la calzada</em>” en Google Imágenes y descargue hasta 800 imágenes. Además, le tenemos que pasar la ruta del <strong>chromedriver</strong>, que en caso de no tenerlo, lo podemos descargar de <a href="http://chromedriver.chromium.org/">aquí</a>.</p><p>Tras ello, habrá que escribir lo siguiente en la consola de <strong>Anaconda</strong> (Yo uso Anaconda, pero esto no es un requisito indispensable):</p><pre>googleimagesdownload -cf config.json</pre><p>Si no estamos en el mismo directorio que nuestro archivo <strong>config.json</strong> habrá que especificarle la ruta completa.</p><p>Tras unos minutos, tendremos una carpeta llena de fotos de Chiquito de la Calzada. <strong>Haremos una pequeña limpieza de los datos</strong>, eliminando fotos con formatos no válidos (<em>.gif</em>) o que tienen mala profundidad de color (8 bits). Además tendremos que fijarnos, porque puede que Google nos haya colado alguna imagen que en realidad no sea de chiquito.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oUu0_P1Ksl6r9-0h.png" /></figure><p>Como siempre, para entrenar nuestro clasificador necesitaremos ejemplos positivos y ejemplos negativos. Por lo tanto, necesitamos imágenes donde NO aparezca chiquito. Para ello, hemos usado el dataset <strong>Labeled Faces in the Wild</strong>, que podemos descargar <a href="http://vis-www.cs.umass.edu/lfw/lfw.tgz">aquí</a>. Este dataset contiene fotos de las caras de 1680 famosos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*UkPSNzqjtSTqHoqg.jpg" /></figure><p>Al descargarlo, vemos que existe un nuevo problema, las imágenes están en subcarpetas con el nombre de cada personaje. Necesitamos tener todas las imágenes en la misma carpeta por lo que he realizado este pequeño script para esta tarea:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54607b4d14ee4e186165b8bbbeed7b80/href">https://medium.com/media/54607b4d14ee4e186165b8bbbeed7b80/href</a></iframe><p>Con este script, tomamos 270 imágenes aleatorias y las pasamos a una misma carpeta. Para tener un dataset bien balanceado, deberemos tener el mismo número de muestras positivas que negativas, es decir, el mismo número de imágenes de chiquito, que de otro tipo.</p><p>Hay otra última cosa que tenemos que hacer para tener nuestro dataset preparado. Nuestro dataset debe estar compuesto por las carpetas <strong>train</strong> y <strong>valid</strong>. Cada una de ellas, contendrán a su vez las carpetas <strong>chiquito</strong> y <strong>not</strong>. Pasaremos 220 imágenes de cada tipo a la carpeta de entrenamiento (train) y 50 imágenes de cada tipo a la carpeta de validación (valid). Si tienes alguna duda, puedes descargar el <a href="https://github.com/unmonoqueteclea/DeepLearning-Notebooks/blob/master/ChiqutoOrNot/dataset.zip?raw=true">dataset de ejemplo</a>.</p><h3>Creando nuestro clasificador</h3><p>Para no hacer un artículo demasiado largo, vamos a poner sólo las principales instrucciones. Para reproducir por completo todo el proceso, recomendamos ver la <a href="https://colab.research.google.com/drive/1euOY5_mxvJv7RQwMtKo1QWU3Vhog6yEa">libreta de Jupyter en Google Colab</a>, donde está todo el proceso comentado.</p><p>Comenzamos importando todos los módulos necesarios y le pasamos la ruta de nuestro dataset. Además, configuraremos el tamaño de imágenes que usará la librería.</p><p>Utilizamos una técnica basada de <strong>Transfer Learning</strong>, es decir, partimos de un modelo pre-entrenado, y con los pesos <em>congelados</em> y añadimos después una capa cuyos pesos entrenaremos con nuestro dataset. Partimos de la arquitectura <a href="https://arxiv.org/abs/1512.03385">resnet</a>, que es utilizada en multitud de ocasiones en este tipo de tareas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/0*dOK7qR6XCR7VJIvQ.jpg" /></figure><p>En las dos últimas línea estamos utilizando una característica de la librería <strong>Fast AI</strong> que nos permite ver cómo se comporta nuestro modelo en función del learning rate elegido.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5723457ea723f4b746b5b93cdbea9fcd/href">https://medium.com/media/5723457ea723f4b746b5b93cdbea9fcd/href</a></iframe><p>Del código anterior, obtenemos la siguiente gráfica:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*KOGGPxZmzVvTbaCd.png" /></figure><p>Basándonos en el paper <a href="http://arxiv.org/abs/1506.01186">Cyclical Learning Rates for Training Neural Networks</a>, escogeremos <strong>0.01</strong> como valor máximo para nuestro <strong>learning rate</strong>, pues es el valor más alto, para el que el error sigue descendiendo. Ahora, simplemente tendremos que escribir la siguiente línea para entrenar nuestra red:</p><pre>learn.fit(0.01, 2)</pre><p>Es importante recordar, que los pesos de nuestra red están <em>congelados</em>, por lo que únicamente estamos entrenando la última capa. Aún así, podemos ver que conseguimos una <strong>precisión del 92%</strong>. No está nada mal.</p><h3>Data Augmentation</h3><p>Una posible opción para mejorar nuestra precisión final, es realizar la tarea conocida como <strong>Data Augmentation</strong>. Esta tarea consiste en la ejecución de operaciones como rotación, translación y zoom de forma aleatoria sobre las imágenes. Con esto conseguimos evitar el <strong>overfitting</strong> (que nuestra red se aprenda las imágenes y no sea capaz de generalizar). Si le pasamos a la red versiones modificadas de la misma imagen, ésta será capaz de aprender características intrínsecas del objeto, y será capaz de generalizar mejor. En la siguiente imagen podemos ver el resultado de aplicar esta técnica a una foto en concreto.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*JZ1SMNaSouwpNP1d.png" /></figure><p>Tras ello, volveremos a entrenar nuestra red, obteniendo ahora un <strong>95% de eficacia</strong>.</p><pre>tfms = tfms_from_model(resnet34, sz, aug_tfms=transforms_side_on, max_zoom=1.3) <br>data = ImageClassifierData.from_paths(PATH, tfms=tfms) <br>learn = ConvLearner.pretrained(arch, data, precompute=False) learn.fit(1e-2, 4, cycle_len=1)</pre><h3>Fine tunning</h3><p>La última técnica que aplicaremos para mejorar aún más nuestra eficacia, es la conocida como <strong>fine tunning</strong>. Lo que haremos es <em>descongelar</em> los pesos de las capas convolucionales, para que la red completa pueda ser entrenada. Sin embargo, estos pesos contienen información que nos puede ser de gran utilidad. Además, sabemos que las primeras capas de una red convolucional tienen información más general, que va siendo más específica según vamos avanzando a capas posteriores. Es por ello por lo que definiremos un array con 3 learning rates distintos, siendo el más bajo, el de la primera capa. De esta forma, nos aseguramos realizar <em>pequeños retoques</em> sin perder el conocimiento general de la red.</p><pre>learn.unfreeze() <br>lr=np.array([1e-4,1e-3,1e-2]) <br>learn.fit(lr, 3, cycle_len=1, cycle_mult=2)</pre><p>Tras esto, conseguimos un <strong>porcentaje de acierto del 98%</strong>. Como vemos en la matriz de confusión de abajo, nuestra red sólo falla con 2 de las imágenes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*zJ1c8g4hCgFzvna3.png" /></figure><p>¡No está nada mal para ser nuestra primera aproximación al Deep Learning! ¡Ya estamos preparados para hacerle competencia a <strong>Hot Dog Or Not</strong>!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FvIci3C4JkL0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DvIci3C4JkL0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FvIci3C4JkL0%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/65750c83b974f395e5dce190cf7e21a3/href">https://medium.com/media/65750c83b974f395e5dce190cf7e21a3/href</a></iframe><p><em>Originally published at </em><a href="https://unmonoqueteclea.github.io/deep-learning/chiquito/"><em>unmonoqueteclea.github.io</em></a><em> on July 18, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97cf697e5e0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>