<?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 Arnaud Zinflou on Medium]]></title>
        <description><![CDATA[Stories by Arnaud Zinflou on Medium]]></description>
        <link>https://medium.com/@azinflou?source=rss-fa228fa48935------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*v527vlEy8lSVEwke.</url>
            <title>Stories by Arnaud Zinflou on Medium</title>
            <link>https://medium.com/@azinflou?source=rss-fa228fa48935------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 02:57:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@azinflou/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[TensorFlow Dev Summit 2019 wrap-up]]></title>
            <link>https://medium.com/data-science/tensorflow-dev-summit-2019-wrap-up-a43ec2e5845a?source=rss-fa228fa48935------2</link>
            <guid isPermaLink="false">https://medium.com/p/a43ec2e5845a</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Arnaud Zinflou]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 21:45:23 GMT</pubDate>
            <atom:updated>2019-03-18T22:58:49.195Z</atom:updated>
            <content:encoded><![CDATA[<h3>2019 <strong>TensorFlow Dev Summit wrap-up</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*ljBeejObosvC0jKIaxJl-w.png" /></figure><p>For the second consecutive year, I was lucky enough to attend the <a href="https://www.tensorflow.org/dev-summit/">TensorFlow dev Summit</a> on March 6th — 7th at the Google Event Center in Sunnyvale, California USA. Last year, I was impressed by the organization, the venue, the schedule, the speakers and I think this year was even better. So once again, congratulations to the Google and TensorFlow teams for organizing such an amazing event!</p><p>TensorFlow Dev Summit still brings together a diverse mix of machine learning users from around the world; now for two days instead of one. The first day was full of technical talks, demos, new product announcements and other improvements to the framework, whereas the second day focused on lightning talks, hands-on sessions where attendees can code along with the TensorFlow team members.</p><p>There are a number of interesting things to say about this event so in this post, I will share my personal notes and briefly summarize what has caught my attention the most.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*92G54oait_RDnQsgZ3XgnA.png" /></figure><h3><strong>Day 1- March 6th</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*KyDEITcDDmL91GyX0hLV0A.png" /></figure><h4>TensorFlow 2.0</h4><p>In TensorFlow 2.0, the focus has been around making the API simpler, and more natural. The API components integrate better with Keras and, by default, the eager mode is activated. With 2.0, you can use Keras as you know it, building your models with the Sequential API, and then using compile and fit. Keras’s fit() will work for many cases; however, if needed, many more options are available. In the recent past, you needed to be familiar with <em>tf.where,</em> <em>tf.select</em> in order to write the conditions and it could have been hard to write a complex control flow as a TensorFlow graph. With 2.0, you can simply use the decorator <em>@tf.function</em> to write a complex control flow as TensorFlow graph. <em>tf.function</em> is just decorator to be attached to the Python function. TensorFlow compiler automatically resolves the dependency on the Tensor and creates the appropriate graph. That makes the development far easier to understand and use since we can now write the control flow of TensorFlow graphs as we write a “standard” Python code.</p><pre>a = tf.constant([1, 2])<br>b = tf.constant([3, 4])<br>print(a + b)<br># returns: tf.Tensor([4 6], shape=(2,), dtype=int32)</pre><p>The magic is achieved under the hood by overloading some method like <em>__if__</em> or <em>__while__ </em>for example. So overall you do not need to write anymore :</p><pre>tf.session.run<br>tf.control_dependencies<br>tf.global_variables_initializer<br>tf.cond, tf.while_loop</pre><p>Along with the 2.0, the team also launched <a href="https://medium.com/tensorflow/introducing-tensorflow-datasets-c7f01f7e19f3">TensorFlow Datasets</a>, a collection of commonly used ML datasets prepared and exposed as tf.data.Datasets or NumPy arrays for easy use in TensorFlow. In addition, they also provide conversion and migration tools to help with the transition from 1.x code to 2.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*ix_uWAdHBCw-GhXeRBiGKQ.png" /><figcaption>TensorFlow Datasets &amp; TensorFlow Probability</figcaption></figure><p>Others add-ons and extensions :</p><ul><li>TensorFlow Agents: library for reinforcement learning</li><li>TF Federated : a library for federated learning to take advantage of decentralized data (i.e. data in different locations)</li><li>TF Privacy : a library with tools to help train models with differential privacy</li><li>Mesh TensorFlow: a library to build and train massively large-scale models using parallelism technique</li><li>TensorFlow Probability: probably one of the most exciting add-ons in my opinion, TensorFlow Probability is a library for using probabilistic methods in ML models for making predictions dealing with uncertainty and incorporating domain knowledge.</li></ul><p>These and many more resources, examples, documentation, and case-studies on TensorFlow can be accessed from the <a href="https://www.tensorflow.org/">tensorflow.org</a> website.</p><p><a href="https://www.linkedin.com/feed/update/urn:li:activity:6509288966850703360">Arnaud Zinflou on LinkedIn: &quot;Another really interesting small video from the #TFDevSummit keynote today&quot;</a></p><p><strong>TensorFlow Extended</strong></p><p>One of my favourite add-ons to TensorFlow ecosystem is TensorFlow Extended (TFX). TFX brings the management of the entire machine learning lifecycle to users. It has several component libraries including :</p><ul><li>TensorFlow Data Visualization(TFDV) for monitoring and validating ML data at scale.</li><li>TensorFlow Transform for preprocessing tasks such as tokenization and format conversions.</li><li>TensorFlow Model Analysis (TFMA) to enable developers to calculate and visualize model evaluation metrics.</li><li>TensorFlow Serving for serving ML model and support versioning and multiple models support</li></ul><p>And as a bonus, it now integrates with open source orchestrators such as <a href="https://airflow.apache.org/">AirFlow</a> and <a href="https://github.com/kubeflow/kubeflow">KubeFlow</a>.</p><p><strong>TensorFlow Lite</strong></p><p>Launched last year, TensorFlow Lite (TFLite) is a lightweight solution for on-device inference. According to Google, TFLite is now running on more than 2 billion mobile devices — leading the next generation of ML on device. Running ML in edge device is required for the following reasons:</p><ul><li>Fast Interactive Application (by running the ML application on the client side, we can eliminate the overhead of sending the data between server and client)</li><li>Data Privacy (by avoiding to send data to the server)</li></ul><p>There have been some improvements to TensorFlow Lite’s general usability, model conversion features and performance. For example, by delegating the processing to an edge TPU, they achieve 62x faster inference time at maximum combining with quantization. They also introduce the Coral Dev Board, a single-board computer with a removable system-on-module featuring the Edge TPU, and the Coral USB Accelerator, an USB dongle designed to speed up machine learning inference on existing Raspberry Pi and Linux systems. In addition, they have also presented Sparkfun. <a href="https://www.sparkfun.com/products/15170">Sparkfun</a> is an edge demo board powered by TensorFlow. According to the information provided, Sparkfun can activate a blender or hot-water heater, or do anything your microcontroller can do when it hears a certain word, with nothing but a coin cell battery for power; interesting isn’t it? Even more interesting is that we received the Sparkfun board and the coral USB accelerator as a gift for attending the conference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*smrBF43FGLzwmLmU8L6rVw.png" /><figcaption>TFDevSummit goodies</figcaption></figure><p>This kind of gift is always fun because we can try to use what we’ve learned. So I’m going to try all of these later :).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*PRRARoczbJU0jBrcXyqvSA.png" /><figcaption>The SparkFun Edge board</figcaption></figure><p><strong>TensorFlow.js 1.0</strong></p><p>Javascript is one of the most used programming languages and TensorFlow.Js brings ML to JavaScript developers. During the conference they announced the released of TensorFlow.Js. In addition to core components, there are multiple supporting libraries around TensorFlow.js.</p><ul><li><a href="https://github.com/tensorflow/tfjs-layers">tfjs-layers</a></li><li><a href="https://github.com/tensorflow/tfjs-data">tfjs-data</a></li><li><a href="https://github.com/tensorflow/tfjs-vis">tfjs-vis</a></li></ul><p>Actually, TensorFlow.js project will support various kind of platform such as Electron and React Native so that we can use the same application code in many platforms. Companies like AirBnb and Uber among others are using TensorFlow.js in production environments.</p><p><strong>Swift for TensorFlow</strong></p><p>Probably one of my favourite announcements last year, Swift for TensorFlow evolved with the release of version 0.2. It’s an incremental improvement; with 0.2, users can see increased usability and try out this novel ML paradigm. In addition, they also launched a new machine learning course using <a href="https://www.fast.ai/2019/03/06/fastai-swift/">Swift for TensorFlow by fast.ai</a> to make it easier to get started on ML with Swift.</p><p><strong>In Codice Ratio</strong></p><p>The project is developing a machine transcription system based on TensorFlow to speed up large scale search and knowledge discovery from the Vatican’s historical archives. A custom CNN trained on crowdsourced annotations enables the system to deal with challenging medieval handwriting.</p><p><strong>New Courses on TensorFlow and TensorFlow world</strong></p><p>Two new new online courses in collaboration respectively with <a href="https://www.udacity.com/course/intro-to-tensorflow-for-deep-learning--ud187">Udacity </a>and <a href="https://www.coursera.org/learn/introduction-tensorflow">Coursera </a>are available to learn TensorFlow.</p><p>Finally, a new conference <a href="https://conferences.oreilly.com/tensorflow/tf-ca">TensorFlow World</a> will be held on Oct 28th-31st, 2019. TensorFlow World conference, organized in collaboration with O’Reilly, will bring engineers, developers, executives, and product managers to discuss their product/service offerings that have been powered by TensorFlow.</p><h3>Day 2- March 7th</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*q8f52h_QBMlytCjnQ3By4Q.png" /></figure><p>Day two was dedicated to lighting talks, panel discussions and workshops such as:</p><ul><li>Visual debugging tool for ML</li><li>NetEase</li><li>Butterfly : democratizing ultrasound</li><li>PAI : Platform for Artificial Intelligence of Alibaba</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/1*uSRLdqiGXQD0N-0o9kMMxQ.png" /><figcaption>PAI presentation</figcaption></figure><ul><li>TensorFlow.jl : TensorFlow is now supported in Julia programming language</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*PGRwcA6L1NamJoRLRhhx2A.png" /><figcaption>Julia and Python syntax side by side</figcaption></figure><ul><li>TF-lattice : a project to help developers ensure that their machine learning models adhere to global trends even when training data is noisy</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*ATxem5N-WyTXuj2U8DDq7g.png" /><figcaption>TF-lattice</figcaption></figure><ul><li>TF.text : Improving text in TensorFlow, unicode support improvement in TensorFlow</li><li>TF.js use at Creative labs</li></ul><p>I also attended the panel discussion on Tensorflow 2.0 upgrade.</p><p><strong>TensorFlow Extended (TFX) workshop</strong></p><p>The TFX workshop is designed to give a hands-on experience on TensorFlow Extended (TFX) and help learn to create our own machine learning pipelines. During the workshop, the participants follow a typical ML development process, starting by examining the dataset, and end up with a complete working pipeline. This is also an opportunity to explore different ways to debug and update our pipeline and measure performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*IqmJZBypKZFiyg-h0wPLcg.png" /><figcaption>TFX workshop screenshot</figcaption></figure><p><strong>Final thoughts</strong></p><p>Overall, the 2019 TF Dev summit was very good, with a bunch of information and announcements. There are many improvements comparing to last year; for example, the addition of a second day and the workshop sessions. I definitely think this event is a must to consider if you use TensorFlow and would like to meet peers who are also using TF in real-life use-cases.</p><h3>References and further reading:</h3><ul><li><a href="https://www.tensorflow.org/">TensorFlow website</a></li><li><a href="https://www.tensorflow.org/dev-summit">TensorFlow Dev Summit</a></li><li><a href="https://medium.com/tensorflow/recap-of-the-2019-tensorflow-dev-summit-1b5ede42da8d">Recap of 2019 Dev Summi</a>t</li><li><a href="https://www.sparkfun.com/news/2886">SparkFun website</a></li><li><a href="https://blog.hackster.io/introducing-the-sparkfun-edge-34c9eb80a000">Introducing SparkFun Edge</a></li><li><a href="https://medium.com/tensorflow/introducing-tensorflow-datasets-c7f01f7e19f3">Introducing TensorFlow Datasets</a></li><li><a href="https://coral.withgoogle.com/">Coral with Google</a></li><li><a href="https://blog.hackster.io/say-hello-to-google-coral-cdbb49183864">Say Hello to Google Coral</a></li><li><a href="https://www.youtube.com/playlist?list=PLQY2H8rRoyvzoUYI26kHmKSJBedn3SQuB">TensorFlow YouTube Channel</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a43ec2e5845a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/tensorflow-dev-summit-2019-wrap-up-a43ec2e5845a">TensorFlow Dev Summit 2019 wrap-up</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playing with time series data in python]]></title>
            <link>https://medium.com/data-science/playing-with-time-series-data-in-python-959e2485bff8?source=rss-fa228fa48935------2</link>
            <guid isPermaLink="false">https://medium.com/p/959e2485bff8</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[timeseries]]></category>
            <dc:creator><![CDATA[Arnaud Zinflou]]></dc:creator>
            <pubDate>Sun, 29 Jul 2018 15:00:41 GMT</pubDate>
            <atom:updated>2018-07-31T23:25:28.324Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*safjXyVMwf9xS-nIaIKlIQ.png" /></figure><p>Time series are one of the most common data types encountered in daily life. Stock prices, sales, climate data, energy usage, and even personal weight are all examples of data that can be collected at regular intervals. Almost every data scientist will encounter time series in their work and being able to effectively deal with such data is an important skill in the data science toolbox.</p><p>This post is a quick introduction to start playing with time series in python. This includes a small definition of time series and some data manipulation using pandas accessing smart meter energy consumption data in London households. The data used in this post can be retrieved <a href="https://data.london.gov.uk/dataset/smartmeter-energy-use-data-in-london-households">here</a>. I have included code where I think it could be useful.</p><p>Let’s begin from basics, a <a href="https://en.wikipedia.org/wiki/Time_series">definition</a> of time series:</p><blockquote><em>A Time series is a collection of data points indexed, listed or graphed in time order. </em>Most commonly, a time series is a sequence taken at successive equally spaced points in time.<em>Thus it is a sequence of discrete-time data.</em></blockquote><p>Time series data are organized around relatively deterministic timestamps; and therefore, compared to random samples, may contain additional information that we will try to extract.</p><h4><strong>Loading and Handling Time Series</strong></h4><p><strong>The dataset</strong></p><p>As an example let’s use some data on energy consumption readings in kWh (per half hour) for a sample of London Households that took part in the UK Power Networks led Low Carbon London Project, between November 2011 and February 2014. We can start by making a few exploratory plots, it’s best to get an idea of the structure and ranges and this will also allow us to look for eventual missing values that need to be corrected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*YPfaYS3oUqv9dWac0hNRpQ.png" /></figure><p>For the remainder of this post we will only focus on the <em>DateTime</em> and <em>kWh</em> columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*uIr_VV_OfsnWFXCYxhn-8w.png" /></figure><p><strong>Resampling</strong></p><p>Let’s begin with simple resampling techniques. Resampling involves changing the frequency of your time series observations. One reason why you may be interested in resampling your time series data is feature engineering. Indeed, it can be used to provide additional structure or insight into the learning problem for supervised learning models. The resample method in pandas is similar to its groupby method as you are essentially grouping by a certain time span. You then specify a method of how you would like to resample. Let’s make resampling more concrete by looking at some examples. We’ll start with a weekly summary and:</p><ul><li>data.resample() will be used to resample the kWh column of our DataFrame</li><li>The ‘W’ indicates we want to resample by week.</li><li>sum() is used to indicate we want the sum kWh during this period.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*BkKD9DjXiV_aobf93uRKPQ.png" /></figure><p>We can do the same thing for a daily summary and we can use a groupby and mean function for hourly summary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*HwgmLro_MmA1N7Ygs97_ng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*Hka1ex0x-HhoxNDni_yyBQ.png" /></figure><p>To go further with resampling, pandas comes with many in-built options and you can even define your own methods. The following two tables present respectively table period options and some of the common methods you might use for resampling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*J92-E3pStWER9Mxfncm_VQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*UioIKxe5DQRI_shJYkEdyQ.png" /></figure><h4><strong>Additional explorations</strong></h4><p>Here are some more few explorations you can do with the data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*1o6xUgm3zojoQMK4C6SN8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*YfGlKJDnBJxItMrgLrYxAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*bLhgvQAN3qa-MuHLsvSBUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*QqMeV4cwiS9jID92waOs9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*FHgyhUg6Szy1wYuODZzERg.png" /></figure><h3><strong>Modeling with Prophet</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*wEdwo63tGQd52WTgV_zDvg.png" /></figure><p>Facebook Prophet was released in 2017 and it is available for Python and R. Prophet is designed for analyzing time series with daily observations that display patterns on different time scales. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well. It also has advanced capabilities for modeling the effects of holidays on a time-series and implementing custom changepoints, but I will stick to the basics to get a model up and running. I think that Prophet is probably a good choice for producing quick forecasts as it has intuitive parameters that can be tweaked by someone who has good domain knowledge but lacks technical skills in forecasting models. For more information on Prophet, readers can consult the official documentation <a href="https://facebook.github.io/prophet/docs/quick_start.html">here</a>.</p><p>Before using Prophet, we rename the columns in our data to the correct format. The Date column must be called ‘<em>ds</em>’ and the value column we want to predict ‘<em>y</em>’. We used our daily summary data in the example below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*L-QzlAHQMWh3_dHRzmm2Ng.png" /></figure><p>Then we import prophet, create a model and fit to the data. In prophet, the <a href="https://facebook.github.io/prophet/docs/trend_changepoints.html">changepoint_prior_scale</a> parameter is used to control how sensitive the trend is to changes, with a higher value being more sensitive and a lower value less sensitive. After experimenting with a range of values, I set this parameter to 0.10 up from the default value of 0.05.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*jI-aama6wciCh3WfvAotgQ.png" /></figure><p>To make forecasts, we need to create what is called a future dataframe. We specify the number of future periods to predict (two months in our case) and the frequency of predictions (daily). We then make predictions with the prophet model we created and the future dataframe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*7UWXMMSlSvNvHmWV6oBRjg.png" /></figure><p>That was pretty simple! The future dataframe contains the estimated household consumption for the next two months. We can visualize the prediction with a plot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*mCzY7k5LVMoIJfYq8tjX6g.png" /></figure><p>The black dots represent the actual values, the blue line indicates the forecasted values, and the light blue shaded region is the uncertainty.</p><p>As illustrated in the next figure, the region of uncertainty grows as we move further out in the future because the initial uncertainty propagates and grows over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*t8HaMDjFP3NS6DMoGaKq1g.png" /></figure><p>Prophet also allows us to easily visualize the overall trend and the component patterns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*8cUmaf-trYzU9uF8xKdTWQ.png" /></figure><p>The yearly pattern is interesting as it seems to suggest that the household consumption increases in fall and winter, and decreases in spring and summer. Intuitively, this is exactly what we expected to see. Looking at the weekly trend, it seems that there is more consumption on Sunday than the other days of the week. Finally, the overall trend suggests that the consumption increases for a year before slowly declining. Further investigation is needed to try to explain this trend. In a next post we will try to find if there is a correlation with the weather.</p><h3><strong>LSTM prediction</strong></h3><p>The Long Short-Term Memory recurrent neural network has the promise of learning long sequences of observations. The blog article, “Understanding LSTM Networks”, does an excellent job at explaining the underlying complexity in an easy to understand way. Here’s an image depicting the LSTM internal cell architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*vCwi2cS5Y3OcxC9B9MMy5Q.png" /><figcaption>Source: <a href="http://colah.github.io/posts/2015-08-Understanding-LSTMs/">Understanding LSTM Networks</a></figcaption></figure><p>LSTM seems to be well suited for time series forecasting, and it may be. Let’s use our daily summary data once again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*1yALSQMztFJWpVRPymi9NQ.png" /></figure><p>LSTMs are sensitive to the scale of the input data, specifically when the sigmoid or tanh activation functions are used. It’s generally a good practice to rescale the data to the range of [0, 1] or [-1, 1], also called normalizing. We can easily normalize the dataset using the MinMaxScaler preprocessing class from the scikit-learn library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*ejgJXusSQYv5Tgd_h01QxA.png" /></figure><p>Now we can split the ordered dataset into train and test datasets. The code below calculates the index of the split point and separates the data into the training datasets with 80% of the observations that we can use to train our model, leaving the remaining 20% for testing the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*BBEPgHW6XqtkNZZSps4hgA.png" /></figure><p>We can define a function to create a new dataset and use this function to prepare the train and test datasets for modeling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*6zD0EO22rpHW9LpIZ8m3lQ.png" /></figure><p>The LSTM network expects the input data to be provided with a specific array structure in the form of: [samples, time steps, features].</p><p>Our data is currently in the form [samples, features] and we are framing the problem as two time steps for each sample. We can transform the prepared train and test input data into the expected structure as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*4q9UE3-5R3d-nOXXKIwPiw.png" /></figure><p>That’s all! We are now ready to design and fit our LSTM network for our example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*uzn0FWknmDirBcdCiGzMJQ.png" /></figure><p>From the plot of loss, we can see that the model has comparable performance on both train and test datasets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*9Ro0vNC-wDN5dUd_xBBAdw.png" /></figure><p>In the next figure we see that LSTM did a quite good job of fitting the test dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*hnLOB5EA47n0AECoiDENGw.png" /></figure><h3><strong>Clustering</strong></h3><p>Last but not least, we can also do clustering with our sample data. There are quite a few different ways of performing clustering, but one way is to form clusters hierarchically. You can form a hierarchy in two ways: start from the top and split, or start from the bottom and merge. I decided to look at the latter in this post.</p><p>Let’s start with the data, we simply import the raw data and add two columns for the day of the year and the hour of the day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*80sHEjUJzU5IRCZWlNKyKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*-Lb9NWWRpDyr7S-ydnQjng.png" /></figure><p><strong>Linkage and Dendrograms</strong></p><p>The linkage function takes the distance information and groups pairs of objects into clusters based on their similarity. These newly formed clusters are next linked to each other to create bigger clusters. This process is iterated until all the objects in the original data set are linked together in a hierarchical tree.</p><p>To do clustering on our data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*QtyMm1AEp0PvTlrQexugSA.png" /></figure><p>Done!!! That was pretty simple, wasn’t it?</p><p>Well, sure it was, but what does the ‘ward’ mean there and how does this actually work? As the scipy linkage docs tell us, ward is one of the methods that can be used to calculate the distance between newly formed clusters. The keyword ‘ward’ causes linkage function to use the Ward variance minimization algorithm. Other common linkage methods like single, complete, average, and different distance metrics such as euclidean, manhattan, hamming, cosine are also available if you want to play around with.</p><p>Now let’s have a look at what’s called a dendogram of this hierarchical clustering. Dendrograms are hierarchical plots of clusters where the length of the bars represents the distance to the next cluster centre.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*BSfU95ukixLmrB2b8EYpdA.png" /></figure><p>Wooooh !!!!!! If it is the first time you see a dendrogram, that’s look intimidating, but don’t worry, let’s take this apart:</p><ul><li>On the x axis you see labels. If you don’t specify anything else (like me) they are the indices of your samples in X.</li><li>On the y axis you see the distances (of the ward method in our case).</li><li>horizontal lines are cluster merges</li><li>vertical lines tell you which clusters/labels were part of merge forming that new cluster</li><li>heights of the horizontal lines tell you about the distance that needed to be “bridged” to form the new cluster</li></ul><p>Even with explanations, the previous dendogram is still not obvious. We can cut a little bit to be able to take a better look at the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*lqGcReA3oq9eygmUVdWd1g.png" /></figure><p>Much better, isn’t it? Look up the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.cluster.AgglomerativeClustering.html">agglomerative clustering documentation</a> to learn more and play with the different parameters.</p><h3>References and further reading:</h3><ul><li><a href="https://joernhees.de/blog/2015/08/26/scipy-hierarchical-clustering-and-dendrogram-tutorial/#Selecting-a-Distance-Cut-Off-aka-Determining-the-Number-of-Clusters">https://joernhees.de/blog/2015/08/26/scipy-hierarchical-clustering-and-dendrogram-tutorial/#Selecting-a-Distance-Cut-Off-aka-Determining-the-Number-of-Clusters</a></li><li><a href="https://medium.com/open-machine-learning-course/open-machine-learning-course-topic-9-time-series-analysis-in-python-a270cb05e0b3">https://medium.com/open-machine-learning-course/open-machine-learning-course-topic-9-time-series-analysis-in-python-a270cb05e0b3</a></li><li><a href="https://petolau.github.io/TSrepr-clustering-time-series-representations/">https://petolau.github.io/TSrepr-clustering-time-series-representations/</a></li><li><a href="https://www.analyticsvidhya.com/blog/2016/02/time-series-forecasting-codes-python/">https://www.analyticsvidhya.com/blog/2016/02/time-series-forecasting-codes-python/</a></li><li><a href="http://colah.github.io/posts/2015-08-Understanding-LSTMs/">http://colah.github.io/posts/2015-08-Understanding-LSTMs/</a></li><li><a href="http://docs.scipy.org/doc/scipy/reference/cluster.hierarchy.html">http://docs.scipy.org/doc/scipy/reference/cluster.hierarchy.html</a></li><li><a href="https://facebook.github.io/prophet/docs/quick_start.html">https://facebook.github.io/prophet/docs/quick_start.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=959e2485bff8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/playing-with-time-series-data-in-python-959e2485bff8">Playing with time series data in python</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CVPR 2018: conference wrap-up]]></title>
            <link>https://medium.com/@azinflou/cvpr-2018-conference-wrap-up-e0d2e69cfc4b?source=rss-fa228fa48935------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0d2e69cfc4b</guid>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[cvpr]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Arnaud Zinflou]]></dc:creator>
            <pubDate>Sat, 23 Jun 2018 22:06:54 GMT</pubDate>
            <atom:updated>2018-06-24T04:06:32.275Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nw-lR59QNfuMI_gj5b6Z1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*-Y2Xr7EL7whsifqZgFwqvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oj-ocGogj_o-RiFNHr-2Cw.png" /></figure><p>I have just returned from the <a href="http://cvpr2018.thecvf.com/">CVPR 2018</a> conference held on June 18–22, 2018 in Salt Lake City, Utah, U.S. CVPR is one of the premier conferences in computer vision and pattern recognition, and this year received more than 3300 papers, from which 979 were accepted — a 29.6% acceptance ratio. Almost 6512 people (a record so far) attended for five days of workshops, tutorials, poster sessions, full oral and spotlight oral sessions. The conference also attracted numerous sponsors with nearly $2 000 000 in sponsorship funds (another record).</p><p>Modern computer vision is largely based on deep learning, so are most of the works presented at this conference (at least among those I’ve had the opportunity to see).</p><p>In this post, I will share my personal notes and briefly summarize trends from this conference, focusing on what has caught my attention the most.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o5BNFjn-Lh8Z_9H1_wt_ig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XxiKqMruQTJ4qyYsyPAHaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*X5MOh_sUMyLIo9eUUIbyaQ.png" /></figure><p>Unsupervised or weakly supervised methods were popular, which indicates researchers are thinking about circumventing the need to do costly dense labelling of datasets, which is one of the downside of supervised learning. Obviously supervised learning is very important, but sometimes, supervision can also be non-objective or subject to interpretation. Nonetheless, a tutorial on unsupervised visual learning was presented by a team from Google.</p><p>As it impossible to solve all problems without supervision, they also briefly discussed self-supervised learning, which is particularly well suited to robotic applications (according to the presenter).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*7FybFlARFTXG8omruc81sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*TplioBz-rs-nfjw4711Y3g.png" /><figcaption>Tutorial: Unsupervised Visual Learning &amp; Difference between unsupervised and self-supervised</figcaption></figure><p>Along with lots of interesting research, some exciting datasets were announced. For example, in the <a href="http://openaccess.thecvf.com/content_cvpr_2018/html/Luo_Fast_and_Furious_CVPR_2018_paper.html">Fast and Furious: Real Time End-to-End 3D Detection, Tracking and Motion Forecasting With a Single Convolutional Net</a> paper, the authors (from Uber ATG and University of Toronto) present an impressive dataset (Uber TOR4D) to evaluate 3D detection, tracking and motion forecasting. The dataset is 2 orders of magnitude bigger than datasets such as KITTI and consists of more than 540 000 frames collected from 2762 different scenes. It is said to be released publicly in a near future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*kJQMkQRdRqyA5QmVVkoCQg.png" /><figcaption>The Fast and Furious poster</figcaption></figure><p>Satellite image approaches were also quite popular at the conference. The <a href="http://deepglobe.org/">deep globe</a> challenge was a good example of the growing attention for maps and population analysis using satellite imagery. Obviously, the talk of the respective winners of each category of the challenge, <em>D-LinkNet: LinkNet with Pretrained Encoder</em>, and, <em>Dilated Convolution for High Resolution Satellite Imagery Road Extraction and Building Detection from Satellite Imagery using Ensemble of Size-specific Detectors</em>, were interesting. But in that session what caught my attention was the “Mapping Economic Development from Space” presentation. In this talk, the presenter shows how night light analysis from satellite imagery can be used as an indicator of development. Mainly they focus on night light intensity. The authors also developed a deep learning model to predict agriculture productivity in the U.S. and, according to their results, the performances of the model are quite impressive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*V736BlWC8AcmSUlT4okTGg.png" /><figcaption>Example of my personal notes taken during the workshop :)</figcaption></figure><p>Many approaches for segmentation or GAN based approaches were also shown at CVPR :</p><p>• Deep Extreme Cut: From Extreme Points to Object Segmentation</p><p>• Interactive Image Segmentation with Latent Diversity</p><p>• The Best of Both Worlds: Combining CNNs and Geometric Constraints for Hierarchical Motion Segmentation</p><p>• Learning Face Age Progression: A Pyramid Architecture of GANs</p><p>• GANerated Hands for Real-Time 3D Hand Tracking from Monocular RGB</p><p>• Person Transfer GAN to Bridge Domain Gap for Person Re-Identification</p><p>• Super-FAN: Integrated Facial Landmark Localization and Super-Resolution of Real-World Low Resolution Faces in Arbitrary Poses With GANs</p><p>• …</p><p>Most of the papers of CVPR can be accessed using the following link:</p><p><a href="http://openaccess.thecvf.com/menu.py">http://openaccess.thecvf.com/menu.py</a> or on IEEE Xplore.</p><p>Overall, this year’s CVPR was very interesting with a lot of quality contents and much larger than before. Minor technical difficulties and delays occurred during the conference, but overall in my opinion it was a success. To conclude, I have to mention the caricature portraits drawing during the event, which is simply amazing and made my day on Thursday 21st!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*3fwjwybgGNwGTaqf5_EJ-A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0d2e69cfc4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TensorFlow Dev Summit 2018 : Post-event reflexion on the potential impact of Machine Learning in…]]></title>
            <link>https://medium.com/@azinflou/tensorflow-dev-summit-2018-post-event-though-and-reflexion-on-possibly-impacts-of-machine-f4956691f4ab?source=rss-fa228fa48935------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4956691f4ab</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[africa]]></category>
            <dc:creator><![CDATA[Arnaud Zinflou]]></dc:creator>
            <pubDate>Sun, 01 Apr 2018 19:21:10 GMT</pubDate>
            <atom:updated>2018-04-01T20:07:34.653Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>TensorFlow Dev Summit 2018 : Post-event reflexion on the potential impact of Machine Learning in Africa</strong></h3><p><strong><em>Disclaimer</em>: These are my own personal views. I do not speak for my employer.</strong></p><p><strong>Quick highlight</strong></p><p>Today the hype around AI in general, and Machine Learning in particular, is at a peak and a lot of people believe that we are at the edge of a new technological revolution. In this context, on March 30th 2018, I attended the second <a href="https://www.tensorflow.org/dev-summit/">Tensorflow dev Summit</a> at the Computer History Museum in Mountain View California..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*H2bWoTC1s6U_44D1eKWe6w.png" /></figure><p>First of all, I have to say that the organization, the venue, the schedule, the speakers, everything was great. Congratulations to the Tensorflow team for organizing such an amazing event. The day was filled with new product announcements and other improvements to the framework, such as:</p><ul><li><a href="https://js.tensorflow.org/">Tensorflow.js</a>,</li><li><a href="https://www.tensorflow.org/programmers_guide/eager">Tensorflow Eager execution</a>,</li><li><a href="http://tensorflow.org/hub">Tensorflow Hub</a></li><li><a href="https://www.github.com/google/nucleus">Tensorflow for Genetics</a>,</li><li><a href="https://github.com/tensorflow/tensorboard/blob/master/tensorboard/plugins/debugger/README.md">Tensorboard Graphical debugger plugins</a>,</li><li><a href="https://github.com/tensorflow/probability/">Tensorflow probability API</a>, and</li><li><a href="https://www.tensorflow.org/community/swift">Tensorflow for Swift</a>.</li></ul><p><strong>What really made my day</strong></p><p>Most of these improvements will probably have a positive impact in the way we use the framework, even if I have to say that Tensorflow probability API and Tensorflow for Swift were among my favorite announcements of the day.</p><p>But what really made my day, kept me awake this night and inspired me to write these few lines on my flight back to Montreal, was how using this kind of framework on real world problems can lead to great advancements in many different fields. For a great example of its application, check out this video on how scientists in Africa used TensorFlow to detect diseases in Cassava plants in order to improve yield for farmers. This 2 minutes or so of video reminded me some of the discussions we have with my brothers and friends on how we strongly believe that such technologies will play a pivotal role in enabling Africa to become a main player in the world economy.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNlpS-DhayQA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNlpS-DhayQA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNlpS-DhayQA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/28935b5aac452ced5f656cb3d4220452/href">https://medium.com/media/28935b5aac452ced5f656cb3d4220452/href</a></iframe><p>Across the continent, AI has the potential to bring myriad positive changes in various sectors. Obviously, I know that many African countries are still battling with issues such as electricity, mechanization of production and automation. But I believe that AI ultimately can help to overcome a lack of physical infrastructure in Africa. Moreover, in most African countries, where capital is scarce but ideas are abundant, AI can enable businesses to run on distinctive and leaner models.</p><p><strong>Call to Action</strong></p><p>It’s an incredibly interesting time to be a software developer and an incredibly interesting time for Africa. With tools like Tensorflow, we don’t have to wait to develop our own distinctive technology model. We can begin to get value right away.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4956691f4ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>