<?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 Ju on Medium]]></title>
        <description><![CDATA[Stories by Ju on Medium]]></description>
        <link>https://medium.com/@jjuinni?source=rss-46a086036c50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bbzK7DlunG2enq2n</url>
            <title>Stories by Ju on Medium</title>
            <link>https://medium.com/@jjuinni?source=rss-46a086036c50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 11:02:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jjuinni/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[CNN Architecture from Scratch — ResNet50 with Keras]]></title>
            <link>https://jjuinni.medium.com/cnn-architecture-from-scratch-resnet50-with-keras-4414539521d1?source=rss-46a086036c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/4414539521d1</guid>
            <category><![CDATA[network-architecture]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[resnet50]]></category>
            <category><![CDATA[keras]]></category>
            <dc:creator><![CDATA[Ju]]></dc:creator>
            <pubDate>Sat, 20 Feb 2021 21:57:32 GMT</pubDate>
            <atom:updated>2021-02-20T21:57:32.492Z</atom:updated>
            <content:encoded><![CDATA[<h3>CNN Architecture from Scratch — ResNet50 with Keras</h3><p>Flower Image Recognition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ny5wY0d8Zz7JmWYr" /><figcaption>Photo by <a href="https://unsplash.com/@stephenleo1982?utm_source=medium&amp;utm_medium=referral">Stephen Leonardi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Although, in practice it’s most common to use pre-trained networks we are not going to talk about them here. Now, if you are interested in understanding the network architecture and how it is coded I would say this could be an interesting read for you. — I hope :) <br>It’s worth saying the network built here is based on the explanation and knowledge acquired from <a href="https://www.coursera.org/specializations/deep-learning">Deep Learning Specialization</a> offered by <a href="https://deeplearning.ai/">DeepLearning.AI</a>. — Great courses!</p><h3>What flower is this?</h3><p>While travelling, there were a couple of times I would see flowers or plants and wonder what is its name. At one time I thought, wouldn’t it be great if there was an application where I would just take a picture and know right away! With that memory in mind, I picked this <a href="https://www.kaggle.com/alxmamaev/flowers-recognition">Flower Image Dataset</a> to make an image classification system. <br>This Dataset have a 4323 image collection of 5 types of flowers. Which are daisy, dandelion, rose, sunflower and tulip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xUxr5GwLnSCfVK51-DIcvA.png" /><figcaption>Sample Images from Dataset</figcaption></figure><h3>ResNet to the Rescue</h3><p><a href="https://arxiv.org/pdf/1512.03385.pdf">Residual Networks</a> are a very powerful model for image recognition. The introduction of ResNet allowed to train much deeper networks than were previously feasible (e.g., LeNet-5, AlexNet and VGG). <br>Very deep networks can represent very complex functions, but in practice they don’t work because they are hard to train due to vanishing gradients. The skip-connections (skipping over layers) helps to address this problem by reusing activations from a previous layer until the adjacent layer learns its weights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kanYOsFl0MmaPk5ZWDjJmw.png" /><figcaption>A ResNet block illustrating a <strong>skip-connection</strong></figcaption></figure><p>These Residual Networks are built by stacking two main types of blocks, the identity block (standard block used in ResNet) and the convolutional block. Typical implementations skips two or three layers that contain nonlinearities (ReLU) and batch normalization in between.<br>- Identity block: Is the standard block used in ResNet and used when the input activation has the same dimension as the output activation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OIMU3ekaWGvEdZpQlTUSyg.png" /><figcaption><strong>Identity block.</strong> Skip connection “skips over” 2 layers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uyXEvYztiv3fGGCCPbm8Jg.png" /><figcaption><strong>Identity block.</strong> Skip connection “skips over” 3 layers</figcaption></figure><p>- Convolutional block: CONV2D layer in the shortcut path and used when the input and output dimensions don’t match up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U5wkA4O1IpY-ekXqFh0tUQ.png" /><figcaption><strong>Convolutional block</strong></figcaption></figure><p>All together, this classic ResNet-50 has the following architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEU7S-EiVqcmtAlj6kgfRA.png" /><figcaption><strong>ResNet-50 model</strong></figcaption></figure><h3>Training ResNet-50</h3><p>Now that we implemented our model we can think of training it!<br>The Dataset have a good distribution of images, it’s relatively balanced so that won’t be an issue. I used 90% of the images to train the model and 10% for validation, which I believe to be a good proportion. <br>To make the training faster I also resized all images to 64 x 64 x 3 dimension images. And to prevent overfitting, I took advantage of data augmentation and added regularization to the Conv2D and Dense layers with l2 = 1e-4. <br>For the learning process, I used the Adam optimizer which combines the best properties of the AdaGrad and RMSProp algorithms.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d5e516fe4880010e8089ed3d625cf79/href">https://medium.com/media/8d5e516fe4880010e8089ed3d625cf79/href</a></iframe><p>In the case we train the model on 64 epochs with a batch size of 40 its given an accuracy of 77.60%. Training the model for other values of iterations and batch size will bring other effects to the performance of the model. Doing a few experiments I verified a test accuracy that oscillates up to 82% (re-trained the model a couple of times to see how this would change).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*FpPn8HzohYC3Lw0D8BEqsg.png" /><figcaption>Performance on Test set</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*1s5IrImZSioCu2-O7ZMe9A.png" /><figcaption>Performance history</figcaption></figure><p>There is always room for improvement, but for the purpose of this article, which is to understand the architecture of a network I didn’t spend more time from here.<br>Possible reasons behind the fluctuation over epochs,<br>(i) All Neural Networks have a natural stochastic behavior<br>(ii) Large network but small dataset: 23M+ parameters for less than 4323 images available<br>(iii) Batch size and learning rate</p><p>To overcome overfitting, <br>(i) Add more regularization and play with hyper parameters<br>(ii) Data augmentation<br>(iii) Increase more data samples naturally<br>(iv) Reduce hidden layers</p><h3>Visualizing Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*pv0ODF8_qNCO0ARZQhQxdA.png" /><figcaption>Expected: Tulip | Actual: Tulip</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*Dk8P1WVPi76UQZCTfwT9yQ.png" /><figcaption>Expected: Dandelion | Actual: Dandelion</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*vv-qnBm9frhjKFFm7o7X0A.png" /><figcaption>Expected: Sunflower | Actual: Sunflower</figcaption></figure><h3>Final Notes</h3><ul><li>Fine tuning and training a ResNet model can consume a great deal of time.</li><li>For a more practical usage, pre-trained network architectures open source implementations might be the best idea because it can achieve great results and save a lot of time.</li><li>ResNet can be a very powerful model but when considering computational budget use transfer learning.</li><li>Check this <a href="https://github.com/jjuinni/Portfolio/blob/master/flower-recognition-resnet50.ipynb">notebook</a> for the complete analysis.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4414539521d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scraping FinViz: Getting Financial Ratios with Python and Applying Valuation Methods]]></title>
            <link>https://jjuinni.medium.com/scraping-finviz-getting-financial-ratios-with-python-and-applying-valuation-methods-655710a024fe?source=rss-46a086036c50------2</link>
            <guid isPermaLink="false">https://medium.com/p/655710a024fe</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[exploratory-data-analysis]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Ju]]></dc:creator>
            <pubDate>Mon, 12 Oct 2020 21:08:33 GMT</pubDate>
            <atom:updated>2020-10-12T21:08:33.823Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>An approach to get Fundamental Ratios and evaluate Securities.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PVfhC8fHF_SX6PRM" /><figcaption>Photo by <a href="https://unsplash.com/@micheile?utm_source=medium&amp;utm_medium=referral">Micheile Henderson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Why FinViz?</h3><p><a href="https://finviz.com/">FinViz</a> is one of the most widely used US stock screener website. It offers a large range of information in its free version, which you can use to make a analytical decision on buying/selling certain securities. FinViz offers a great depth of technical, descriptive and fundamental information on stocks. You can explore yourself on their website if you don’t know about it yet.</p><h3>Scraping Ratios with Python</h3><p>There is really a lot of information offered by FinViz, in here I scrapped data with the purpose of conducting a simple stock valuation analysis to calculate its fair value. For that, I predefined the financial metrics I wanted and scraped the data from the security of interest and its sector or industry related securities for further analysis.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/964b9403def58a659730ffaa88ac6b1c/href">https://medium.com/media/964b9403def58a659730ffaa88ac6b1c/href</a></iframe><p>Using <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/">BeautifulSoup</a> we will start navigating from the quote page(<a href="https://finviz.com/quote.ashx?t=aapl">example</a>) of the chosen symbol and we will go to the <a href="https://finviz.com/screener.ashx">screener page</a> according to the filter selection(by <a href="https://finviz.com/screener.ashx?v=111&amp;f=sec_technology">sector </a>or <a href="https://finviz.com/screener.ashx?v=111&amp;f=ind_consumerelectronics">industry</a>). In the screener page we will have all the related symbols, now we can get their financial ratios and store these data in a dataframe with <a href="https://pandas.pydata.org/docs/user_guide/index.html#user-guide">Pandas</a>. After successfully retrieving the web data, we will clean this data and transform it to an all numeric values dataframe and use it to calculate the fair value of the symbols according to two valuation methods, a <a href="https://www.youtube.com/watch?v=cI8ZSf0nkFs&amp;feature=youtu.be">Simple Discounted Cash Flow</a> and <a href="https://www.youtube.com/watch?v=nX2DcXOrtuo">Phil Town’s ‘Margin of Safety</a>’. Finally, we will store this information in a database files so we can readily access this data.</p><p>For better code readability I used <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">OOP</a> and separated the process in steps. For that I created an abstract class ‘Parser’(<a href="https://gist.github.com/jjuinni/56bf480109abdc2242bc81cf6b9eeba5">details in: code</a>) which will contain subclass ‘TickerParser’ and ‘ScreenerParser’. They will be responsible to parse the chosen symbol page and the screener page according to chosen filter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58c00993d451c3200d9b902011acf2b2/href">https://medium.com/media/58c00993d451c3200d9b902011acf2b2/href</a></iframe><p>Now that I have a list with all the tickers(symbols) I can scrape the ratios from its urls and store them in a dataframe.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06c98ba7e7561c026488a5cc0928d08e/href">https://medium.com/media/06c98ba7e7561c026488a5cc0928d08e/href</a></iframe><p>At this point, I’ve got my data stored as a dataframe. But it’s not exactly in the format I need to apply the valuation methods. The data we scraped is originally in this format:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CpRb48hGZzf4O__OULWxFw.png" /><figcaption>Scraped METRICS highlighted in yellow</figcaption></figure><p>After retrieving the web data, our dataframe has numeric and text data depending on the metric. I’ll treat this data so we have an all numeric dataframe that can easily be manipulated for further valuation calculations (details in: <a href="https://gist.github.com/jjuinni/27c3b58bce07e60c334ac0152a039274">code</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*en-0noOuhfLQ-fRz_Zks_w.png" /><figcaption>Illustration of dataframe after cleaning process</figcaption></figure><p>Now we are ready to apply our valuation methods! <br>I won’t get into the details of each methods idea, but you can have a look in the following links to understand the idea behind it: <br>- <a href="https://www.youtube.com/watch?v=cI8ZSf0nkFs&amp;feature=youtu.be">Simple Discounted Cash Flow</a> <br>- <a href="https://www.youtube.com/watch?v=nX2DcXOrtuo">Phil Town’s ‘Margin of Safety</a>’<br>- Or also, more details in <a href="https://gist.github.com/jjuinni/4832a8cbd7a65432e935f6bf829220bc">code</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08e71c0617cedc0826e587314fb009d8/href">https://medium.com/media/08e71c0617cedc0826e587314fb009d8/href</a></iframe><p>Finally, we can store the results in a database file (or any other format of choice) so we don’t have to scrape FinViz every time we want to use this data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acd58405eda43585303d7240f707b67f/href">https://medium.com/media/acd58405eda43585303d7240f707b67f/href</a></iframe><p><strong><em>Note: About missing values<br></em></strong>Although FinViz is a very powerful data source, there are missing ratios. This can happen for a variety of factors. Consequently, part of the calculated intrinsic values are missing because they are calculated with some of the metrics we got from the website. <br>It’s the most common problems financial firms face while utilizing data. And imputing fundamental data that is missing can be very time consuming because of the importance of accuracy of these information that cannot be underestimated. It would require diverse data sources and data would need to be tested for its usability.<br>This treatment is out of the scope of this article.</p><h3>Example of usage: Fundamental Analysis of Apple Inc.</h3><p>To calculate the value of a security is not something trivial, but thoughtful analysis will include estimations based on many different aspects of the business and can give a good prediction to the security value in the future. You can find more about value investing in <a href="https://www.investopedia.com/terms/v/valueinvesting.asp">here</a>.<br>The approach presented here focuses on estimating the value of an investment today with only financial ratios.</p><ol><li>We can try summarize a range of values for the business based on the different valuation methods we applied with the purpose of showing how much a buyer might be willing to pay for the business. And do the same with other similar businesses to compare their behavior.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*ZdTl9yNPbr5CQ1mx9w3wMA.png" /><figcaption>AAPL Valuation Summary (details in <a href="https://gist.github.com/jjuinni/bf90522b30989716a727c4aabc94155d">code</a>)</figcaption></figure><p>2. We could see how well Apple can deliver value to shareholders compared to four other from the same sector or industry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*k4M2ut-DFnqSxb_NL6pG4w.png" /><figcaption>EPS Growth Projection by sector or industry (details in <a href="https://gist.github.com/jjuinni/f7d267ecf48dd5e7ba1eefbcf4078ce4">code</a>)</figcaption></figure><p>If you would like to check the code or the exploratory data analysis related to this article, please visit my <a href="https://github.com/jjuinni/Portfolio/tree/master/Fundamental%20Analysis%20of%20a%20Stock">github</a>. <br>Thank you very much for reading.</p><p><strong><em>Disclaimer:</em></strong><em> </em><strong><em>I’m interested in the stock market but I’m not an expert. This is not a suggestion of investment. The material presented in this article is educational.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=655710a024fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>