<?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 Yora Radityohutomo on Medium]]></title>
        <description><![CDATA[Stories by Yora Radityohutomo on Medium]]></description>
        <link>https://medium.com/@yoratyo?source=rss-d7ed589bab2a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_hZKfAE956yKgO9N.</url>
            <title>Stories by Yora Radityohutomo on Medium</title>
            <link>https://medium.com/@yoratyo?source=rss-d7ed589bab2a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 20:38:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yoratyo/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[Scaling Flask Application Using Blueprints]]></title>
            <link>https://medium.com/@yoratyo/scaling-flask-application-using-blueprints-957a109aab73?source=rss-d7ed589bab2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/957a109aab73</guid>
            <category><![CDATA[organize]]></category>
            <category><![CDATA[scaling]]></category>
            <category><![CDATA[blueprint]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[flask]]></category>
            <dc:creator><![CDATA[Yora Radityohutomo]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 03:52:53 GMT</pubDate>
            <atom:updated>2018-04-06T04:08:20.441Z</atom:updated>
            <content:encoded><![CDATA[<p>Building simple flask application is really easy, but it can be little bit messy if you have many routes and templates just in one module of project. It will be better if you can separate the project to some modules along your application become more complex.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*y2ZnkATnJS80URBl86gKEg.png" /><figcaption>Image from this <a href="https://www.cockroachlabs.com/docs/stable/automated-scaling-and-repair.html">link</a></figcaption></figure><p>There is a way to organize your flask application become more scalable, that is Blueprints. Blueprints enable you to separate your flask app into specific module, so it can be easier to maintained.</p><p>First, we have to structuring our application to have directory as follows.</p><pre>project<br>    ├── app.py<br>    └── blueprints<br>        ├── __init__.py<br>        └── module_1<br>            ├── templates<br>            │   └── index.html<br>            └── views.py</pre><p>First, we need to edit file from the bottom of directory, which is <em>index.html</em> that is used to render the templates from your module. This following code is the example of <em>index.html</em>.</p><pre>&lt;h1&gt;Hello, this is index from module 1&lt;/h1&gt;</pre><p>Then we edit the routing of module 1 in <em>view.py</em> file. Follow the code bellow to create blueprints of module 1.</p><pre>from flask import render_template, Blueprint</pre><pre>mod1 = Blueprint(<br>    <strong>&#39;mod1&#39;</strong>, <em>#name of module<br>    </em>__name__,<em><br>    </em>template_folder=<strong>&#39;templates&#39; </strong><em># templates folder<br></em>)</pre><pre>@mod1.route(<strong>&#39;/&#39;</strong>)<br><strong>def </strong>index():<br>    <strong>return </strong>render_template(<strong>&#39;new.html&#39;</strong>)</pre><p>After that we start to edit <em>__init__.py</em> inside blueprints directory. This is the initialization file of your application. You can register your module and define the url prefix in this file with following code.</p><pre><strong>from </strong>flask <strong>import </strong>Flask<br>from blueprints.module_1.views import mod1</pre><pre>app = Flask(__name__)<br>app.register_blueprint(mod1, url_prefix=<strong>&#39;/module1&#39;</strong>)</pre><p>And the last, edit <em>app.py</em> with the following code that is used to run your application.</p><pre>from blueprints import app<br>app.run(host=&#39;0.0.0.0&#39;, port=8080, debug=True)</pre><p>You can run the flask application by execute this command.</p><pre>python app.py</pre><p>Finally your application can be open on your browser. You can run your tested module by this url localhost:8080/module1.</p><p>This is the minimal set to create flask with blueprints. Later you can add some module to your application without changing previous module, because it can be work independently. All you need to do after create a new module is register blueprints module in <em>__init__.py</em> file.</p><p>You can found the example flask project using blueprints on my <a href="https://github.com/yoratyo/flask-blueprints">github</a> repository. Happy coding and good luck.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=957a109aab73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sentiment Analysis Using TextBlob]]></title>
            <link>https://medium.com/@yoratyo/sentiment-analysis-using-textblob-c57728ded1ec?source=rss-d7ed589bab2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c57728ded1ec</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[text-mining]]></category>
            <dc:creator><![CDATA[Yora Radityohutomo]]></dc:creator>
            <pubDate>Sun, 01 Apr 2018 02:13:34 GMT</pubDate>
            <atom:updated>2018-04-01T02:40:04.565Z</atom:updated>
            <content:encoded><![CDATA[<p>Sentiment analysis is natural language processing method to identify and quantify the subjective information. It can classify some information into three reaction, they are <em>positive</em>, <em>negative</em> and <em>neutral</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*jHzNpL-KagnaHUSHzPTPkA.jpeg" /><figcaption>image from this <a href="https://www.kdnuggets.com/images/sentiment-fig-1-689.jpg">source</a></figcaption></figure><p>You can create simple sentiment analysis easily with <a href="https://www.python.org/">python</a>. All dependency that you need is <a href="http://textblob.readthedocs.io/en/dev/">TextBlob</a>. You can install it with <a href="https://pip.pypa.io/en/stable/installing/">pip</a> by this following command.</p><pre>pip install textblob</pre><p>Lets begin with creating a python file and add the following code.</p><p>First, import the TextBlob function.</p><pre>from textblob import TextBlob</pre><p>Then, create a variable to store input text that you want to know its sentiment with TextBlob function.</p><pre>#put your input inside TextBlob<br>analysis = TextBlob(&#39;not a very great experiment&#39;)</pre><p>Finally you can print the sentiment value with this following code.</p><pre>print(analysis.sentiment)</pre><p>You will see the output with the two value, they are <strong><em>polarity</em></strong> and <strong><em>subjectivity</em></strong>. The polarity score is a float within the range [-1.0, 1.0]. The subjectivity is a float within the range [0.0, 1.0]. Polarity indicates the sentiment, minus is for negative, 0 is for neutral and positive is for positive statement. Subjectivity indicates that if its close to 0 means objective statement, but if its close to 1 means the statement is very subjective. The output of code above is such the following.</p><pre>Sentiment(polarity=-0.30769230692377,subjectivity=0.57692369230769)</pre><p>The sentence “not a very great experiment” has a <em>polarity</em> of about -0.3, meaning it is slightly negative, and a <em>subjectivity</em> of about 0.6, meaning it is fairly subjective.</p><p>Congratulation, you have created your simple sentiment analysis. Good luck at your experiment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c57728ded1ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build Python Classifier Using Scikit-learn]]></title>
            <link>https://medium.com/@yoratyo/how-to-build-python-classifier-using-scikit-learn-c27f1a08254?source=rss-d7ed589bab2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c27f1a08254</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[scikit-learn]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[decision-tree]]></category>
            <dc:creator><![CDATA[Yora Radityohutomo]]></dc:creator>
            <pubDate>Sun, 01 Apr 2018 02:10:25 GMT</pubDate>
            <atom:updated>2018-04-04T10:35:11.841Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is general purpose programming language that have special place on every data scientist. It has huge packages of data processing tools that can help them to solve the problem.</p><p>Classification is the common problem that can be solved with data. The goal is you can make a prediction with some given data. Here is the diagram of classification process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Vv6TezbZ5FJpS_eBxZB6Q.png" /><figcaption>image from this <a href="https://image.slidesharecdn.com/machine-learning-and-data-mining-14-evaluation-and-credibility-28463/95/machine-learning-and-data-mining-14-evaluation-and-credibility-16-728.jpg?cb=1176687268">source</a></figcaption></figure><p>First to do is determine what classes that will be predicted as the output, and what features that we use as the input. As the example I will predict whether someone is obese or not with age, weight and height data.</p><p>Then we can started using <a href="http://scikit-learn.org/stable">Scikit-learn</a> to create our prediction model. You have to make sure <a href="https://www.python.org/">Python</a> running on your machine. We also need pip to get our dependencies. Once you have done <a href="https://pip.pypa.io/en/stable/installing/">installing pip</a>, you can get Scikit-learn, numpy and scipy dependency with the following code.</p><pre>pip install -U scikit-learn<br>pip install numpy<br>pip install scipy</pre><p>Scikit-learn have many machine learning models to classify the data, but now we use <strong><em>Decision Tree</em></strong>. To implemented the classifier, create a python file and add the code with following instruction.</p><p>first, import Decision Tree model from Scikit-learn.</p><pre>from sklearn import tree </pre><p>Then, create pairs of input data and the label as training data.</p><pre>#[age, weight, height]<br>input = [[20,61.2,165.0], [15,49.2,144.3], [23,62.6,150.0]]</pre><pre>#obese (yes,no)<br>label = [&#39;no&#39;, &#39;no&#39;, &#39;yes&#39;]</pre><p>After that, Initialize the decision tree classifier and train the data.</p><pre>classifier = tree.DecisionTreeClassifier()<br>classifier = classifier.fit(input, label)</pre><p>Finally you can tested your model to predict the different input of data.</p><pre>prediction = classifier.predict([[31,89.0,155.2]])<br>print(prediction)</pre><p>The accuracy of the result is depends of the training data. It requires a lot of accurate training data to create more accurate model, so you can try to train your model that suite to your problem.</p><p>Congratulation, you have created simple python classifier using Scikit-learn. I’m pretty sure it can help you understand the basic of classification. Good luck.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c27f1a08254" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Flask on Docker]]></title>
            <link>https://medium.com/@yoratyo/running-flask-on-docker-dc3941d39304?source=rss-d7ed589bab2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc3941d39304</guid>
            <category><![CDATA[python-flask]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-compose]]></category>
            <dc:creator><![CDATA[Yora Radityohutomo]]></dc:creator>
            <pubDate>Sat, 31 Mar 2018 09:00:20 GMT</pubDate>
            <atom:updated>2018-03-31T17:31:59.875Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="http://flask.pocoo.org/">Flask</a> is the lightweight web framework in python. Flask can be used easily to create API or simple web application. Once you have done create your flask application in your local machine, you have to deploy it to the server. Sometimes it feels so painful to make sure your application can run smoothly in the server just because you have different environment on your local. But with Docker, you can fix the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqkOxvoRYBBXy3IIr9ikzQ.jpeg" /><figcaption>image from <a href="https://codefresh.io/docker-tutorial/hello-whale-getting-started-docker-flask/">https://codefresh.io/docker-tutorial/hello-whale-getting-started-docker-flask/</a></figcaption></figure><p>So, what is <a href="https://www.docker.com/">Docker</a> actually? Docker is the platform to enable developer help devops to build, ship and run the application. Docker exist as virtual machine that can containerized your application. It means all your dependency included in simple distributed configuration.</p><p>First you need to install docker, you can follow <a href="https://docs.docker.com/install/">here</a> based on your operating system. And then you need to install docker compose to simplify defining and running multi docker container, you can follow <a href="https://docs.docker.com/compose/install/">this</a> instruction.</p><p>Create a project directory, as the example I create “flask_docker_demo”.</p><pre>mkdir flask_docker_demo<br>cd flask_docker_demo</pre><p>You need to specify list of python modules in <strong><em>requirements.txt</em></strong> file in your project directory. Just fill with <em>flask</em> and <em>gunicorn</em> for minimal requirements.</p><p>Create new folder to store all your python code, I create <strong>web_app</strong> folder. Then create <strong><em>app.py</em></strong> inside of <strong>web_app </strong>and add the following code.</p><pre><strong>from </strong>flask <strong>import </strong>Flask<br><br>app = Flask(__name__)<br><br>@app.route(<strong>&#39;/&#39;</strong>)<br><strong>def </strong>index():<br>    <strong>return &quot;Hello World!!&quot;</strong></pre><p>And the last, you need to create <strong><em>Dockerfile</em></strong> and <strong><em>docker-compose.yml</em></strong> outside the <strong>web_app</strong> folder. Here is code inside <strong><em>Dockerfile</em></strong>.</p><pre><strong>FROM </strong>python:2.7<strong>-</strong>slim<br><strong>MAINTAINER </strong>Yora Radityohutomo <strong>&lt;</strong>yoratyo@gmail.com<strong>&gt;<br><br>RUN </strong>apt-get update <strong>&amp;&amp; </strong>apt-get install <strong>-</strong>qq <strong>-</strong>y \<br>  build-essential libpq-dev <strong>--</strong>no-install-recommends<br><br><strong>ENV <em>INSTALL_PATH </em>/</strong>web_app<br><strong>RUN </strong>mkdir <strong>-</strong>p $<strong><em>INSTALL_PATH<br><br></em>WORKDIR </strong>$<strong><em>INSTALL_PATH<br><br></em>COPY </strong>requirements.txt requirements.txt<br><strong>RUN </strong>pip install <strong>-</strong>r requirements.txt<br><br><strong>COPY </strong>. .<br><br><strong>CMD </strong>gunicorn <strong>-</strong>b 0.0.0.0:8000 <strong>--</strong>access-logfile <strong>- &quot;web_app.app:app&quot;</strong></pre><p>And following code inside <strong><em>docker-compose.yml.</em></strong></p><pre><strong>version: &#39;2&#39;<br><br>services:<br>  web_app:<br>    build: </strong>.<br>    <strong>command: </strong>&gt;<br>      gunicorn -b 0.0.0.0:8000<br>      --access-logfile -<br>      --reload<br>      &quot;web_app.app:app&quot;<br>    <strong>environment:<br>      PYTHONUNBUFFERED: &#39;true&#39;<br>    volumes:<br>      </strong>- <strong>&#39;.:/web_app&#39;<br>    ports:<br>      </strong>- <strong>&#39;8000:8000&#39;</strong></pre><p>To build and run the application you can execute this command on your terminal inside the project directory.</p><pre>docker-compose up --build</pre><p>You can test it by opening this url in the browser.</p><pre>localhost:8000</pre><p>Congratulation you have done your first simple flask application using docker. Its very simple right? You can clone the example project from my <a href="https://github.com/yoratyo/yoratyo-flask/">github</a>. Happy coding..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc3941d39304" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>