<?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 Ricky H. Putra on Medium]]></title>
        <description><![CDATA[Stories by Ricky H. Putra on Medium]]></description>
        <link>https://medium.com/@rputra?source=rss-c76595d8b0c4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YkcSn6iHeGAmjpnEwitJCg.jpeg</url>
            <title>Stories by Ricky H. Putra on Medium</title>
            <link>https://medium.com/@rputra?source=rss-c76595d8b0c4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:52:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rputra/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[Build Your Own SKU Product Classifier — Part 2]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://rputra.medium.com/build-your-own-sku-product-classifier-part-2-0e76eb795f6f?source=rss-c76595d8b0c4------2"><img src="https://cdn-images-1.medium.com/max/1024/1*d5uXBhsLdVBh2bYdeWNzvQ.jpeg" width="1024"></a></p><p class="medium-feed-snippet">This part will show how to build the model with the category data explained in Part 1.</p><p class="medium-feed-link"><a href="https://rputra.medium.com/build-your-own-sku-product-classifier-part-2-0e76eb795f6f?source=rss-c76595d8b0c4------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://rputra.medium.com/build-your-own-sku-product-classifier-part-2-0e76eb795f6f?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e76eb795f6f</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[keras]]></category>
            <category><![CDATA[tensorflow]]></category>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Thu, 29 May 2025 10:15:08 GMT</pubDate>
            <atom:updated>2025-05-29T10:15:08.048Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Build Your Own Product Classifier — Part 1]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://rputra.medium.com/build-your-own-product-classifier-part-1-2db453d12412?source=rss-c76595d8b0c4------2"><img src="https://cdn-images-1.medium.com/max/1148/1*EnIPn2JH4p0sHcgV6ZB5PQ.jpeg" width="1148"></a></p><p class="medium-feed-snippet">Business Problem. The significance of data analysis in the ever-growing and always changing grocery retail industry cannot be emphasized&#x2026;</p><p class="medium-feed-link"><a href="https://rputra.medium.com/build-your-own-product-classifier-part-1-2db453d12412?source=rss-c76595d8b0c4------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://rputra.medium.com/build-your-own-product-classifier-part-1-2db453d12412?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2db453d12412</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[product-classifier]]></category>
            <category><![CDATA[google-colab]]></category>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 06:25:59 GMT</pubDate>
            <atom:updated>2025-05-22T15:44:04.516Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Interactive map-based data visualizations with Streamlit and Bokeh.js]]></title>
            <link>https://rputra.medium.com/interactive-map-based-data-visualizations-with-streamlit-and-bokeh-js-e29c4751648?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e29c4751648</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Sat, 06 Nov 2021 04:44:28 GMT</pubDate>
            <atom:updated>2022-08-12T03:31:38.956Z</atom:updated>
            <content:encoded><![CDATA[<p>I need to build a simple dashboard web prototype that takes input data from users and reads geographical data such as latitude and longitude, and then visualize it as a map on the website which allow users to interact with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*19uQ3uNliY1DDwLIW_nK9w.png" /><figcaption>Geo data visualization with Bokeh.js Map</figcaption></figure><p>In this tutorial, I will walkthrough five main technical building blocks:</p><ol><li>Building web interface with Streamlit framework which allows me to quickly build the UI prototype.</li><li>Mapping service such as Google geocoding service to translate address into latlong coordinate.</li><li>Database connection, in this case MySQL and MongoDB.</li><li>Making JSON HTTP requests</li><li>Map plotting with Bokeh.js</li></ol><h3>Build UI with Streamlit</h3><p>Streamlit allows me to build simple UI on my dashboard for users to fill in query parameters. It is super easy to install and use.</p><p>Install with pip:</p><blockquote>pip install streamlit</blockquote><p>Put some input text fields for user to fill in query parameters:</p><blockquote>import streamlit as st</blockquote><blockquote>st.title(‘Streamlit dashboard’)</blockquote><blockquote>CUSTOMER_ID = st.text_input(“Customer ID”, 111)<br>APPLICATION_ID = st.text_input(“Application ID”, “222”)<br>FROM_DATE = st.date_input(“From date”)<br>UNTIL_DATE = st.date_input(“Until date”)</blockquote><p>It takes just a few lines of code to actually build the query form. Two text fields and two date fields. Streamlist also has many other UI components such as slider, radio button, etc. See the list of display interactive widgets <a href="https://docs.streamlit.io/en/stable/api.html#display-interactive-widgets">here</a>.</p><p>Adding a UI widget is the same as declaring variable. <strong>No need backend code, define routes, handle HTTP requests, write HTML, CSS, JavaScript, etc.</strong> This is what I think makes Streamlit magically simply to use.</p><p>Last but not least, if you prefer cloud based deployment, it can not be easier than Streamlit instant deployment which they offer freely for up to 3 public apps.</p><h3>Google Maps service</h3><p>I use <a href="https://developers.google.com/maps/documentation/geocoding/overview">Google Maps geocoding API</a> to convert addresses (like “1st boulevard street, city, province”) into geographic coordinates (like “latitude 36.429010 and longitude -121.103638)</p><pre>GEOCODE_URL = &#39;<a href="https://maps.googleapis.com/maps/api/geocode/json?address=&#39;+pd_loans[&#39;supplier_address&#39;][0]+&#39;&amp;key=&#39;+GOOGLE_API_KEY">https://maps.googleapis.com/maps/api/geocode/json?address=&#39;+customer[&#39;address&#39;][0]+&#39;&amp;key=&#39;+GOOGLE_API_KEY</a><br>geo_response = requests.request(&quot;GET&quot;, GEOCODE_URL)<br>geodata = json.loads(geo_response.text)</pre><pre>try:<br> print(geodata[&#39;results&#39;][0][&#39;geometry&#39;][&#39;location&#39;])<br> latlong = [geodata[&#39;results&#39;][0][&#39;geometry&#39;][&#39;location&#39;][&#39;lat&#39;],geodata[&#39;results&#39;][0][&#39;geometry&#39;][&#39;location&#39;][&#39;lng&#39;]]<br>except IndexError:<br> latlong = None<br> st.write(&#39;latlong not found&#39;)</pre><p>You need to register and obtain Google API key from Google Cloud Platform console.</p><h3>Making MySQL database connection</h3><p>There are plenty of Python libraries that you can use to work with MySQL databases such as SQL Alchemy. It is simple yet powerful with object-relational mapper (ORM) feature, an optional component that provides the <strong>data mapper pattern</strong>, where classes can be mapped to the database in open ended, multiple ways — allowing the object model and database schema to develop in a cleanly decoupled way from the beginning.</p><pre>import sqlalchemy</pre><pre>engine = sqlalchemy.create_engine(&#39;mysql+mysqlconnector://user:pass@mysql:port/db&#39;)</pre><pre>df = pd.read_sql(&quot;select * from customers&quot;, con = </pre><pre>engine)</pre><h3>JSON HTTP requests</h3><p>Making JSON request is pretty straightforward with requests package</p><pre>import requests</pre><pre>response = requests.request(&quot;POST&quot;, url, headers=headers, data=payload)</pre><p>headers: HTTP headers to the request e.g. {‘user-agent’ : ‘xyz’}</p><p>payloads: a key value pairs dictionary object e.g. {‘key1’ : ‘value1’}</p><h3>Plot map with Bokeh.js</h3><p>Bokeh.js has comprehensive components to build map visualization such as gmap. It can be built as embedded map or separately save as file. The built-in map also has basic interaction tool like zoom and pan. It is very easy to annotate as well as you can see in below code.</p><p>First we import the bokeh.* packages</p><pre>from bokeh.io import show<br>from bokeh.plotting import gmap<br>from bokeh.models import GMapOptions<br>from bokeh.models import ColumnDataSource<br>from bokeh.palettes import Set3<br>from bokeh.palettes import Category20<br>from bokeh.palettes import RdBu3<br>from bokeh.resources import CDN<br>from bokeh.embed import file_html</pre><p>Set the map width and height</p><pre>bokeh_width, bokeh_height = 1024,768</pre><p>Write a function to plot data as map</p><pre>def plotAll(data, zoom=15, map_type=&#39;roadmap&#39;):<br>    gmap_options = GMapOptions(lat=data[0][1], lng=data[0][2], <br>                               map_type=map_type, zoom=zoom)<br>    p = gmap(GOOGLE_API_KEY, gmap_options, title=&#39;AwanTunai - Risk Intelligence&#39;, <br>             width=bokeh_width, height=bokeh_height)<br>    <br>    latArr = []<br>    longArr = []<br>    colorArr = []<br>    labelArr = []<br>    colidx = 0<br>    colpalette =</pre><pre> Category20.get(20)<br>    print(‘palette length: ‘, len(Set3))<br>    <br>    for x in data:<br>        if(x[4] == ‘Stationary’):<br>          latArr.append(x[1])<br>          longArr.append(x[2])<br>          labelArr.append(x[3])<br>          if(colidx == len(colpalette)):<br>              colidx=0<br>          colorArr.append(colpalette[colidx])<br>          colidx+=1<br>    <br>    print(‘latArr: ‘, latArr)<br>    print(‘longArr: ‘, longArr)<br>    print(‘colorArr: ‘, colorArr)<br>    print(‘label: ‘, labelArr)<br>    <br>    source = ColumnDataSource(dict(<br>                x=longArr,<br>                y=latArr,<br>                color=colorArr,<br>                label=labelArr<br>            ))<br>    <br>    center = p.circle(x=’x’, y=’y’, size=10, alpha=0.9, color=’color’, legend_group=’label’, source=source)<br>    <br>    if RESIDENCE_LATLONG is not None:<br>        p.triangle([RESIDENCE_LATLONG[1]], [RESIDENCE_LATLONG[0]], size=10, alpha=0.9, color=’red’)<br>    if BUSINESS_LATLONG is not None:<br>        p.triangle([BUSINESS_LATLONG[1]], [BUSINESS_LATLONG[0]], size=10, alpha=0.9, color=’blue’)<br>    html = file_html(p, CDN, &quot;User locations&quot;)<br>    return html</pre><p>And finally using streamlit components to render the map from html generated from bokeh.embed.file_html function.</p><pre>import streamlit.components.v1 as components</pre><pre>if len(data) &gt; 0:<br>    components.html(plotAll(data, 15, &#39;satellite&#39;), height = bokeh_height + 100, width = bokeh_width + 100)<br>else:<br>    st.write(&#39;no location data found&#39;)</pre><p>Please <strong>follow </strong>me if you find this article useful, it would motivate me to write more useful articles and helping others to learn. Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e29c4751648" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Face Detection with Google ML Kit]]></title>
            <link>https://javascript.plainenglish.io/mobile-face-detection-with-google-ml-kit-6b6debf13e84?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b6debf13e84</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Sun, 28 Feb 2021 10:53:04 GMT</pubDate>
            <atom:updated>2022-08-12T03:34:17.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*07KCOtuUYGqeosGQ-KJ2WA.png" /><figcaption>Face detector</figcaption></figure><p>My goal in this article is to show you how to build a face detector mobile app with Expo and Google ML Kit in less than 5 minutes.</p><p>Expo is a powerful framework equips with tons of ready-to-use components that allows you to build a cross-platform mobile application with ease. In this article, we are going to use components such as expo-camera to access mobile phone camera and a built-in face detector module expo-face-detector to detect faces from images. Expo-face-detector is based on <a href="https://cloud.google.com/vision">Google ML Kit Vision API</a>.</p><p>Before we can use Camera object, we need to import expo-permissions package and access camera permission with this line of code.</p><pre>await Permissions.askAsync(Permissions.CAMERA);</pre><p>Expo camera has built-in face detectors properties in order for us to configure its properties and callback methods.</p><pre>&lt;Camera<br>  style={{ flex: 1 }}<br>  type={this.props.cameraType}<br>  onFacesDetected={this.handleFacesDetected}<br>  onFaceDetectionError={this.handleFaceDetectionError}<br>  faceDetectorSettings={{<br>    mode: FaceDetector.Constants.Mode.fast,<br>    detectLandmarks: FaceDetector.Constants.Landmarks.all,<br>    runClassifications: FaceDetector.Constants.Classifications.all,<br>  }}<br>  ref={ref =&gt; {<br>    this.camera = ref;<br>  }}<br>&gt;</pre><p>onFacesDetected: set to the method to handle faces when detected. While detecting faces, face detector will call this method with an array of faces objects as parameter. My implementation as below.</p><pre>handleFacesDetected = ({ faces }) =&gt; {<br>  if (faces.length === 1){ // detect a face<br>    this.setState({<br>      faceDetected: true, // variable state to hold face is detected<br>      faceBox: faces[0].bounds // variable to hold face location<br>    });<br>  } else { // no faces detected<br>    this.setState({faceDetected: false });<br>  }<br>}</pre><p>In order to show face bounding box and highlight detected face, we are using React View with corresponding styles to draw a dashed rectangle in the location returned by Face Detector model.</p><pre>&lt;View<br>  style={{<br>    position: &#39;absolute&#39;,<br>    backgroundColor: &#39;transparent&#39;,<br>    flexDirection: &#39;row&#39;,<br>    width: this.state.faceBox ? this.state.faceBox.size.width : &#39;100%&#39;,<br>    height: this.state.faceBox ? this.state.faceBox.size.height : &#39;100%&#39;,<br>    top: this.state.faceBox ? this.state.faceBox.origin.y : &#39;0&#39;,<br>    left: this.state.faceBox ? this.state.faceBox.origin.x : &#39;0&#39;,<br>    borderColor: &#39;#33FF33&#39;,<br>    borderWidth: 5,<br>    borderStyle: &#39;dashed&#39;,<br>    display: this.state.faceDetected &amp;&amp; !this.state.pictureTaken ? &#39;flex&#39; : &#39;none&#39;,<br>  }}&gt;<br>&lt;/View&gt;</pre><p>To draw the rectangle, notice that we are setting top left width height from our faceBox state variable which has origin.x, origin.y and size.width, size.height.</p><p>Here is the interesting part of faceDetectorSettings property, which we can detect not just faces but smiling and open eye probability by setting runClassifications: FaceDetector.Constants.Mode.all. Note if you only need faces detection set it to none. Refer to the <a href="https://docs.expo.io/versions/latest/sdk/facedetector/">API documentation</a> here. There is also detectLandmarks property which we can detect and return face landmarks such as eyes, nose, mouth. With a bit more code, we can build an app that can alert exhausted drivers when they are unintentionally closing their eyes for too long</p><p>Expo camera and built-in face detector function allow us to build a mobile face detection app with just a few lines of code. It is simple yet powerful, but you might ask how can I use my own vision model with the camera? In my next article, I will show you how to use other machine learning model like Google MobileNet and TensorFlow.js platform adapter for react native framework in which we will see how to use TensorCamera object. This object augments the <a href="https://docs.expo.io/versions/latest/sdk/camera/">Expo.Camera</a> component with the ability to yield tensors representing the camera stream. Stay tuned.</p><p>Full source code for this article can be found here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/502cdc070df9faa7b50921dcc54404a5/href">https://medium.com/media/502cdc070df9faa7b50921dcc54404a5/href</a></iframe><p>Please <strong>follow </strong>me if you find this article useful, it would motivate me to write more useful articles and helping others to learn. Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b6debf13e84" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/mobile-face-detection-with-google-ml-kit-6b6debf13e84">Mobile Face Detection with Google ML Kit</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Facebook login in Android using React and Expo]]></title>
            <link>https://rputra.medium.com/facebook-login-in-android-using-react-and-expo-57a5007f0423?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/57a5007f0423</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[facebook-login]]></category>
            <category><![CDATA[expo]]></category>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Sun, 07 Feb 2021 04:39:14 GMT</pubDate>
            <atom:updated>2022-08-12T03:34:42.715Z</atom:updated>
            <content:encoded><![CDATA[<p>Many mobile applications today allow users to login with third-party authentication such as Facebook. In today&#39;s post, I am going to show you how easy it is to set up and build in Android using React &amp; Expo framework but the idea should be applicable to other frameworks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*Fv9W7T2eLxzs1X42HurjOw.png" /><figcaption>Facebook Login</figcaption></figure><ol><li>Generate Facebook App ID for your application</li></ol><p>Create an account if you have not had so, and go to <a href="https://developers.facebook.com/apps/">https://developers.facebook.com/apps/</a></p><p>Choose Create App -&gt; Build connected experiences, fill up the form and you are good to go. You should be able to see your App ID in the app dashboard page. We will need to use this App ID when calling Facebook Login API.</p><p>2. Prepare your React Expo project</p><p>In Expo docs, refer to <a href="https://docs.expo.io/versions/latest/sdk/facebook/">https://docs.expo.io/versions/latest/sdk/facebook/</a> where it explains how to install the package with code example. You should be able to create a simple login page based on the sample code which is basically calling Expo’s Facebook.initializeAsync function (pass it with Facebook App ID created in the first step) and using Facebook Graph API to fetch user info</p><p>3. Write the code</p><p>In my example, I am using reducer function “useReducer” in React so that I can manage different login states for example after login I want to show welcome message as shown in line 18 in below code snippets.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20f44f69aa7ec03376194051ef790ad6/href">https://medium.com/media/20f44f69aa7ec03376194051ef790ad6/href</a></iframe><p>4. Test login</p><p>Once you hook the function with the UI component such as button, you can test it. Upon clicking on the button, it will show login box for you to enter Facebook credentials.</p><p>How about logout function? Well, Expo Facebook does have function Facebook.logOutAsync but when I try to login again, it will not show the login box anymore and used the previously entered credentials automatically.</p><p>So I decided to call Graph API manually and force delete the Facebook session’s token every time I logout. This allows me to re-enter the credentials.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b01405a1853b53c1e5b48c297473fb8/href">https://medium.com/media/0b01405a1853b53c1e5b48c297473fb8/href</a></iframe><p>Hope this article helps you implement Facebook login and logout to your React Native mobile application. Cheers.</p><p>Please <strong>follow </strong>me if you find this article useful, it would motivate me to write more useful articles and helping others to learn. Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57a5007f0423" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Expo ADB server didn’t ack error]]></title>
            <link>https://rputra.medium.com/expo-adb-server-didnt-ack-error-9a9e99b111c0?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a9e99b111c0</guid>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Sat, 30 Jan 2021 05:24:57 GMT</pubDate>
            <atom:updated>2022-08-12T03:35:04.418Z</atom:updated>
            <content:encoded><![CDATA[<p>So I was exploring latest Android Studio 4 upgrade and upgrading my old Expo projects with it. I hit error when executing expo start with android emulator running.</p><p>The error message is below:</p><blockquote>Couldn’t start project on Android: adb E 1723 33490 usb_osx.cpp:138] Unable to create an interface plug-in (e00002be)<br>error: could not install *smartsocket* listener: Address already in use<br>ADB server didn’t ACK<br>* failed to start daemon *<br>error: cannot connect to daemon</blockquote><p>Checked adb process is running but was unable to connect by Expo. Strange.</p><p>I figured out that I have two adb installation exists from Android Studio platform tools and from Expo itself. From Mac Activity Manager, search for adb, double click on it, then you will see process details, click on Open Files and Ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*jsTbMmyBSLpACS4I6CgMJg.png" /><figcaption>adb from SDK platform-tools (auto starts from IDE)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*BEls0w7-8feFmYDbysvEXg.png" /><figcaption>adb from expo-cli</figcaption></figure><p>When you run Android Studio, the IDE will automatically starts the adb from SDK path which causing Expo to not able to use its own adb.</p><p>I killed adb process from SDK platform-tools, run “expo start” again, resolved the issue as Expo starts its own adb process.</p><p>Then I tried to upgrade expo-cli to latest version (4.1.4). Restart android emulator and Android Studio. When running “expo start” this time, it killed adb from SDK platform-tools and starting its own adb successfully. I am not sure if this issue arises from SDK platform-tools upgrade or expo upgrade. Troubleshooting android emulator related issues could be tricky and I hope this article could help people who have similar issue with me here. Cheers.</p><p>Please <strong>follow </strong>me if you find this article useful, it would motivate me to write more useful articles and helping others to learn. Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a9e99b111c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fusion CNN and LSTM for Inertial-Based Gait Recognition]]></title>
            <link>https://rputra.medium.com/fusion-cnn-and-lstm-for-inertial-based-gait-recognition-4a757f0d3a4b?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a757f0d3a4b</guid>
            <category><![CDATA[inertial-sensors]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <category><![CDATA[gait]]></category>
            <category><![CDATA[lstm]]></category>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Mon, 22 Jun 2020 14:56:42 GMT</pubDate>
            <atom:updated>2020-06-22T14:56:42.927Z</atom:updated>
            <content:encoded><![CDATA[<p><em>User identification framework from inertial based sensor</em></p><p><em>This paper present user identification framework from inertial based sensor or device. The goal is to recognize a target user from their gait patterns or way of walking, using accelerometer and gyroscope signals provided by inertial based sensor like smartphone. This research contributes several innovations such as 1) Novel feature extraction based on Convolutional Neural /network (CNN) 2) Convolutional neural network (CNN) &amp; Long short term memory (LSTM) neural network to classify walking subject. We exploit deep learning approach as universal feature extractors for gait recognition, which able to remember classification results from subsequent walking cycles to identify target user. Our experiment shows the superiority of the approach against other state-of-the-art techniques, leading to accuracy of 93% with fewer than five walking cycles. Approaches and several design choices are evaluated and compared, assessing their impact on user identification performance.</em></p><p><strong>Index Terms </strong>Gait, Inertial, CNN, LSTM, Fusion</p><ol><li><strong>INTRODUCTION</strong></li></ol><p>Gait analysis began in the early 1970s where scientists used video camera systems that could produce detail studies of individual with realistic cost and time constraint. There were widespread application of gait analysis for pathological conditions such as cerebral palsy, parkinson and neuromuscular disorders [1]. Gait analysis is an important tool in the evaluation of operative procedures [1,2], rehabilitation progress [3], or the assessment of the motor status in neurologically impaired patients [4,5]. There are various parameters that are of interest such as joint kinematics, spatio-temporal parameters, joint forces, pressure distributions, and muscle activities. Accurate and efficient detection of gait events is essential for the analysis of human gait. Determination of heel strike and toe off allows walking trials to be broken up into gait cycles consisting of a stance and swing phase. This allows comparison of joint angles, forces and moments across multiple strides and walking. Analysis of gait data will often examine gait variables with reference to one or more of these gait events or phases, such as knee flexion at heel strike or knee moment at fifty percent of stance phase. It is critical that these events are detected accurately and consistently throughout a trial [6]. This paper presents user specific gait identification involves gait events recognition based on kinematic parameters and find gait patterns specific to individual or identification.</p><p><strong>2. RELATED WORK</strong></p><p>Most of researchers today performed two ways of human gait identification, first, explicitly through physiological gait parameters e.g. cadence, step-length or second through detection of gait phases or kinematic parameters e.g. joint angle measurement [7], optical markers or inertial data. Other technique includes markerless gait capture using depth camera e.g. kinect, pressure management, kinetics and dynamic electromyography. Gait analysis involves measurable parameters which introduced and analyzed, and interpretation, where conclusions of the subject are drawn. In general, most of the gait identification approaches are based on computer vision, but there are also works which are based on inertial sensors [11].</p><p>There are several stages and techniques involved during gait analysis. Since data is taken from sensor, it is prone of noises. Most of researchers today perform denoising or removing noises in data before analysing and fitting to model. Some researchers using specific feature extraction technique such as PCA eigenvalues and some are using deep learning to find important features.</p><p>Below are summary of several techniques of each analysis task that we have explored during our research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*CcSLv2TA1UEQK9Hb4FXaxA.png" /><figcaption>Combination of common techniques used</figcaption></figure><p>Besides techniques above, we also found that different inertial sensor setup could also impact the result. Some researchers are using 7 IMUs with retroreflective markers, and some are using 3 or 5 IMUs sensor only. Depending on the objective, different sensor setup will have different implication on model performance. As stated in [9], gait recognition accuracy of three different sensor positions are found best in left IMU position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*-WZk7gRiOIqg08SstVlj2A.png" /><figcaption>Other authors results</figcaption></figure><p>With these different techniques and setup, there are huge combinations of techniques and setup that we can try to achieve best performance model.</p><p>Both CNN and LSTM have shown improvements over Deep Neural Networks (DNN) across a wide variety of tasks. CNNs are good at reducing sequences variations, LSTMs are good at temporal modeling, and DNNs are appropriate for mapping features to a more separable space.</p><p><strong>3. PROPOSED APPROACH</strong></p><p>In this section, we describe the architecture of the proposed approach for gait subject identification. Our methodology consists of 6 essential steps: data sourcing, pre-processing, decompose data to specific time window, features engineering, training estimators and finally predicting the gait subject.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/0*Qn6DT0-wEtENOnA7" /></figure><p>In following, we explain all of these components in detail.</p><ol><li>Data sourcing</li></ol><p>This research is primarily based on dataset acquired from<em> Anguita et al</em> in their paper with title <em>A Public Domain Dataset for Human Activity Recognition Using Smartphones</em>, where they have carried out with a group of 30 volunteers within an age bracket of 19–48 years. Each person performed six different activities wearing a smartphone on their waist. Using its embedded accelerometer and gyroscope, it captured 3-axial linear acceleration and 3-axial angular velocity at a constant rate of 50Hz.</p><p>2. Pre-processing</p><p>The sensor signals (accelerometer and gyroscope) were pre-processed by applying noise filters. The sensor acceleration signal, which has gravitational and body motion components, was separated using a Butterworth low-pass filter into body acceleration and gravity. The gravitational force is assumed to have only low frequency components, therefore a filter with 0.3 Hz cutoff frequency was used. From each window, a vector of features was obtained by calculating variables from the time and frequency domain.</p><p>3. Decomposition</p><p>Since raw data from sensors are time series and covers long sequences, we need to break them into subsequences. Since we are using fixed-width sliding windows of 2.56 sec and 50% overlap, we have 128 time steps.</p><p>4. Features engineering</p><p>Referring to the data source <em>Anguita et al</em>, all features selected for this database came from the accelerometer and gyroscope 3-axial raw signals. The acceleration signal was then separated into body and gravity acceleration signals using another low pass Butterworth filter with a corner frequency of 0.3 Hz. Subsequently, the body linear acceleration and angular velocity were derived in time to obtain Jerk signals. Also the magnitude of these three-dimensional signals were calculated using the Euclidean norm. Finally a Fast Fourier Transform (FFT) was applied to some of these signals producing another set of frequency domain signals. In total we have 561 features derived from 6 raw features.</p><p>5. Training estimators</p><p>The models are trained with CNN, LSTM and both combination in which we want to evaluate and compare with other state-of-the-arts model</p><p>6. Predicting gait subject</p><p>HAR dataset contains 30 individuals, in which we apply one hot encoding. For each 128 time steps multiply by the features, we have all of sensor data as X variables to predict Y (subject ID)</p><p><strong>4. EXPERIMENTS AND RESULTS</strong></p><p>The obtained dataset has been randomly partitioned into two sets, where 70% of the volunteers was selected for generating the training data and 30% the test data. During training, we subsequently split the training data 80% for training and 20% for validation.</p><p>First, we establish baseline numbers for CNN and LSTM as shown in below table. With LSTM having 100 hidden layers, drop out 0.5 and fully connected layers. CNN having 1 convolution 2D layer with 240 hidden layers, Max Pooling and Average Pooling is used followed by fully connected layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*csRGta1bsm2NJIDZm7uACw.png" /><figcaption>Our baseline model performance</figcaption></figure><p>Our models are basically trained with two types of neural networks: Convolutional Neural Network (CNN) and Long Short Term Memory (LSTM). We experiment both model with various hyperparameters tuning, and network types and also combining both as one model e.g. CNN-LSTM. Below is the accuracy result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*ad8p2hNTHAyrDSLXEKVgIQ.png" /><figcaption>Our final model performance</figcaption></figure><p>Result 1: Comparing Model 1–4, CNN-LSTM with 2 bi-directional layers does not really have significant improvement over CNN-LSTM with 1 bi-directional layer. Although, it seems to have slightly better result with 200 training epochs.</p><p>Result 2: Comparing Model 3,4 and 5,6. It seems that by wrapping bi-directional layers over CNN-LSTM network improves the performance by ~ 3% for 100 epochs, but not much for 200 epochs.</p><p>Result 3: Comparing Model 9 and others, It seems that CNN with 4 Conv2D layers were able to achieve highest accuracy. This means that CNN model alone were able to learn from the sequence patterns and use them for gait subject identification.</p><p>Result 4: Another observation was LSTM model alone has very low accuracy ~34% suggesting that LSTM alone might not be able to learn from the sequence patterns very well for gait subject identification.</p><p><strong>5. CONCLUSIONS</strong></p><p>In this experiment, we have explored various data pre-processing techniques especially to work on sensor data. We also apply CNN and CNN-LSTM to compare and evaluate their performance given the complexity of sensor data. With proper denoising technique and fine tuning CNN and CNN-LSTM networks we found that both model are having quite similar result with CNN slightly higher than CNN-LSTM. Interestingly, LSTM model alone did not have good result. With CNN, important features are proven can be detected and extracted to fit into LSTM model and resulting the good result.</p><p><strong>REFERENCES</strong></p><p>[1] Wikipedia contributors. “Gait analysis.” <em>Wikipedia, The Free Encyclopedia</em>. Wikipedia, The Free Encyclopedia, 9 Feb. 2019. Web. 1 Mar. 2019.</p><p>[2]. Loske, S.; Nüesch, C.; Byrnes, K.S.; Fiebig, O.; Schären, S.; Mündermann, A.; Netzer, C. Decompression surgery improves gait quality in patients with symptomatic lumbar spinal stenosis. Spine J. 2018, 18, 2195–2204.</p><p>[3] Zomar, B.O.; Bryant, D.; Hunter, S.; Howard, J.L.; Vasarhelyi, E.M.; Lanting, B.A. A randomised trial comparing spatio-temporal gait parameters after total hip arthroplasty between the direct anterior and direct lateral surgical approaches. HIP Int. 2018, 28, 478–484.</p><p>[4] Steultjens, M.P.M.; Dekker, J.; van Baar, M.E.; Oostendorp, R.A.B.; Bijlsma, J.W.J. Range of joint motion and disability in patients with osteoarthritis of the knee or hip. Rheumatology 2000, 39, 955–961.</p><p>[5] Bertoli, M.; Cereatti, A.; Trojaniello, D.; Avanzino, L.; Pelosin, E.; Del Din, S.; Rochester, L.; Ginis, P.; Bekkers, E.M.J.; Mirelman, A.; et al. Estimation of spatio-temporal parameters of gait from magneto-inertial measurement units: Multicenter validation among Parkinson, mildly cognitively impaired and healthy older adults. Biomed. Eng. OnLine 2018, 17, 58.</p><p>[6] Pau, M.; Corona, F.; Pili, R.; Casula, C.; Guicciardi, M.; Cossu, G.; Murgia, M. Quantitative assessment of gait parameters in people with Parkinson’s disease in laboratory and clinical setting: Are the measures interchangeable? Neurol. Int. 2018, 10, 7729.</p><p>[7] Zeni Jr, J. A., J. G. Richards, and J. S. Higginson. “Two simple methods for determining gait events during treadmill and overground walking using kinematic data.” <em>Gait &amp; posture</em> 27.4 (2008): 710–714.</p><p>[8] Sprager, Sebastijan, and Matjaz Juric. “Inertial sensor-based gait recognition: a review.” <em>Sensors</em> 15.9 (2015): 22089–22127.</p><p>[9] Teufl, Wolfgang, et al. “Towards Inertial Sensor Based Mobile Gait Analysis: Event-Detection and Spatio-Temporal Parameters.” <em>Sensors</em> 19.1 (2019): 38.</p><p>[10] Delgado-Escaño, Rubén, et al. “An End-to-End Multi-Task and Fusion CNN for Inertial-Based Gait Recognition.” <em>IEEE Access</em> 7 (2019): 1897–1908.</p><p>[11] Gadaleta, Matteo, and Michele Rossi. “Idnet: Smartphone-based gait recognition with convolutional neural networks.” <em>Pattern Recognition</em> 74 (2018): 25–37.</p><p>[12] Davide Anguita, Alessandro Ghio, Luca Oneto, Xavier Parra and Jorge L. Reyes-Ortiz. A Public Domain Dataset for Human Activity Recognition Using Smartphones. 21th European Symposium on Artificial Neural Networks, Computational Intelligence and Machine Learning, ESANN 2013. Bruges, Belgium 24–26 April 2013.</p><p>[13] Riaz, Qaiser, et al. “Move Your Body: Age Estimation Based on Chest Movement During Normal Walk.” <em>IEEE Access</em> 7 (2019): 28510–28524.</p><p>[14] Sainath, Tara N., et al. “Convolutional, long short-term memory, fully connected deep neural networks.” <em>2015 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)</em>. IEEE, 2015.</p><p>[15] Ngo, Thanh Trung, et al. “The largest inertial sensor-based gait database and performance evaluation of gait-based personal authentication.” <em>Pattern Recognition</em> 47.1 (2014): 228–237.</p><p>[16] Trung, Ngo Thanh, et al. “Performance evaluation of gait recognition using the largest inertial sensor-based gait database.” <em>2012 5th IAPR International Conference on Biometrics (ICB)</em>. IEEE, 2012.</p><p>[17] Sun, Bing, Yang Wang, and Jacob Banda. “Gait characteristic analysis and identification based on the iPhone’s accelerometer and gyrometer.” <em>Sensors</em> 14.9 (2014): 17037–17054.</p><p>[18] Hung, Tran, and Young Suh. “Inertial sensor-based two feet motion tracking for gait analysis.” <em>Sensors</em> 13.5 (2013): 5614–5629.</p><p>[19] Annadhorai, Anuradha, et al. “Human identification by gait analysis.” <em>Proceedings of the 2nd International Workshop on Systems and Networking Support for Health Care and Assisted Living Environments</em>. ACM, 2008.</p><p>[20] Dehzangi, Omid, Mojtaba Taherisadr, and Raghvendar ChangalVala. “IMU-based gait recognition using convolutional neural networks and multi-sensor fusion.” <em>Sensors</em> 17.12 (2017): 2735.</p><p>[21] Caldas, Rafael, et al. “A systematic review of gait analysis methods based on inertial sensors and adaptive algorithms.” <em>Gait &amp; posture</em> 57 (2017): 204–210.</p><p>[22] Zou, Qin, et al. “Robust gait recognition by integrating inertial and RGBD sensors.” <em>IEEE transactions on cybernetics</em> 48.4 (2018): 1136–1150.</p><p>[23] Mannini, Andrea, et al. “A machine learning framework for gait classification using inertial sensors: Application to elderly, post-stroke and huntington’s disease patients.” <em>Sensors</em> 16.1 (2016): 134.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a757f0d3a4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PROTEIN IDENTIFICATION WITH SUPPORT VECTOR MACHINES]]></title>
            <link>https://rputra.medium.com/protein-identification-with-support-vector-machines-20e49f0b364c?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/20e49f0b364c</guid>
            <category><![CDATA[support-vector-machine]]></category>
            <category><![CDATA[bag-of-words]]></category>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Mon, 22 Jun 2020 14:34:59 GMT</pubDate>
            <atom:updated>2022-08-27T11:03:13.289Z</atom:updated>
            <content:encoded><![CDATA[<h3>Protein Identification With Support Vector Machines</h3><p>Many combination of structures are available for proteins involved in the central processes of life, however it can be a challenge to find the information that we need, since protein data bank archives so many different structures, often with multiple combination of structures for a given molecule, or partial structures, or structures that have been modified from their native form. This paper presents SVM-based algorithm to identify protein structures and compare with a Naive Bayes-based algorithm on a set of protein database from Research Collaboratory for Structural Bioinformatics (RCSB) Protein Data Bank (PDB). Performance was measured for identification scenarios. The classification performance for SVM with one-vs-rest approach is ~94% versus Naive Bayes is ~90%.</p><p><strong><em>Keywords: </em></strong>support vector machine, sequences, pattern recognition, bag of words</p><p><strong>1. INTRODUCTION</strong></p><p>Protein plays countless roles throughout the biological world, from catalyzing chemical reactions to building the structures of all living things. Despite this wide range of functions all proteins are made out of the same twenty amino acides, but combined in the different ways.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/0*1haJ7_JdoEbBlrPY" /></figure><p>Support Vector Machines (SVMs) are a class of supervised learning algorithms first introduced by Vapnik [4]. Given a set of labelled training vectors (positive and negative input examples), SVMs learn a linear decision boundary to discriminate between the two classes. The result is a linear classification rule that can be used to classify new test examples. SVMs have exhibited excellent generalization performance (accuracy on test sets) in practice and have strong theoretical motivation in statistical learning theory [4].</p><p>We demonstrate our SVM-based algorithm on protein sequence identification applications. The algorithm is presented with a sequence of an unknown protein. The algorithm reports its best estimate of the identity of an unknown protein from a database of known proteins.</p><p>The simplest way to extend SVMs for multiclass problems is using the so-called one-vs-rest approach (Vapnik, 1995). For K class problems, K linear SVMs will be trained independently, where the data from the other classes form the negative cases [5]. Other approach uses one-vs-one <em>(Knerr et al. 1990)</em> based multiclass approaches. All possible two-class classifiers are evaluated from the training set of n classes, each classifier being trained on only two out of n classes, giving a total of n_class * (n_class — 1) / 2 classifiers. Applying each classifier to the test data vectors give one vote to the winning class. The data is assigned the label of the class with most votes. Results of recent analysis of different multi-class strategies are provided by <em>Hsu and Lin (2002), </em>but we will leave those for future work.</p><p>To provide a benchmark for comparison, we experimented both one-vs-rest and one-vs-one SVM with different model parameters tuning, and in addition we compared our approaches with a Naive Bayes based algorithm. We present experiment results by using different set of testing data. Cross validation was also performed against training data with 5 different folds to ensure model fitness.</p><p><strong>2. BASELINE APPROACH</strong></p><p>Protein sequence is represented as a sequence of string constructed from a process of determining the amino acid sequence of all or part of a protein or peptide. We extracted each character from protein sequence, count number of occurrences and stored them into a vector. This vector will become the input into our SVM model and based on these inputs, the classifier will output one out of eight classes of known proteins.</p><p>Suppose our training set S consists of labelled input vectors (xi,yi), i = 1 . . . m, where xi∈Rn and yi∈ {±1}. We can specify a linear classification rule f by a pair (w, b), where w ∈ Rnand b ∈ R, via</p><p>f(x) = (w, x) + b</p><p>where a point x is classified as positive (negative) if f(x) &gt; 0 (f(x) &lt; 0). Geometrically, the decision boundary is the hyperplane</p><p>{x ∈ Rn : (w, x) + b = 0}</p><p>where w is a normal vector to the hyperplane and b is the bias. If we further require that |w| = 1, then the geometric margin of the classifier with respect to S is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/1*OdB7-sTTVlNKBWRRhrkp8A.png" /></figure><p>In the case where the training data are linearly separable and a classifier f correctly classifies the training set, then m g S (f) is simply the distance from the decision hyperplane to the nearest training point(s).</p><p><strong>2.1. SVM Kernels</strong></p><p>A key feature of any SVM optimization problem is that it is equivalent to solving a dual quadratic programming problem. For example, in the linearly separable case, the maximal margin classifier is found by solving for the optimal “weights” ai , i = 1 . . . m, in the dual problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*PGiA2g37YiaPi56C2yR3mg.png" /></figure><p>on the region: ai ≥ 0 for all i</p><p>The parameters (w, b) of the classifier are then determined by the optimal αi (and the training data). The dual optimization problems for various soft margin SVMs are similar. The dual problem not only makes SVMs amenable to various efficient optimization algorithms, but also, since the dual problem depends only on the inner products (xixj)allows for the introduction of kernel techniques.</p><p>To introduce a kernel, we now suppose that our training data are simply labelled examples (xi ,yi), where the xi belong to an input space X which could be a vector space or a space of discrete structures like sequences of characters from an alphabet or trees. Given any feature map Φ from X into a (possibly high-dimensional) vector space called the feature space Φ : X → Rn , we obtain a kernel K on n × n matrix defined by K(x , y) = (Φ(x), Φ(y)). By replacing (xixj) by K(xixj) in the dual problem, we can use SVMs in feature space.</p><p>Moreover, if we can directly compute the kernel values K(x , y) without explicitly calculating the feature vectors, we gain tremendous computational advantage for high-dimensional feature spaces.</p><p><strong>3. PROPOSED APPROACH</strong></p><p>Baseline approach with one-to-one approach has limitation of training data size. It is computational expensive and does not scale well after more than 10.000 records. More effective approach is needed to scale the training performance with lesser computation. Furthermore training an optimal SVM model requires number of decisions: data pre-processing / features engineering, kernel function to use and SVM parameters.</p><p><strong>3.1. SVM parameters tuning</strong></p><p>Our approach will be comparing both SVM one-vs-one and one-vs-rest approach which has been proven to be effective and scale better with larger training data size. Below are parameters we used in our SVM model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/1*CZARWplI-FHsQCAadWoaig.png" /><figcaption>SVC parameters</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*UuB1DRxe2VNNt5GB3r6FOw.png" /><figcaption>Linear SVC parameters</figcaption></figure><p><strong>3.2. Features engineering</strong></p><p>Protein sequences data are basically composed of series of characters which represents different amino acids combined. In order for our model to learn from it, we need to convert these strings into a number representation.</p><p>Bag-of-words model is one of the most popular representation methods for object categorization. The key idea is to quantize each extracted key point into one of visual words. In our case, we basically extracts each character from the string and count the number of occurrence for each symbol or character.</p><p><strong>4. EXPERIMENTAL RESULTS</strong></p><p><strong>4.1. Cross validation (Training data)</strong></p><p>Here is the 5-folds cross validation result performed with training dataset to ensure model fitness before proceeding with testing dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*CqchkcB9QWRiHKxA9lutrQ.png" /><figcaption>Cross validation</figcaption></figure><p><strong>4.2. Model accuracy (Test data)</strong></p><p>Below result table presents two SVM approaches and Naive Bayes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*6IfX2hfYxoFaJGuvkJtK6Q.png" /><figcaption>Model performance</figcaption></figure><p>In terms of model training time, Naive Bayes have highest performance compared with SVC and LinearSVC, and LinearSVC is relatively faster than SVC.</p><p><strong>5. CONCLUSIONS</strong></p><p>Typical machine learning systems operate on input data after they have been transformed into feature vectors d1,…,dn ∈ D living in an m dimensional space. There are many cases, however, where the input data cannot readily be described by explicit feature vectors: for example protein sequences.</p><p>For such datasets, the construction of a feature extraction module can be as complex and expensive as solving the entire problem. This feature extraction process not only requires extensive domain knowledge but also it is possible to lose important information during this process. These extracted features play a key role in the effectiveness of a system. Protein sequence raw data comprises of a sequence of symbols that cannot be fed directly to the algorithms themselves as most of them expect numerical feature vectors with a fixed size rather than the raw text documents with variable length. Tokenizing, counting and normalizing are the common ways to extract these numerical features from text content. We called vectorization the general process of turning a collection of text into numerical feature vectors. This specific strategy (Tokenizing, counting and normalizing) is called bag of words or bag of n-grams representation. One protein sequence can be described by symbol occurances while completely ignoring the relative position information of the symbol in the sequence.</p><p>Our experiments have shown the potential of using the bag of words representation together with SVM and we could achieve very good classification results without the need for complex manual parameter tuning.</p><p><strong>REFERENCES</strong></p><p>[1] P. Jonathan Phillips, <em>Support Vector Machines Applied to Face Recognition</em>, National Institute of Standards and Technology Bldg 225/ Rm A216, Gaithersburg/ MD 20899.</p><p>[2] Mahesh Pal, <em>Multiclass Approaches for Support Vector Machine Based Land Cover Classification</em>, Department of Civil engineering, National Institute of Technology, Kurukshetra, 136119, Haryana (India).</p><p>[3] Christina Leslie, Eleazar Eskin, William Stafford Noble, <em>The Spectrum Kernel: A String Kernel For SVM Protein Classification</em>, Department of Computer Science, Columbia University, New York, NY 10027</p><p>[4] VN Vapnik. <em>Statistical Learning Theory</em>. Springer, 1998.</p><p>[5] Yichuan Tang <a href="/service/mailto:tang@cs.toronto.edu">tang@cs.toronto.edu</a>, <em>Deep Learning using Linear Support Vector Machines. </em>Department of Computer Science, University of Toronto. Toronto, Ontario, Canada.</p><p>[6] Yin Zhang, Rong Jin, Zhi-Hua Zhou, <em>Understanding Bag-of-Words Model: A Statistical Framework. </em>National Key Laboratory for Novel Software Technology, Nanjing University, Nanjing 210093, China and Department of Computer Science &amp; Engineering Michigan State University, East Lansing, MI 48824.</p><p>[7] Huma Lodhi, Craig Saunders, John Shawe-Taylor, Nello Cristianini, Chris Watkins, <em>Text Classification using String Kernels.</em>Department of Computer Science, Royal Holloway, University of London, Egham, Surrey TW20 0EX, UK</p><p>[8] Christina S. Leslie, Eleazar Eskin, Adiel Cohen, Jason Weston and William Stafford Noble, <em>Mismatch string kernels for discriminative protein classification. </em>Department of Computer Science, Columbia University, 1214 Amsterdam Avenue, Mail Code 0401, New York, NY 10027, USA, Max-Planck Institute for Biological Cybernetics, Spemannstrasse 38, 72076 Tübingen, Germany and Department of Genome Sciences, University of Washington, 1705 NE Pacific Street, Seattle, WA 98195, USA</p><p>[9] Betty Yee Man Cheng, Jaime G. Carbonel, and Judith Klein-Seetharaman, <em>Protein Classification Based on Text Document Classification Techniques. </em>Language Technologies Institute, Carnegie Mellon University, 5000 Forbes Avenue, Pittsburgh, Pennsylvania, Department of Pharmacology, University of Pittsburgh School of Medicine, Biomedical Science Tower E1058, Pittsburgh, Pennsylvania</p><p>[10] Needleman SB, Wunsch CD. <em>A general method applicable to the search for similarities in the amino acid sequence of two proteins</em>. J Mol Biol 1970;48(3):443–453.</p><p>[11] Deshpande M, Karypis G. <em>Evaluation of techniques for classifying biological sequences</em>. In 6th Pacific-Asia Conference on Knowledge Discover (PAKDD). 2002. p 417–431.</p><p>[12] Hsu, Chih-Wei and Lin, Chih-Jen. <em>A comparison of methods for multiclass support vector machines</em>. IEEE Transactions on Neural Networks, 13(2):415–425, 2002.</p><p>[13] E. J. Bredensteiner and K. P. Bennett, <em>“Multicategory classification by support vector machines”</em> Comput. Optimiz. Applicat., pp. 53–79, 1999.</p><p>[14] C. Cortes and V. Vapnik, <em>“Support-vector network”</em> , <em>Machine Learning</em>, vol. 20, pp. 273–297, 1995.</p><p>[15] E. Mayoraz and E. Alpaydin, <em>“Support vector machines for multi-class classification”</em> in IWANN, vol. 2, 1999, pp. 833–842.</p><p>[16] Lipo Wang, <em>Support Vector Machines: Theory and Applications. </em>Springer, Berlin 2005</p><p>[17] Thorsten Joachims, <em>Text Categorization with Support Vector Machines: Learning with Many Relevant Features. </em>Universitat Dortmund Informatik LS8, Baroper Str. 301 44221 Dortmund, Germany</p><p>[18] Yuh-Jye Lee, Yi-Ren Yeh, and Hsing-Kuo Pao, <em>An Introduction to Support Vector Machines, </em>Department of Computer Science and Information Engineering National Taiwan University of Science and Technology Taipei, Taiwan 10607</p><p>[19] Olivier Chapelle, Vladimir Vapnik, Olivier Bousquet, Sayan Mukherjee, <em>Choosing Multiple Parameters for Support Vector Machines</em>. LIP6, Paris, France, AT&amp;T Research Labs, 200 Laurel Ave, Middletown, NJ 07748, USA, Ecole Polytechnique, France, MIT, Cambridge, MA 02139, USA</p><p>[20] Juwen Shen, Jian Zhang, Xiaomin Luo, Weiliang Zhu, Kunqian Yu, Kaixian Chen, Yixue Li, and Hualiang Jiang, <em>Predicting protein–protein interactions based only on sequences information. </em>Center for Drug Discovery and Design, State Key Laboratory of Drug Research, Shanghai Institute of Materia Medica, Shanghai Institutes for Biological Sciences, Chinese Academy of Sciences, and Graduate School of Chinese Academy of Sciences, 555 Zuchongzhi Road, Shanghai 201203, China; School of Pharmacy, East China University of Science and Technology, Shanghai 200237, China; and Bioinformation Center, Shanghai Institutes for Biological Sciences, Chinese Academy of Sciences, 320 Yue Yang Road, Shanghai 200031, China</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20e49f0b364c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object detection with android phone using tensor flow lite]]></title>
            <link>https://medium.com/swlh/object-detection-with-android-phone-using-tensor-flow-lite-9463a1522ffd?source=rss-c76595d8b0c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9463a1522ffd</guid>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[tensorflowjs]]></category>
            <dc:creator><![CDATA[Ricky H. Putra]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 14:50:00 GMT</pubDate>
            <atom:updated>2022-08-12T03:35:24.815Z</atom:updated>
            <content:encoded><![CDATA[<h3>Object detection in Android using React Native &amp; TensorFlow.js</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*jD2jL0ZWl6c5TssOBnnsDQ.png" /></figure><p>With the advance of AI and computing device and smart phone, it is easier for us to build and deploy machine learning application today. Many frameworks and tools are available to build sophisticated mobile application with AI enabled such as React and Tensor Flow.</p><p>In this post, I am using React Native and Tensor Flow, two very popular frameworks use to build mobile application and have been used by companies like Facebook and Google. OK, let’s get started.</p><p>First, clone my sample project here:</p><pre>$ git clone <a href="https://github.com/rickyhp/obj-detection.git">https://github.com/rickyhp/obj-detection.git</a><br>$ cd obj-detection<br>$ yarn install</pre><p>You should have the Expo project ready in less than a minute, to start running just type below command:</p><p>expo start</p><p>You can run the app with Android simulator and see the result.</p><p>Now, I will walk through the main pieces of the code for you to understand further.</p><p>Open App.js and you should find the first section on top which we import all the necessary libraries:</p><pre>import React, { Component } from &#39;react&#39;;<br>import { StyleSheet, Text, View, StatusBar, ActivityIndicator, TouchableOpacity, Image } from &#39;react-native&#39;<br>import { ScrollView } from &#39;react-native-gesture-handler&#39;;<br><br>import Constants from &#39;expo-constants&#39;<br>import * as Permissions from &#39;expo-permissions&#39;<br>import * as ImagePicker from &#39;expo-image-picker&#39;<br>import * as FileSystem from &#39;expo-file-system&#39;<br><br>import * as jpeg from &#39;jpeg-js&#39;<br><br>import * as tf from &#39;@tensorflow/tfjs&#39;;<br>import &#39;@tensorflow/tfjs-react-native&#39;;<br><br>// import * as mobilenet from &#39;@tensorflow-models/mobilenet&#39;<br>// You can try with other models, see https://github.com/tensorflow/tfjs-models<br>import * as cocossd from &#39;@tensorflow-models/coco-ssd&#39;</pre><p>The first 3 imports are standard react native UI component libraries, then follow by 4 imports related with Expo framework. Jpeg-js is used to decode raw image data to 3d array tensor object as it is required by our model. Next 2 imports for tensorflow.js and tensorflow.js for react native as we are building React Native app. Last import is the model we use to predict the image.</p><p>There are three main logics in our sample code:</p><ol><li>Preparing TensorFlow engine</li><li>Loading model</li><li>User to choose image for model to predict, model does the prediction and result will be printed below the image</li></ol><p>Step 1: Preparing TensorFlow engine</p><pre>await tf.ready();<br>this.setState({ isTfReady: true,});</pre><p>Step 2: Loading model</p><pre>this.model = await cocossd.load();<br>this.setState({ isModelReady: true });</pre><p>Step 3: User to choose image for model to predict, model does the prediction and result will be printed below the image</p><pre>try {<br>  let response = await ImagePicker.launchImageLibraryAsync({<br>    mediaTypes: ImagePicker.MediaTypeOptions.All,<br>    allowsEditing: true,<br>    aspect: [4, 3]<br>  })<br><br>  if (!response.cancelled) {<br>    const source = { uri: response.uri }<br>    this.setState({ image: source })<br>    this.detectObjects()<br>  }<br>} catch (error) {<br>  console.log(error)<br>}</pre><p>detectObjects method is our main prediction logic</p><pre>detectObjects = async () =&gt; {<br>  try {<br>    const imageAssetPath = Image.resolveAssetSource(this.state.image)<br><br>    console.log(imageAssetPath.uri);<br>    const imgB64 = await FileSystem.readAsStringAsync(imageAssetPath.uri, {<br>       encoding: FileSystem.EncodingType.Base64,<br>    });<br>    const imgBuffer = tf.util.encodeString(imgB64, &#39;base64&#39;).buffer;<br>    const raw = new Uint8Array(imgBuffer)<br>    const imageTensor = this.imageToTensor(raw);<br>    console.log(&#39;imageTensor: &#39;, imageTensor);<br>    const predictions = await this.model.detect(imageTensor)<br><br>    this.setState({ predictions: predictions })<br><br><br>    console.log(&#39;----------- predictions: &#39;, predictions);<br><br>  } catch (error) {<br>    console.log(&#39;Exception Error: &#39;, error)<br>  }<br>}</pre><p>In my case, I use FileSystem.readAsStringAsync to read the image from local storage. It is read as String object with base64 encoding type, we need to convert it into Uint8Array using jpeg-js decoder and then created a 3d tensor object.</p><pre>imageToTensor(rawImageData) {<br>  const TO_UINT8ARRAY = true<br>  const { width, height, data } = jpeg.decode(rawImageData, TO_UINT8ARRAY)<br>  <br>  const buffer = new Uint8Array(width * height * 3)<br>  let offset = 0 // offset into original data<br>  for (let i = 0; i &lt; buffer.length; i += 3) {<br>    buffer[i] = data[offset]<br>    buffer[i + 1] = data[offset + 1]<br>    buffer[i + 2] = data[offset + 2]<br><br>    offset += 4<br>  }<br><br>  return tf.tensor3d(buffer, [height, width, 3])<br>}</pre><p>For rendering part, we create a method renderPrediction which take the result from our model.detect function. And since we are using COCO Single Shot MultiBox Detection (capable of identifying 90 classes of objects) here, it returns an array of bounding boxes with class name and confidence level.</p><pre>renderPrediction = (prediction, index) =&gt; {<br>  const pclass = prediction.class;<br>  const score  = prediction.score;<br>  const x = prediction.bbox[0];<br>  const y = prediction.bbox[1];<br>  const w = prediction.bbox[2];<br>  const h = prediction.bbox[3];<br><br>  return (<br>      &lt;Text key={index} style={styles.text}&gt;<br>        Prediction: {pclass} {&#39;, &#39;} Probability: {score} {&#39;, &#39;} Bbox: {x} {&#39;, &#39;} {y} {&#39;, &#39;} {w} {&#39;, &#39;} {h}<br>      &lt;/Text&gt;<br>  )<br>}</pre><p>Here we go, the result of sample prediction running in Note10+ which takes less than 2 seconds to show.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*go2bGJLJJWywGu-ikIqR_Q.jpeg" /></figure><p>Please <strong>follow </strong>me if you find this article useful, it would motivate me to write more useful articles and helping others to learn. Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9463a1522ffd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/object-detection-with-android-phone-using-tensor-flow-lite-9463a1522ffd">Object detection with android phone using tensor flow lite</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>