<?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 Luka Beverin on Medium]]></title>
        <description><![CDATA[Stories by Luka Beverin on Medium]]></description>
        <link>https://medium.com/@u04561890?source=rss-5d4a39f8d4c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xp3jGAldnbZlcZ-pCYiUsA.png</url>
            <title>Stories by Luka Beverin on Medium</title>
            <link>https://medium.com/@u04561890?source=rss-5d4a39f8d4c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:49:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@u04561890/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[Setting Up Metaflow with AWS CloudFormation]]></title>
            <link>https://medium.com/@u04561890/setting-up-metaflow-with-aws-cloudformation-5c824e5ff107?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c824e5ff107</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[metaflow]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 12:32:41 GMT</pubDate>
            <atom:updated>2024-04-07T12:32:41.376Z</atom:updated>
            <content:encoded><![CDATA[<p>“Metaflow makes it easy to build and manage real-life data science and machine learning projects.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pKUNvjiMOMeBBnMW.png" /><figcaption>image <a href="https://docs.metaflow.org/introduction/why-metaflow">creds</a></figcaption></figure><p>In this quick and simple tutorial we go through setting up <a href="https://netflixtechblog.com/open-sourcing-metaflow-a-human-centric-framework-for-data-science-fa72e04a5d9">Metaflow</a> with AWS CloudFormation to use AWS resources for scalable data science workflows. We start with creating an AWS account and configuring the AWS CLI, then we’ll authenticate your requests to AWS using access credentials. Next, we introduce AWS CloudFormation, a service enabling the automated deployment of AWS resources, essential for Metaflow’s cloud-scaling capabilities.</p><p>Then, by following the Outerbounds tutorial, you’ll deploy a Metaflow-specific AWS CloudFormation template, configure Metaflow to use AWS resources with the metaflow configure aws --profile metaflow command, and ultimately test your setup with a simple Metaflow script. This process is a simple end-to-end setup of Metaflow on AWS.</p><h3>Step 1: Setting Up the AWS CLI</h3><p>The first step involves creating an AWS account and installing the AWS CLI (<a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">link</a>). The AWS CLI which allows you to control AWS from the command line. The standard documentation by AWS is called “<a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html">Using Amazon ECR with the AWS CLI</a>”- but we found this <a href="https://docs.amplify.aws/gen2/start/account-setup/">tutorial</a> by Amplify to be more helpful.</p><p>Of course, in the tutorial, instead of setting “- -profile” to amplify-admin as they do, use a different name, something you will remember.</p><p>Once you have set up AWS CLI and configured your profile, you will have the <strong>AWS Access Key ID</strong> and <strong>Secret Access Key.</strong> These are the credentials that the AWS CLI uses to authenticate your requests to AWS. The Access Key ID is like a username, and the Secret Access Key is like a password. They are associated with an IAM (Identity and Access Management) user or role in your AWS account that has permissions to access the resources and services you want to manage with the CLI.</p><h3>Step 2: Understanding AWS CloudFormation</h3><p>AWS <a href="https://www.contino.io/insights/aws-cloudformation">CloudFormation</a> is a service that gives us an easy way to create a collection of related AWS and third-party resources, manage them in a simple and predictable way, and provision and update them in an orderly and controlled sequence. It enables us to use a high-level programming language or a simple text file to model and provision, in an automated and secure manner, all the resources needed for your applications across all regions and accounts.</p><p><strong>AWS &lt;&gt; Metaflow Managed with CloudFormation</strong></p><p>The AWS CloudFormation template that <strong>Metaflow</strong> ships with is designed to streamline the deployment of the necessary AWS resources to enable cloud-scaling capabilities within Metaflow. This template is a JSON or YAML file that defines the AWS resources (and their configurations) required to run Metaflow workflows at scale, leveraging various AWS services, such as S3 buckets or AWS Step functions.</p><p>To add metaflow to your AWS CloudFormation, follow the tutorial here:</p><p><a href="https://outerbounds.com/engineering/deployment/aws-managed/cloudformation/">AWS Managed with CloudFormation | Outerbounds</a></p><p>The CloudFormation template acts like a blueprint for your AWS infrastructure, and when it’s executed, it provisions and configures the resources as defined. So, if your template (you can change it if you want) includes a section that defines an S3 bucket — using the AWS::S3::Bucket resource type, for example—AWS CloudFormation will create this bucket for you during the stack creation process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qsTxKmDb_OqwxnHCi61_ug.png" /></figure><h3>Step 3: Metaflow AWS Integration Setup</h3><p>After deploying your AWS resources with CloudFormation for Metaflow, the next step involves configuring Metaflow to use these resources. This is done by setting up your Metaflow environment to communicate with AWS under the appropriate permissions and configurations.</p><p>The command is, metaflow configure aws --profile metaflow, plays a critical role in this process.</p><blockquote><em>Let’s assume you’re in a project folder with a </em><a href="https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/"><em>python virtual environment</em></a></blockquote><p>--profile metaflow: This “metaflow” after profile, specifies which AWS CLI named profile to use when configuring Metaflow. A named profile contains a set of configuration and credentials that you can apply to your AWS CLI commands. By specifying --profile metaflow, you&#39;re telling Metaflow to use the credentials and settings associated with the metaflow profile, which should have permissions tailored for Metaflow&#39;s operations.</p><p>Once you have run metaflow configure aws --profile metaflow , you will get the following response:</p><blockquote><em>Welcome to Metaflow! Follow the prompts to configure your installation.</em></blockquote><blockquote><em>Metaflow relies on AWS access credentials present on your computer to access resources on AWS.<br>Before proceeding further, please confirm that you have already configured these access credentials on this computer.</em></blockquote><p>If you configured your AWS CLI correctly, your AWS Access Key ID and AWS Secret Access Key will be stored in ~/.aws/credentials, and this is where Metaflow will find the keys needed to access AWS.</p><p>Next it will ask about</p><ol><li>Amazon S3 as the storage backend</li></ol><p>Here you will need to tell Metaflow where to store the artifacts. The structure needs to be in the following format = (s3://&lt;bucket&gt;/&lt;prefix&gt;). So it might look like this for you, “s3://metaflow-stack-metaflows3bucket-some_id/metaflow/artifacts”. Do the same for datatools (replace artifacts).</p><p>Once done, you should get a succes message saying “Configuration successfully written to “/Users/username/.metaflowconfig/config_metaflow.json” “</p><h3>Step 4: Testing the Setup</h3><p>First, let’s create a basic Metaflow script. This script defines a flow with two steps: start and end. You can save this script in a file named flow_playground.py.</p><pre>from metaflow import FlowSpec, step<br><br>class BasicFlow(FlowSpec):<br><br>    @step<br>    def start(self):<br>        print(&quot;This is the start step.&quot;)<br>        self.next(self.end)<br><br>    @step<br>    def end(self):<br>        print(&quot;This is the end step.&quot;)<br><br>if __name__ == &#39;__main__&#39;:<br>    BasicFlow()</pre><p>After installing the packages, run</p><pre>METAFLOW_PROFILE=metaflow python flow_playground.py run</pre><p>When you use METAFLOW_PROFILE=metaflow python flow_playground.py run, it tells Metaflow to use a specific set of configurations named metaflow that you&#39;ve previously set up for running your workflow. In other words, this profile (metaprofile) contains settings that Metaflow will use, such as AWS credentials, S3 bucket locations for storing artifacts, and other AWS-related configurations.</p><p>This setup could include details about where to store data, how to handle tasks, and which AWS resources to use. It&#39;s like telling Metaflow, &quot;Hey, use the settings I&#39;ve grouped under &#39;metaflow&#39; for this job.&quot; This way, Metaflow knows exactly how to handle your tasks according to the predefined settings.</p><p><strong>Resources</strong></p><p><a href="https://docs.metaflow.org/introduction/what-is-metaflow">What is Metaflow?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c824e5ff107" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to connect AWS RDS to PgAdmin4]]></title>
            <link>https://medium.com/@u04561890/how-to-connect-aws-rds-to-pgadmin4-172d4a60b468?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/172d4a60b468</guid>
            <category><![CDATA[ip]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[pgadmin]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 09:43:22 GMT</pubDate>
            <atom:updated>2022-12-13T09:43:22.726Z</atom:updated>
            <content:encoded><![CDATA[<p>Suppose you want to create an RDS instance on AWS, and connect to the database using PgAdmin4, you might run into some issues like I did. E,g session expired or timeout.</p><blockquote>What is RDS from AWS?</blockquote><p>Amazon Relational Database Service (RDS) is a fully managed database service offered by Amazon Web Services (AWS). RDS makes it easy to set up, operate, and scale a relational database in the cloud. It provides you with a high-performance database environment that is both reliable and scalable, so you can focus on building your applications without having to worry about the underlying infrastructure. With RDS, you can choose from a variety of popular database engines, including Amazon Aurora, MySQL, Microsoft SQL Server, Oracle, and PostgreSQL.</p><p>In this case, I choose <strong>PostgreSQL</strong> as my database engine.</p><p><em>How to set up AWS RDS so that it works with pgAdmin 4?</em> You need to make sure two check boxes are ticked. First that the RDS is publicly accessible, and secondly that the Inbound rules are edited so that your computer network can access to the database.</p><h4>1. ) Make sure RDS is publicly accessible</h4><p>In AWS, go to RDS -&gt; Database</p><p>Select your database and the click on <strong>Modify</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WnQFcgW9AMxZzV3GNgxUow.png" /></figure><p>Then scroll down to <strong>Connectivity</strong> and select <strong>Additional configuration. </strong>Make sure that it’s set equal to True, and then save the settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bHsMwqcBzxL5Sao7jHA8w.png" /></figure><h4>2. ) Edit Inbound Rules</h4><p>In AWS, go to RDS -&gt; Database -&gt; your_database. Scroll down a bit and click on VPC security groups</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hY_muamBMWeWJdMPN88-KA.png" /></figure><p>Once you click, scroll down and edit the inbound rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ic-NXSQJosYqJNOHh5uKyA.png" /></figure><p>Then you need to change Type to All traffic, and change <strong>Source</strong> to <strong>My IP</strong></p><p>This will give you IP address range in CIDR notation, which specifies a range of IP addresses that are allowed to access your RDS instance. Basically, only your IP address can access this database. Save this rule. Now your computer network can connect to the RDS instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6WLb_5B0KYrSsFMjGMi3BQ.png" /></figure><p>At first, or by default, the AWS allows inbound traffic from network interfaces and instances that are assigned to the same security group. Because pgAdmin 4 is not assigned to the same security group, we could not access it.</p><p>From here, you should be able to connect pgAdmin 4 with the appropriate Host address, username and Password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*TjRm_CYHfGOwGnwK3UZlPg.png" /></figure><p>All this information can be found at RDS -&gt; Database -&gt; your_database</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=172d4a60b468" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Being Good at Google is a Skill.]]></title>
            <link>https://medium.com/@u04561890/being-good-at-google-is-a-skill-3868485d41fd?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/3868485d41fd</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[resourcefulness]]></category>
            <category><![CDATA[stackoverflow]]></category>
            <category><![CDATA[memes]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Wed, 12 Aug 2020 17:23:05 GMT</pubDate>
            <atom:updated>2020-08-12T17:23:05.557Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*XxycmcUWe0g2nJQF1AKyww.jpeg" /></figure><p>Being good at ‘Google” is a skill. Yes you heard me. Knowing what and how to Google or search for something is an undervalued asset, especially in the fields of Data Science and developing. The problem is that nobody wants to admit that they’re good at “Googling”, because having to Google something in the first place is construed to knowing nothing about that which we are searching for. This couldn’t be further from the truth. Google is there to help the ones that know something, not the ones that don’t know anything.</p><p>There is a plethora of information and resources available on the internet with more and more being added every second. Anyone can contribute to the expansion of the internet, and this feature comes with its own pros and cons. The pro: to be connected, learn and share ideas. The con: you can’t trust everything on the internet. Knowing how to sort through the rubble is an important as finding the rubble.</p><p>Nowadays people learn to play the guitar and other various instruments on YouTube. Disregarding the costs of internet, these guitar lessons are essentially free and such is the case for many other available resources (think in terms of books, music and academic works). In the sense that we want to learn how to play the guitar, the “Googling” aspect is rather straightforward because we know the end goal: learn how to play the guitar. What happens if we don’t know what the goal is? Taking it even further, what if we know what the goal is, yet we don’t know how to find the correct information to help complete the goal?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*LNI3TWutq8kj69DAUQqO4g.png" /></figure><p>This is where being good at “Google” comes into play, or in the context of Data Science, being good at navigating Stack Overflow (a popular online community of developers). If you believe that coding is exactly as you see it in the movies, I am sorry to say that you will be largely disappointed. Most of the time, programmers spend hours or even days figuring out what to code in order to get the result that they want. They usually have the idea in mind, but translating that idea into a computer algorithm is a different story. They have all the ingredients without the recipe.</p><h4>When to Google?</h4><p>At one point or another, a developer will be required to complete a task in a programming language that he or she has never experienced before. For example, asking a Data Scientist to create a webpage (Python to Java). Every programming language comes with its own syntax and the developer will have to master the syntax if they want to be successful in the language. To Google the workings of a new syntax, you must already know what it is that you want to do. For example, the syntax for installing packages in R Studio and Python is completely different, but the difficulty gap closes if you are able to transfer your programming understanding between languages. In such a simple scenario, you’d Google something along the lines of: How to import packages in R/Python?</p><p>Sometimes you will have to Google something because you genuinely don’t know what else to do. This process may come at different times in a project. It could come at the beginning when you just need an idea to start. It could come somewhere in the middle, where you need help to tune a certain parameter, or it could come in the end when it’s time to interpret the results of the model. In general, Googling is turned to when we have a problem that we can’t solve, in the hope that somebody else has had the same problem, but has solved it for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*F302syfZWt_CAl57kCP8HQ.png" /></figure><h4>Isn’t it just copy and paste?</h4><p>No data scientist or programmer worth their salt would survive by continuously copy pasting code from Stack Overflow. Reiterating, Google is there to help developers that know something and not the one’s that don’t. Most likely you’ll only get answers to a piece of the puzzle and not the entire solution. Once you “copy and paste”, it’s still up to you to make sure that the added code is understandable, reproducible, robust and more. For example, a lot of aspiring Data Scientists are applying XGBoost to all data under the Sun (guys, sometimes linear regression is good enough). It might be beneficial in some cases, but the problem is that they have no understanding of the parameters and how to fine tune them in order to get the best results with the data that they have. As you can see, we should Google the stuff we Googled.</p><p>I am seriously considering putting “Good at Googling stuff” on my CV. Until then, the term “resourceful” will do just fine in its place. Finally, giving credit for people’s work is more important than the purpose for which you are copying. If you are unable to give credit where it is due, please reconsider using their information, especially when they are providing such an upright service for the developers community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3868485d41fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Think and Grow Rich | Summary & Notes]]></title>
            <link>https://medium.com/@u04561890/think-and-grow-rich-summary-notes-c8dab07d811a?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8dab07d811a</guid>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[notes]]></category>
            <category><![CDATA[think-and-grow-rich]]></category>
            <category><![CDATA[self-help]]></category>
            <category><![CDATA[summary]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Wed, 08 Jul 2020 17:18:03 GMT</pubDate>
            <atom:updated>2020-07-08T17:18:03.788Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Chapter 1: Introduction</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1LNEOMW0zcKi5adYilwK3A.jpeg" /><figcaption>Edwin C. Barnes and Edison</figcaption></figure><p>Edwin C. Barnes was determined to work <em>with</em> Edison, not <em>for </em>Edison. This desire to work with the inventor was definite. In Edwin’s mind it was going to happen, no matter what. Before he could fulfill his goal, two problems stood in his way. The first being that he didn’t know Edison, and the second is that he lacked funds to pay for a railroad fare to Orange, New Jersey. Edwin didn’t let the money problem stop him. He traveled by freight train instead of the regular passenger train. All he had to now was to meet Edison. He showed up at the offices of the inventor and announced that he wanted to go into business. Most people would quit if they were faced the same problems as Edwin. We all suffer similar problems in one way or another, especially relating to finance, or lack thereof. However, Edwin overcame these problems with sheer will and determination, something that we are all capable of. We can all catch a cheap train and meet someone that we <em>desire</em> to meet.</p><p>The interesting part is the impression that he imparted on Edison. Edison gave him an opportunity because Edison could see that he had made up his mind to stand by until he succeeded. If we give it our all, someone ought to see it and give you a chance. It is not something that can be staged, it is a burning flame that is clearly visible. Edison could truly see that Edwin had come after what he truly wanted. We should do the same in our lives and not go searching half-hardheartedly. Edwin wasn’t promoted immediately but got an opportunity to be near Edison, which was enough to keep the desire going: “Working with Edison”.</p><blockquote>“When one is truly ready for a thing, it puts in its appearance”</blockquote><p>If you really desire and long for a result, your appearance and actions will mold accordingly. I bet it was incredibly visible that Edwin wanted to work with Edison and everybody knew, just based on the way he behaved around the office. Secondly, when you’re ready for a thing, you won’t mind waiting until you get it, because in your mind you know that you will… it’s only a matter of time. In essence, we should strive to adopt a definite purpose and stand by that purpose until it becomes an all consuming obsession.</p><blockquote>“Opportunity has a sly habit of slipping by in the back door, and often it comes disguised in the form of misfortune or temporary defeat”</blockquote><p>An opportunity might not always come in the form that you expect it to come in. Some people think that opportunists are like hand outs and we will know exactly when to act upon them, almost as if they are bestowed upon us by some generous God of the Riches. This is almost never the case. Most opportunities are disguised in defeat, which is why most people look the other way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iJ1MgjfAdYmGR7-GjRORJg.jpeg" /><figcaption>Train in the 1930&#39;s</figcaption></figure><p>The moral of the Edwin and Edison story is that an intangible impulse of thought can be transmuted into its physical counterpart. Edwin has nothing to start with except the capacity to know what he wanted , and the determination to stand by that desire until he realized it.</p><h4>Three feet from Gold</h4><blockquote>One of the most common causes of failure is the habit of quitting when one is overtaken by temporary defeat.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*5r0d2vXabh5Ir5Ti2dmKSQ.jpeg" /><figcaption>3 feet from the goal</figcaption></figure><p>We all make this mistake at one time or another. I’ve made this mistake personally many times, and most recently about a month ago. I was determined to make an online course about artificial intelligence. I gave up after the first obstacle that was in front of me. There’s a tale about an uncle of R. U. Darby who was caught by the gold rush and wanted to make a fortune. He initially struck some shinning ore and was encouraged to go further, so he invested time and money into expensive mining equipment. The hopes were up, until something happened. There was no more ore! The team was devastated and decided to quit. They sold their equipment to a “junk man” for thousands less than their purchase price. This “junk man” called a mining engineer and was then suggested to keep on digging.</p><blockquote>“The “junk” man took millions of dollars in ore from the mine because he knew enough to seek expert counsel before giving up”</blockquote><p>Long afterwards Darby profited by the experience in his chosen work of selling life insurance policies. He says “I stopped three feet from gold, but I will never stop because men say ‘no’ when i ask them to buy insurance”.</p><blockquote>The greatest successes come just one step beyond the point at which defeat overtakes you.</blockquote><p>One of the main weaknesses of mankind is the average man’s familiarity with the word “Impossible.” He knows all the rules which will not work. He knows all the things that cannot be done. We need to disobey these rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ZCmm54sEp2p43ua2RhOMrA.jpeg" /></figure><p>We are the masters of our fate, and the captains of our soul, because we the power to control our thoughts and emotions. Our brains become magnetized with the dominating thoughts which we hold in our minds. We must magnetize our mind with an intense desire for riches until the desire for money drives us to create definite plans for acquiring it.</p><h3>Chapter 2: Desire</h3><blockquote>Desire (<em>noun</em>): a strong feeling of wanting to have something or wishing for something to happen.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*yLaKOBq6nEdJfokOmi7ohA.jpeg" /></figure><p>If you succeed, people will only view you in your days of triumph, without taking the the trouble to investigate the cause of your success. After each degree I complete, people will see my name on a certification but forget about the countless steepness nights in the library. Since you would like others to acknowledge your sacrifices, don’t be too egocentric to return the favor.</p><p>If you truly want to succeed, you need to choose a definite goal (the word definite is important here) and then place all your energy, willpower and effort into achieving your goal. The power of a definite desire is remarkable. Think back to the story of Edwin. One of the reasons why he succeeded in his goal is because he burnt all the bridges behind himself. He left himself no possible way of retreat..either he would win or perish! When you have a scapegoat or a fall back, it becomes very easy to give up when faced with a challenge. Having only two choices: win or perish, can be a determining factor on the road to riches and success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pK9GeuFEN9aGgcqCvsft6A.jpeg" /></figure><p>We all understand the purpose of money and most of us <em>wish</em> for it. Wishing will not bring riches. Desiring riches with a state of mind that becomes and obsession, then planning definite ways and means to acquire riches, backed by plans with persistence which <em>does not recognize failure</em>, will bring riches.</p><p><strong>Six steps to transmute desire to riches</strong></p><ol><li>Fix in your mind the <em>exact</em> amount of money you desire. Example, I want to make 20 million rand.</li><li>Determine exactly what you intend to give in return for the money you desire. What sacrifices are you willing to make?</li><li>Establish a definite date when you intend to <em>possess</em> the money you desire</li><li>Create a definite plan for carrying out your desire, and begin <em>immediately</em>, whether you are ready or not, to put this plan into action.</li><li>Write it out clearly!</li><li>Read your written statement aloud, twice daily, once before bedtime and once after arising in the morning.</li></ol><p>Only those who become “<strong>money consciousness</strong>” ever accumulate riches. “Money consciousness” means that the mind has become thoroughly saturated with the desire for money, that one can see one’s self already in possession of it. These steps are necessary for the attainment of <em>any definite goal.</em></p><p>After COVID-19, economies will collapse and all men will be reduced to the same level. A new race is about the be run. The stakes represent huge fortunes which will be accumulated within the next 10 years. The rules of the race have changed, because we now live in a changed world that definitely favors the masses. This pandemic has marked the death of one age and the birth of another. To win the big stakes in this changed world, you must catch the spirit of the great pioneers of the past.</p><blockquote>“Success requires no apologies, failure permits no alibis.”</blockquote><p>The new world has shown a willingness to reward the dreamer who gives the world a new idea.</p><blockquote>“No one ever is defeated until defeat has been accepted as a reality.</blockquote><h3>Chapter 3: Faith</h3><p>Visualization of, and belief in, attainment of desire</p><p>Faith is a state of mind which may be induced, or created, by affirmation or repeated instructions to the subconscious mind, although through the principle of autosuggestion.</p><blockquote>Repetition of affirmation of orders to your subconscious mind is the only known method of voluntary development of the emotion of faith.</blockquote><p>This is equivalent to saying that any impulse of thought which is repeatedly passed on the subconscious mind, is finally accepted and acted upon by the subconscious mind, which proceeds to translate that impulse into physical equivalent by the most practical procedure available. To make this “deceit” more realistic, conduct yourself as you would if you were already in possession of the material thing in which you are demanding, when you call upon your subconscious mind. Encourage the positive emotions as dominating forces of your mind, and discourage and eliminate negative emotions.</p><p>Faith is the starting point of all accumulation of riches and is the only anecdote for failure. It is well-known that one comes, finally, to believe whatever one repeats to one’s self, <em>whether the statement be true or false.</em></p><p><strong>SELF-CONFIDENCE FORMULA</strong></p><ol><li>I know that i have the ability to achieve the object of my definite purpose in life. Therefore i demand of myself persistent, continuous action toward its attainment, and I here and now promise to render such action</li><li>I realize the dominant thoughts of mu mind will eventually reproduce themselves outward and into physical action. Therefore, I will concentrate my thoughts for thirty minutes daily upon the task of thinking of the person i intend to become, thereby creating in my mind a clear mental picture of that person.</li><li>I know through the principle of autosuggestion, any desire that i persistently hold in my mind will eventually seek expression through some practical means of attaining the object back of it. Therefore, i will devote ten minutes daily to demanding of myself the development of self-confidence.</li><li>I have clearly written down a description of my definite chief aim in life, and i will never stop trying until I shall have developed sufficient self-confidence for its attainment.</li><li>I fully realize that no wealth or position can long endure, unless built upon truth and justice. I will cause others to believe in me, because i will believe in them, and in myself.</li></ol><p>Like the wind which carries one ship east, and another west, the law of autosuggestion will lift you up or pull you down, according to the way you set your sails of thought.</p><h3><strong>Chapter 4: Autosuggestion</strong></h3><p>The medium for influencing the subconscious mind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*uaGdmaQ1Li_wDxHwHqbqlw.jpeg" /><figcaption>autosuggestion</figcaption></figure><p>Autosuggestion is a term which applies to all suggestions and self-administered stimuli which reach one’s mind through the five senses. Remember that the mere reading of the words is of mo consequence — unless you mix emotion, or feeling ,with your words. Your subconsciousness mind recognizes and acts upon only thoughts which have been well-mixed with thought or feeling.</p><p>Ability to reach and influence your subconscious mind has its price, and you must pay that price. You cannot cheat, even if you desire to do so. You must decide whether or not the reward for which you are striving is worth the price you must pay for in it effort.</p><blockquote>There are no limitations to the mind except those we acknowledge. Both successes and failures are the offspring of thought.</blockquote><p>Do not wait for a definite plan, through which you intend to exchange services or merchandise in return for the money you are visualizing, but begin at once to see yourself in possession of the money, demanding and expecting meanwhile that your subconscious mind will hand over the plans or the plans you need. Be on the alert for these plans and when they appear, put them into action immediately. When the plans appear, they will probably “flash” into your mind through the sixth sense, in the form of an “inspiration.” Treat it with respect, and act upon it as soon as you receive it. Failure to do this will be fatal to your success.</p><p><strong><em>Summary of instructions</em></strong></p><ol><li>Go into some quiet spot where you will not be disturbed, close your eyes, and repeat aloud the amount of money you intend to accumulate, the time limit for its accumulation, and a description of the service or merchandise you intend to give in return for the money.</li><li>Repeat this program night and morning until you can see (in your imagination) the money you intend to calculate.</li><li>Place a written copy of your statement where you can see it night and morning, and read it before retiring and upon arising until it has been memorized.</li></ol><p>Man may become the master of himself, and of his environment, because he has the power to influence his own subconscious mind, and through it, gain the cooperation of the sixth sense.</p><h3>Chapter 5: Specialized Knowledge</h3><p>Personal experiences or observations.</p><p>Most of professors have little but no money. They specialize on teaching knowledge, but they do not specialize on the organization or the use of the knowledge. Knowledge is only <em>potential</em> power. it becomes power only when, and if, it is organized into definite plans of action, and directed to a definite end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V6ohcFLAgg7fN-LzrUy7Lw.jpeg" /></figure><p>An educated man is not, necessarily one who has an abundance of general or specialized knowledge. An educated man is one who has developed the faculties of his mind that hey may acquire anything he wants, or its equivalent, without violating the rights of others.Any man is educated who knows where to get knowledge when he needs it, and how to organize that knowledge into definite plans of action.</p><p>The accumulation of great fortunes calls for power, and power is acquired through highly organized and intelligently directed specialized knowledge, but that knowledge does not necessarily have to be in the possession of the man who accumulates them.</p><blockquote>First of all, decide the sort of specialized knowledge you require, and the purpose for which it is needed.</blockquote><ol><li>One’s own experience and education</li><li>Experience and education available through the cooperation of others.</li><li>College and universities</li><li>Public libraries and online resources</li><li>Online courses and training courses</li></ol><p>If you contemplate taking additional schooling, first determine the purpose for which you want the knowledge you are seeking, them learn where this particular sort of knowledge can be obtained from reliable sources.</p><p>Successful men, in all callings, never stop acquiring specialized knowledge related to their major purpose, business, or profession. Those who are not successful usually make the mistake of believing that the knowledge-acquiring period ends when one finishes school. The truth is that schooling does little but more than put one in the way of learning how to acquire practical knowledge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*vy5UhQ76iErxn3oWCUrW7w.gif" /></figure><p>Anything acquired without effort and without cost is generally unappreciated and often discredited. The self-discipline one receives from a definite program of specialized study makes up to some extent for the wasted opportunity when knowledge was available without cost. One of the strange things about humans is that they value only that which has a price.</p><p>Any person who has the ambition to give up a part of his spare time to studying at home has in him those qualities which make for leadership. The person who stops studying merely because he has finished school is forever doomed to mediocrity, no matter what may be his calling.</p><blockquote>The way of success is the continuous pursuit of knowledge.</blockquote><p>The idea of starting at the bottom and working one’s way up may appear to be sound, but the major objection to it is those — too many of those who begin at the bottom never manage to lift their heads high enough to be seen by the opportunity, so they remain at the bottom. It should be remembered, also, that the outlook from he bottom is not so very bright or encouraging. It has a tendency to kill off ambition. We call it “getting into a rut”, which means that we accept our fate because we form the habit of daily routine, a habit that finally becomes so we strong we cease to try throw it off. We rise to high positions or remain at the bottom because of conditions we can if we desire to control them.</p><blockquote>Both successes and failure are largely the results of habit</blockquote><p>Remember, the idea is the main thing. Specialized knowledge may be found just around the corner-any corner!</p><h3>Chapter 6: Imagination</h3><p>The workshop of the mind</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJQv1BLxDmsiQfvBL8XjzQ.jpeg" /></figure><p>It has been said that man can create anything which he can imagine. Man’s only limitation, within reason, lies in his development and use of his imagination. He has not yet reached apex of development in the use of his imaginative faculty. He has merely discovered that he has an imagination and has commenced to use it in a very elementary way.</p><p>While the synthetic imagination is the one which will be used most frequently in the process of transforming the impulse of of desire into money, you must keep in the mind the fact you may face circumstances and situations which demand use of the creative imagination as well.</p><p>Transformation of the intangible impulse of desire, into the tangible reality of money, calls for the use of a plan, or plans. These plans must be formed with the aid of imagination, and mainly, with the synthetic reality.</p><blockquote>Ideas are the beginning points of all fortunes. Ideas are the products of the imagination.</blockquote><p>If you are one of those who believe that hard work and honesty alone will bring riches, perish the thought! It is not true! Riches, when they come in huge quantities, are never the result of hard work! Riches come, if they come at all, in response to definite demands, based upon the application of definite principles, and not by chance or luck.</p><blockquote>There is no standard price on ideas. The creator of ideas makes his own price.</blockquote><p>Millions of people go through life hoping for favorable “breaks.” Perhaps a favorable break can get one an opportunity, but the safest plan is not to depend on luck.</p><p>First you give life and action and guidance to ideas, then they take on power of their own and sweep aside all opposition. Ideas are intangible forces, but they have more power to than the physical brains that give birth to them.</p><blockquote>Ideas have the power to live on, after the brain that creates them has returned to dust.</blockquote><p>Success requires no explanations. Failure permits no alibis.</p><h3>Chapter 7: Organized Planning</h3><p>The crystallization of desire into action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*8daostOEnpsdtbLHX0VQLQ.jpeg" /></figure><p>You have learned that everything man creates or acquires begins in the form of desire, that desire is taken on the first lap of its journey, from the abstract to the concrete, into the workshop of the imagination, where plans for its transition are created and organized.</p><p><strong>How to build plans which will be practical</strong></p><ol><li>Ally yourself with a group of as many people as you may need for the creation and carrying out of your plan, or plans, for the accumulation of money.</li><li>Decide what advantages and benefits you may offer the individual members of your group in return for their cooperation.</li><li>Arrange to meet with the members of your Master Mind group at least twice a week.</li><li>Maintain perfect harmony between yourself and every member of your Master Mind group.</li></ol><p>To be sure of success, you must have plans which are faultless.</p><p>No individual has sufficient experience, education, native ability, and knowledge to insure the accumulation of a great fortune without the cooperation of other people.</p><p>If the first plan doesn&#39;t work,replace it with a new plan. Keep doing so until it you are successful. Right here is the point at which the majority of men meet with failure, because of their lack of persistence in creating new pans to take the place of those which failed.</p><blockquote>Temporary defeat is not permanent failure.</blockquote><p>Your achievement can be no greater than your plans are sound and no man is ever whipped, until he quits —<em> in his own mind</em></p><p>When defeat comes, accept it as a signal that your plans ar not sound, rebuild those plans and set sail once more toward your coveted goal. If you give up before your goal has been reached, you are a “quitter”.</p><blockquote>A quitter never wins-and-a winner never quits</blockquote><p>Money, of itself, is nothing but inert matter. It cannot move, think or talk, but it can “hear” when a man who desires it, calls it to come!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*eFnlzb6ZEWsehg1i3RTA6g.png" /></figure><p>Broadly speaking, there are two type of people in this world. One type is known as leaders, and the other as followers. Decide at the outset whether you intend to become a leader in your chosen calling, or remain a follower. The difference ins compensation is vast. The follower cannot reasonably expect the compensation to which a leader is entitled, although many followers make the mistake of expecting such pay.</p><p>It is no disgrace to be a follower. On the hand, it is no credit to remain a follower. Most great leaders began in the capacity of followers. They become great leaders because they were intelligent followers.</p><p><strong>The most important factors of leadership.</strong></p><ol><li>Unwavering courage based upon knowledge of self, and of one’s occupation.</li><li>Self-control</li><li>A keen sense of judgement</li><li>Definiteness of decision</li><li>Definiteness of plans</li><li>The habit of doing more than paid for</li><li>A pleasing personality</li><li>Sympathy and understanding</li><li>Mastery of detail</li><li>Willing to assume full responsibility</li><li>Cooperation</li></ol><p>The relationship of employer and employee, or of leader and follower, in the future will be one of mutual cooperation, based upon an equitable division of the profits of business. In the future, the relationship of employer and employee will be more like a partnership than it has been in the past.</p><p><strong>What leaders should NOT do</strong></p><ol><li>Inability to organize details</li><li>Unwillingness to render humble services</li><li>Expectation of pay for what they “know” instead of what they do with that which they know.</li><li>Lack of imagination</li><li>Selfishness</li><li>Intemperance</li><li>Disloyalty</li><li>Emphasis of the “authority” of leadership</li><li>Emphasis of title</li></ol><blockquote>The world does not pay men for that which the “know”. It pays them for what they DO, or induce others to do.</blockquote><p><strong>Media through which services may be marketed</strong></p><ol><li>Employment bureaus</li><li>Advertising in newspapers, trade journals, magazine and radios</li><li>Personal letters of application, directed to particular firms or individuals most apt to need such services as are being offered.</li><li>Application through personal acquaintances</li><li>Application in person</li></ol><p><strong>Information to be supplied in a written “Brief”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*jmk16BjaKliGjAxGMrb9OA.jpeg" /></figure><ol><li>Education</li><li>Experience</li><li>References</li><li>Photograph of self</li><li>Apply for a position</li><li>State your qualifications</li><li>Offer to go to work on probation (work for free)</li><li>Knowledge of your prospective employer’s business</li></ol><p>Remember that it is not the lawyer who knows the most law, but the one who prepares his case, who wins. If your “case” is properly prepared and presented, your victory will have been more than half won at the outset.</p><blockquote>Successful salesmen groom themselves with care. They understand that first impressions are lasting.</blockquote><p>If the position you seek is worth having, it is worth going after with care. Moreover, if you sell yourself to an employer in a manner that impresses him with your individuality, you probably will receive more money from your services from the very start than you would if you applied for employment in the usual conventional way.</p><h4>HOW TO GET THE EXACT POSITION YOU DESIRE</h4><ol><li>Decide exactly what kind of job you want. If the job doesn’t already exist, perhaps you can create it</li><li>Choose the company or individual for whom you wish to work.</li><li>Study your prospective employer, as to policies, personnel, and by chances of advancement</li><li>Figure out what you can offer and give ideas that you believe you can successfully deliver</li><li>Forget about “a job.” Concentrate on what you can give.</li><li>Put it on paper in neat form and in full detail</li><li>Present it to the proper person with authority and he will do the rest.</li></ol><blockquote>Every company has room for the man who has a definite plan of action which is to the advantage of that company.</blockquote><p>The day of the “go-getter” has passed. He has been supplanted by the “go-giver.”</p><p>The actual capital value of your brains may be determined by the amount of income you can produce. Money is no more worth than brains. It is often worth much less. Competent “brains”, if effectively marketed, represent a much more desirable form of capital than that which is required to conduct a business dealing in commodities, because “brains” are a form of capital which cannot be permanently depreciated through depressions, nor can this form of capital be stolen or spent. Moreover, the money which is essential for the conduct of business is as worthless as a sand dune, until it has been mixed with efficient “brains”.</p><h4>THIRTY REASONS FOR FAILURE</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*vo0fnAzPKffU-xBrv4odvA.png" /></figure><ol><li>Unfavorable hereditary background</li><li>Lack of well-defined purpose in life</li><li>Lack of ambition to aim above mediocrity</li><li>Insufficient education</li><li>Lack of self-discipline</li><li>Ill health</li><li>Unfavorable environmental influences during childhood</li><li>Procrastination</li><li>Lack of persistence</li><li>Negative Personality</li><li>Lack of controlled sexual urge</li><li>Uncontrolled desire of “something for nothing:</li><li>Lack of well-defined power of decision</li><li>One or more of the six basic fears</li><li>Wrong selection of a mate in marriage</li><li>Over-caution</li><li>Wrong selection of associate in business</li><li>Superstition and prejudice</li><li>Wrong selection of vocation</li><li>Lack of concentration of effort.</li><li>The habit of indiscriminate spending</li><li>Lack of enthusiasm</li><li>Intolerance</li><li>Intemperance</li><li>Inability to cooperate with others</li><li>Possession of power that was not acquired through self-effort</li><li>Intentional dishonesty</li><li>Egotism and vanity</li><li>Guessing instead of thinking</li><li>Lack of capital</li></ol><p>It will be helpful if you can induce someone who knows you well to go over the list with you, and help to analyze you by the thirty causes of failure. It may be beneficial if you try this alone. Most people cannot see themselves as others see them.</p><p>You should know all of your weaknesses in order that you may either bridge them or eliminate them entirely. You can know yourself only through accurate analysis.</p><p>It is one one thing to want money-everyone wants more-but it is something entirely different to be worth more. Your value is established entirely by your ability to render useful service. Annual self-analysis will disclose whether advancement has been made, and if so, how much. It will also disclose any backward steps one may have made.</p><h4>Self-analysis questionnaire for personal inventory</h4><ol><li>Have I attained the goal which I established as my object for this year?</li><li>Have I delivered service of the best possible quality of which I was capable, or could I have improved any part of this service?</li><li>Have I delivered service in the greatest possible quantity of which I was capable?</li><li>Has the spirit of my conduct been harmonious and cooperative at all times?</li><li>Have I permitted the habit of procrastination to decrease my efficieny, and if so, to what extent?</li><li>Have I improved my personality, and if so, in what ways?</li><li>Have I been persistent in following my plans through to completion?</li><li>Have I reached my decision promptly and definitely on all occasions?</li><li>Have I permitted any one or more of the six basics fears to decrease my efficiency?</li><li>Have I been either “overcautious” or “under-cautious”?</li><li>Has my relationships with my associates in work been pleasant or unpleasant? If it has been unpleasant, has the fault been my partly or wholly mine?</li><li>Have I dissipated any of my energy through lack of concentration of efforts?</li><li>Have I been open-minded and tolerant in connection with all subjects?</li><li>In what way have I improved my ability to render service?</li><li>Have I been intemperate in any of my habits?</li><li>Have I expressed, either openly or secretly, any form of egotism?</li><li>Has my conduct toward my associates been such that it has induced them to respect me?</li><li>Have my opinions and decisions been based upon guesswork, or accuracy or analysis and thought?</li><li>Have I followed the habit of budgeting my time, my expenses, and my income, and have I been conservative in these budgets?</li><li>How much time have I devoted to unprofitable effort which I might have used to be advantage?</li><li>How many I re-budget my time, and change my habits so I will be more efficient during the coming year?</li><li>Have I been guilty of any conduct which was not approved by my conscience?</li><li>Have I been unfair to anyone, and if so, in what way?</li><li>In what ways have I rendered more service and better service than I was paid to render?</li><li>If I had been the purchaser of my own services for the year, would I be satisfied with my purchase?</li><li>Am I in the right vocation, and if not, why not?</li><li>Has the purchaser of my services been satisfied with the services I have rendered, and if not, why not?</li><li>What is my present rating on the fundamental principles of success?</li></ol><p>Opportunity has spread its wares before you. Step up to the front, select what you want, create your plan, put the plan into action and follow through with persistence.</p><h3>Chapter 8: Decision</h3><p>The mastery of procrastination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Hvy-Kel5cOVLhEY1lMFF4g.jpeg" /></figure><p>The lack of decision is near the head of the list of the thirty major causes of failure. This is no more mere statement of a theory-<em>it is a fact. </em>Procrastination, the opposite of decision, is a common enemy which practically every man must conquer.</p><p>People who fail to accumulate money, without exception, have the habit of reaching decisions, if at all, very slowly and of changing these decisions quickly and often.</p><p>The majority of people who fail to accumulate money sufficient for their needs, are, generally, easily influenced by the ‘“opinions” of others. They permit the newspapers and the “gossiping” neighbors to do their “thinking” for them. “Opinions” are the cheapest commodities on earth. Everyone has a flock of opinions ready to be wished upon anyone who will accept them. If you are influenced by “opinions” when you reach decisions, you will not succeed in any undertaking, much less in that of transmuting your own desire into money.</p><blockquote>“If you are influenced by the opinions of others, you will have no desire of your own.”</blockquote><p>You have a brain and mind of your own. Use it, and reach your own decisions. If you need facts or information from other people to enable you to reach decisions, as you probably will in many instances, acquire these facts or secure the information you need quickly, without disclosing your purpose.</p><p>Keep your eyes and ears wide open-and your mouth closed-if you wish you to acquire the habit of prompt decision. Those who talk too much do little else. If you talk more than you listen, you not only deprive yourself of many opportunities to accumulate useful knowledge, but you also disclose your plans and purposes to people who will take great delight in defeating you because they envy you.</p><blockquote>“Tell the world what you intend to do, but show them first.”</blockquote><p>Those who reach decisions promptly and definitely, know what they want, and generally get it. The leaders in every walk of life decide quickly and firmly. That is the major reason why they are leaders. The world has a habit of making room for the man whose words and actions show the he knows where he is going.</p><p>People working for the wages today are in the position they hold because they lacked the definiteness of decision to plan a definite position, and the knowledge of how to choose an employer. Definiteness of decision always requires courage, sometimes very great courage.</p><p>The person who reaches a definite decision to procure the particular job, and make life pay the price he asks, does not stake his life on that decision; he stakes his economic freedom. Financial independence, riches, desirable business and professional positions are not within reach of the person who neglects or refuses to expect, plan and demand these things.</p><h3>Chapter 9: Persistence</h3><p>The sustained effort necessary to induce faith</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6KcJgZL9BDr3pQ9WzVMng.jpeg" /></figure><p>Persistence is an essential factor in the procedure of transmuting desire into its monetary equivalent. The basis of persistence is the power of will. Willpower and desire, when properly combined, make an irresistible pair. Men who accumulate great fortunes are generally know as cold-blooded and sometimes ruthless. Often they are misunderstood. What they have is willpower, which they mix with persistence, and place back of their desire to insure the attainment of their objectives.</p><p>Your first test of persistence will come when you begin to follow the six steps described in the second chapter.</p><blockquote>Lack of persistence is one the major causes of failure</blockquote><p>It is a weakness that may be overcome by effort. The ease with which lack of persistence may be conquered depend entirely upon the intensity of one’s desire. The starting point of all achievements is desire. Keep this constantly in mind. Weak desires bring weak results, just as small amount of fire makes a small amount of heat. If you find yourself lacking persistence, this weakness may be remedied by building a stronger fire under your desire.</p><p>Fortunes gravitate to men whose minds have been prepared to “attract” them, just as surely as water gravitates to the ocean. Your subconscious mind works continuously, while you are awake and while you are asleep.</p><blockquote>Without persistence, you will be defeated even before you start. With persistence you will win.</blockquote><p>Those who have cultivated the habit of persistence seem to enjoy insurance against failure. No matter how many times they are defeated, they finally arrive upward toward the top of the ladder. They receive as their compensation whatever goal they are pursuing…but that is not all! They receive something infinitely more important than material compensation-the knowledge that “every failure brings with it the seed of an equivalent advantage.”</p><p>One thing we all know: if one does not possess persistence, one does not achieve noteworthy success in any calling. Persistence is a state of mind, therefore it can be cultivated. Like all states of mind, persistence is based upn definite causes, among them these:</p><ol><li>Definite of purpose</li><li>Desire</li><li>Self-reliance</li><li>Definiteness of plans</li><li>Accurate knowledge (“guessing instead of knowing”)</li><li>Cooperation</li><li>Willpower</li><li>Habit (Persistence is a direct result of habit)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-peRBcX0iQP9Hx0BNRffA.jpeg" /></figure><h4>Symptoms of lack of persistence</h4><ol><li>Failure to recognize and to clearly define exactly what one wants</li><li>Procrastination, with or without cause</li><li>Lack of interest in acquiring specialized knowledge</li><li>Indecision, the habit of ‘passing the buck’ on all occasions, instead of facing issues squarely</li><li>The habit of relying upon alibis instead of creating definite plans for the solution of problems</li><li>Self-satisfaction. There is but little remedy for this affliction, and no hope for those who suffer from it.</li><li>Indifference, usually reflected in one’s readiness to compromise on all occasions rather than meet opposition and fight it</li><li>The habit of blaming others for one’s mistakes, and accepting unfavorable circumstances as being unavoidable.</li><li>Weakness of desire, due to neglect in the choice of motives that impel action.</li><li>Willingness, even eagerness, to quit at the first sign of defeat.</li><li>Lack of organized plans, placed in writing where they may be analyzed.</li><li>The habit of neglecting the move on ideas, or to grasp opportunity when it presents itself.</li><li>Wishing instead of willing</li><li>The habit of compromising with poverty instead of aiming at riches. General absence of ambition to be, to do, and to own</li><li>Searching for all shortcuts to riches, trying to get without giving a fair equivalent, usually reflected in the habit of gambling or endeavoring to drive “sharp” bargains</li><li>Fear of criticism, failure to create plans and to put them into action because of what other people will think, do, or say. This enemy belongs at the head of the list because it generally exists in one’s subconscious mind, where its presence is not recognized.</li></ol><p>The majority of people permit relatives, friends, and the public at large to influence them that they cannot live their own lives, because they fear criticism. People refuse to take chances in business, because they fear the criticism which may follow if they fail.</p><blockquote>The fear of criticism in such cases is stronger than the desire for success.</blockquote><p>The fear of criticism is at the bottom of the destruction of most ideas which never reach the planning and action stage.</p><p>The only “break” anyone can afford is to rely upon is a self-made “break.” These come through the application of persistence. The starting point is definiteness of purpose.</p><p>Examine the first hundred people you meet, ask them what they want most in life, and ninety-eight of them will not be able to tell you. If you press them for an answer, some will say security, many will say money, a few will say happiness, others will say fame and power, and still others will say social recognition, ease in living, ability to sing, dance or write. But none of them will be able to define these in terms, or give the slightest indication of a plan by which they hope to attain these vaguely expressed wishes.</p><blockquote>Riches do not respond to wishes. They respond to only definite plans, backed by definite desires, through constant pressure.</blockquote><h4>How to develop persistence</h4><ol><li>A definite purpose backed by burning desire for its fulfillment</li><li>A definite plan, expressed in continuous action</li><li>A mind closed tightly against all negative ad discouraging influences, including negative suggestions of relatives, friends and acquaintances</li><li>A friendly alliance with one or more persons who will encourage one to follow through with both plan and purpose</li></ol><p>It is the privileged of writing one’s own ticket, and of making life yield whatever price is asked.</p><h3>Chapter 10: Power of the Master Mind</h3><p>The driving force</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*XIG6I6LgctNWi3t7N0ulPQ.png" /></figure><p>Power is essential for success in the accumulation of money. Plans are inert and useless without sufficient power to translate them into action.</p><p>Power may be defined as “<em>organized and intelligently directed knowledge.</em>”</p><p>Power is required for the accumulation of money! Power is necessary for the retention of money after it has been accumulated. If power is “organized knowledge”, let’s examine the sources of money.</p><ol><li>Infinite intelligence</li><li>Accumulated experience</li><li>Experiment and research</li></ol><p>Knowledge may be acquired from any of the foregoing sources. It may be converted into power by organizing it into definite plans and by expressing those plans in terms of actions.</p><p>If one’s plans are comprehensive and if they contemplate large proportions, one must, generally, induce others to cooperate with him before he can inject into them the necessary element of power.</p><p>The Master Mind may be defined as “<em>coordination of knowledge, and effort, in a spirit of harmony, between two or more people, for the attainment of a definite purpose.</em>”</p><p>The Master Mind principle has two characteristics, one which is economic in nature, and the other psychic.</p><blockquote>“No two mind ever come together without, thereby, creating a third, invisible, intangible force which may be likened to a third mind.”</blockquote><p>When a group of individual brains are coordinated and function in harmony, the increased energy created through that alliance becomes available to every individual brain in the group.</p><blockquote>“Men take on the nature and the habits and the power of thought of those whom they associate in a spirit of sympathy and harmony.”</blockquote><p>Money is as shy and elusive as the “old-time” maiden. It must be wooed and won by methods not unlike those used by a determined lover in pursuit of the girl of his choice. And, coincidental as it is, the power used in the “wooing” of money is not greatly different from that used in the wooing a maiden. That power, when successfully used in the pursuit of money, must be mixed with faith. It must be mixed with desire. It must be mixed with persistence. It must be applied through a plan, and that plan must be set into action.</p><p>Poverty and riches often change places. Poverty may, and generally does, voluntarily take the place of riches. When riches take the place of poverty, the change is usually brought about through well-conceived and carefully executed PLANS. Poverty needs no plan. It needs no one to aid it, because it is bold and ruthless. Riches are shy and timid. They have to be “attracted.”</p><blockquote>Anybody can wish for riches, and most people do, but only a few know that a definite plan, plus a burning desire for wealth, are the only dependable means of accumulating wealth.</blockquote><h3>Chapter 11: The Mystery of Sex Transmutation</h3><p>The meaning of the word “transmute” is, in simple language, “the changing or transferring of one element or form of energy into another.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*G2sxE2bTleyv78tYVT8CSQ.jpeg" /></figure><p>Sex transmutation is simple and easily explained. It means switching the mind from thoughts of physical expression to thoughts of some other nature. So strong and impelling is the desire for sexual contact that men freely run the risk of life and reputation to indulge in it. When harnessed and redirected along other lines, this motivating force maintains all of its attributes of keenness and imagination, courage etc., which may be used as powerful creative forces in literature, art, or in any other profession or calling, including, of course, the accumulation of riches.</p><p>The men who have accumulated great fortunes and achieved outstanding recognition in literature, art, industry, architecture, and the professions were motivated by the influence of a woman.</p><h4>The Ten Mind Stimuli</h4><p>The human mind responds to stimuli through which it may be “keyed up” to high rates of vibration, known as enthusiasm, creative imagination, intense desire, etc. The stimuli to which the mind responds most freely are:</p><ol><li>The desire for sex expression</li><li>Love</li><li>A burning desire for fame, power or financial gain</li><li>Music</li><li>Friendship between either those of the same sex or those of opposite sex</li><li>Master mind alliance based upon the harmony of two or more people who ally themselves for spiritual or temporal advancement</li><li>Mutual suffering, such as that experience by people who are persecuted</li><li>Autosuggestion</li><li>Fear</li><li>Narcotics and alcohol</li></ol><p>A genius is “a man who has discovered how to increase the vibrations of thought to the point where he can freely communicate with sources of knowledge not available through the ordinary rate of vibration of thought.”</p><h4>“Genius” is developed through the sixth sense</h4><p>This sixth sense is “creative imagination.” When ideas or concepts flash into one’s mind through what is popularly called a “hunch”, they come from one or more of the following sources:</p><ol><li>Infinite intelligence</li><li>One’s subconscious mind, wherein is stored every sense impression and thought impulse which ever reached the brain through any of the five senses</li><li>From the mind of some other person who has just released the thought, or picture of the idea or concept, through conscious thought, or</li><li>From the other person’s subconscious storehouse</li></ol><p>When the brain action has been stimulated through one or more of the ten mind stimulants, it has the effect of lifting the individual far above the horizon of ordinary thought, and permits him to envision distance, scope, and quality of thoughts not available on the lower plane, such as that occupied while one is engaged in the solution of the problems of business and professional routine.</p><p>The scientific inventor, or “genius”, begins an invention by organizing and combining the known ideas or principles accumulated through experience, through the synthetic faculty (reasoning faculty). If he finds this accumulated knowledge to be insufficient for the completion of his invention, he then draws upon the sources of knowledge available to him through his creative faculty. The method by which he does this varies with the individual, but this is the sum and substance of his procedure:</p><ol><li>He stimulates his mind so that it vibrated on a higher-than-average plane, using one or mire of the ten mind stimulants or some other stimulant of his choice (mediation, mindfulness etc.)</li><li>He concentrates upon the known factors (the finished part) of his invention, and creates in his mind a perfect picture of unknown factors ( the unfinished part) of his invention. He holds this picture in his mind until it has been taken over by the subconscious mind, then relaxes by clearing his mind of all thought, and waits for the answer to “flash” into his mind</li></ol><blockquote>The human mind responds to stimulation!</blockquote><p>Sex energy is the creative energy of all genii. There never has been and never will be a great leader, builder, or artist lacking in this driving force of sex. The desire for sexual expression is by far the strongest and most impelling of all the human emotions, and for this very reason this desire, when harnessed and transmuted into action other than physical expression, may raise one to the status of a genius.</p><p>People are influenced in their actions not by reason so as by “feelings.” The creative faculty of the mind is set into action entirely by emotions, and not by cold reason. The most powerful of all human emotions is that of sex.</p><p>The salesman who knows how to take his mind off the subject of sex , and direct it in sales effort with as much enthusiasm and determination as he would apply to its original purpose, has acquired the art of sex transmutation, whether he knows or not.</p><p>Love, romance, and sex are all emotions capable of driving men to heights of super achievement. Love is the emotion which serves as a safety valve, and insures balance, poise, and constructive effort.</p><p>Encourage the presence of these emotions as the dominating thoughts in one’s mind, and discourage the presence of all destructive emotions. The mind is a creature of habit. It thrives upon the dominating thoughts fed it. Through the faculty of willpower, one may discourage the presence of any emotion, and encourage the presence of any other. Control of the mind, through the power of will, is not difficult. Control comes from persistence and habit. The secret of control lies in understanding the process of transmutation. When any negative emotion presents itself in one’s mind, it can be transmuted into a positive, or constructive emotion by the simple procedure of changing one’s thoughts.</p><p>The emotion of love brings out and develops the artistic and the aesthetic nature of man. It leaves its impress upon one’s very soul, even after the fire has been subdued by time and circumstance. The man who cannot be stimulated to great heights of achievement by love is hopeless-he is dead, though he may seem to live.</p><blockquote>Man’s greatest motivating force is his desire to please woman!</blockquote><p>Men who accumulate large fortunes, and attain to great heights of power and fame, do so mainly to satisfy their desire to please woman. Take woman out of their lives, and great wealth would be useless to most men.<em> It is this inherent desire to please woman, which gives woman the power to break a man.</em></p><h3>Chapter 12: The Subconscious Mind</h3><p>The connecting link</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*mRVZIJNM87pI5xqkpTiZ0Q.jpeg" /></figure><p>The subconscious mind consists of a filed of consciousness in which every impulse of thought that reaches the objective mind through any of the five sense is classified and recorded, and from which thoughts may be recalled or withdrawn as letters may be taken from a filling cabinet.</p><p>It receives and files sense impressions or thoughts, regardless of their nature. You may voluntarily plant in your subconscious mind any plan, thought, or purpose which you desire to translate into its physical or monetary equivalent. The subconscious acts first on the dominating desires which have been mixed with emotional feeling, such as faith.</p><p>You cannot <em>entirely</em> control your subconscious mind, but you can voluntarily hand over to it any plan, desire, or purpose which you wish transformed into concrete. Remember that the subconscious mind may be voluntarily directed only through habit, under the directions given in the chapter on faith.</p><p>Remember, your subconscious mind functions voluntarily whether you make any effort to influence it or not. This, naturally, suggests to you that thoughts of fear and poverty, and all negative thoughts, serve as stimuli to your subconscious mind, unless you master these impulses and give it more desirable food upon which it may feed.</p><p>For the present, it is sufficient if you remember that you are living daily in the midst of all manner of thought impulses which are reaching your subconscious mind without your knowledge. Some of these impulses are negative, some are positive. You are now engaged in trying to shut off the flow of negative impulses, and to aid in voluntarily influencing your subconscious mind through positive impulses of desire.</p><p>The subconscious mind is more susceptible to influence by impulses of thought mixed with “feeling” or emotion than those by originating solely in the reasoning portion of the mind. The subconscious mind understand best the language of emotion or feeling. Let us, therefore, describe here the seven major positive emotions and the seven major negative emotions, so that you may draw upon the positives and avoid the negatives when giving instructions to your subconscious mind.</p><h4>The Seven Major Positive Emotions</h4><ol><li>Desire</li><li>Faith</li><li>Love</li><li>Sex</li><li>Enthusiasm</li><li>Romance</li><li>Hope</li></ol><h4>The Seven Major Negative Emotions</h4><ol><li>Fear</li><li>Jealousy</li><li>Hatred</li><li>Revenge</li><li>Greed</li><li>Superstition</li><li>Anger</li></ol><blockquote><em>Positive and negative emotions cannot occupy the mind at the same.</em></blockquote><p>One or the other must dominate. It is your responsibility to make sure that positive emotions constitute the dominating influence of your mind. Here the law of habit will come to your aid.</p><blockquote>Where one is found, the other cannot exist</blockquote><h3>Chapter 13: The Brain</h3><p>A broadcasting and receiving station for thought</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*-N6DKxL5cswNYpfGgF0H4Q.jpeg" /></figure><p>Thought which has been modified or “stepped up” by any of the major emotions vibrates at a much higher rate than ordinary thought, and it is this type of thought which passes from one brain to another through the broader casting machinery.</p><p>The subconscious mind is the “sending station” of the brain, through which vibrations of thought are broadcast. The creative imagination is the “receiving set,” through which the vibrations of thought are picked up from the ether.</p><p>Operation of your mental “broadcasting: station is a comparatively simple procedure. You have but three principles to bear in mind and to apply when you wish to use your broadcasting station-the subconscious mind, creative imagination, and autosuggestion. The stimuli through which you put these three principles into action have been described- the procedure begins with desire.</p><p>Man, with all of his boasted culture and education, understands little or nothing of the intangible force (the greatest of al the intangibles) of thought. He knows but little concerning the physical brain and its vast network or intricate machinery through which the power of thought is translated into its material equivalent.</p><h3>Chapter 14: The Sixth Sense</h3><p>The door to the temple of wisdom</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*8jFyRLjHX9OQfPAhsJeOtA.jpeg" /></figure><p>The sixth sense is that portion of the subconscious mind which has been referred to as the creative imagination. It has been referred to as the “receiving set” through which ideas, plans, and thoughts flash into the mind. The “flashes” are sometimes called “hunches” or “inspirations.”</p><p>Experience has taught me that the next best thing to being truly great is to emulate the great, by feeling and action, as nearly as possible. I followed the habit of reshaping my own character by trying to imitate the men whose lives and lifeworks has been most impressive to me.</p><p>The procedure was that. Just before going to sleep at night, I would shut my eyes and see, in my imagination, this group of men seated with me around my council table. Here I had not only an opportunity to sit among those whom I considered to be great, but I actually dominated the group by serving as the chairman.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ftktwQgwcXsTCKo8ZUvrA.jpeg" /></figure><p>My purpose was rebuild my own character so it would be represent a composite of the characters of my imaginary counselors. My method of addressing the members of the imaginary cabinet would vary, according to the traits of character in which I was, for the moment, most interested in acquiring. I studied the records of their lives with painstaking care. After some months of this nightly procedure, I was astounded by the discovery that these imaginary figures became, apparently, real.</p><blockquote>One of the blessings of maturity is that it sometimes brings on greater courage to be truthful, regardless of what those who do not understand think or say.</blockquote><p>My original purpose in conducting council meetings with imaginary beings was solely that of impressing my own subconscious mind, through the principle of autosuggestion, with certain characteristics which I desired to acquire.</p><p>The starting point of all achievements is desire. The finishing point is that brand of knowledge which leads to understanding-understanding of self, understanding of others, understanding of the laws of nature, recognition and understanding of happiness.</p><h3>Chapter 15: How to Outwit the Six Ghosts of Fear</h3><p>Search yourself carefully as you study these six enemies, as they may exist only in your subconscious mind, where their presence will be hard to detect. Remember too, as you analyze the “six Ghosts of fear”, that they are nothing but ghost because they only exist in one’s mind. Remember, also, that ghosts-creations of uncontrolled imagination-have caused most of the damage that people have done to their own minds; therefore, ghosts can be as dangerous as if they lived and walked on the each in physical bodies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*KIkQthhpDWHDelvLt-7Hng.jpeg" /></figure><p>Indecision crystallizes into doubt; the two blend and become fear! The “blending” process often is slow. This is one reason why these three enemies are so dangerous. They germinate and grow without their presence being observed.</p><p>Before we can master an enemy, we must know its name, its habits, and its place of abode.</p><h4>The Six Basic Fears</h4><ol><li>The fear of POVERTY</li><li>The fear of CRITICISM</li><li>The fear of ILL HEALTH</li><li>The fear of a LOSS OF LOVE OF SOMEONE</li><li>The fear of OLD AGE</li><li>The fear of DEATH</li></ol><blockquote>Fears are nothing more than states of mind. One’s state of mind is subject to control and direction.</blockquote><p>Every human being has the ability to completely control his own mind, and with this control, obviously, every person may open his mind to the tramp thought impulses which are being released by other brains, or close to the doors tightly and admit only thought impulses of his own choice.</p><h4>The Fear of Poverty</h4><p>If you want riches, you must refuse to accept any circumstance that leads toward poverty. (The word “riches: is here used in its broadest sense, meaning financial, spiritual, mental and material estates.) If you demand riches, determine what form, and how much will be required to satisfy you.</p><blockquote>A state of mind is something that one assumes. It cannot be purchased, it must be created.</blockquote><p><strong>Symptoms of the fear of Poverty</strong></p><ol><li>Indifference</li><li>Indecision</li><li>Doubt</li><li>Worry</li><li>Over-caution</li><li>Procrastination</li></ol><p>There are many men that say “Give me all the money I need, and I will find everything else I want.”</p><h4>The Fear of Criticism</h4><p>Just how man originally came by this fear, no one can state definitely, but one thing is certain-he has it in highly developed form. The author is inclined to attribute the basic fear of criticism to that part of man’s inherited nature which prompts him not only to take away his fellowman’s goods and wares, but to justify his action by criticism of his fellow man’s character.</p><p>The astute manufactures of clothing have not been slow to capitalize on this basic fear of criticism which all of mankind has been cursed. Every season the styles in many articles of wearing apparel change. Who establishes the styles? Certainly not the purchaser of the clothing, but the manufacturer. Why does he change the styles so often? The answer is obvious. He changes styles so he can sell more clothes.</p><p>The fear of criticism robs man of his initiative, destroys his power of imagination, limits his individuality, takes away his self-reliance, and does him damage in a hundred other ways. Criticism is the one form of service if which everyone has too much. Everyone has as a stock of it which is handed out, gratis, whether called for or not.</p><p><strong>The symptoms of the fear of Criticism</strong></p><ol><li>Self-consciousness</li><li>Lack of poise</li><li>Personality</li><li>Inferiority complex</li><li>Extravagance</li><li>Lack of initiative</li><li>Lack of ambition</li></ol><h3>The Fear of Ill Health</h3><p>It has been shown most convincingly that the fear of disease, even where there is not the slightest cause for fear, often produces the physical symptoms of the disease feared. Powerful and mighty is the human mind! It builds or it destroys.</p><p><strong>The symptoms of the fear of Ill Health</strong></p><ol><li>Negative Autosuggestion</li><li>Hypochondria</li><li>Lack of exercise</li><li>Susceptibility</li><li>Self-coddling</li><li>Intemperance</li></ol><h3>The Fear of Loss of Love</h3><p>Jealousy and other forms of dementia praecox grow out of man’s inherited fear of the loss of love of someone. This fear is the most painful of all the six basic fears. It probably plays more havoc with the body and mind than any other of the basic fears, as it often leads to permanent insanity.</p><p><strong>The symptoms of this fear are</strong></p><ol><li>Jealousy</li><li>Faultfinding</li><li>Gambling</li></ol><h3>The Fear of Old Age</h3><p>In the basic fear of old age, man has two very sound reasons for his apprehension-one growing out of his distrust of his fellowman, and the other arising from the terrible pictures of the world beyond, which were planted into his mind through social heredity before he came into full possession of his mind. The possibility of ill health, which is more common as people grow older, is also a contributing cause of this common fear of old age.</p><p>Another contributing cause of the fear of old age is the possibility of loss of freedom and independence, as old age may bring it with the loss of physical and economic freedom.</p><p><strong>The symptoms of the Fear of Old Age</strong></p><p>The tendency to slow down and develop an inferiority complex at the age of mental maturity, around the age of forty, falsely believing one’s self to be “slipping” because of age.</p><p>The habit of speaking apologetically of one’s self as “being old” merely because one has reached the age of forty or fifty, instead of reversing the rule and expressing gratitude for having reached the age of wisdom and understanding.</p><p>The habit of the man or woman of forty dressing with the aim of trying to appear much younger, and affecting mannerisms youth, thereby inspiring ridicule by both friends and strangers.</p><h3>The Fear of Death</h3><p>To some this is the cruelest of all the basic fears. So-called “heathen” are less afraid of death than the more “civilized.” For hundreds of millions of years man has been asking the still-unanswered questions, “whence” and “whither.” Where did I come from, and where am I going?</p><p>Eternity is a long time. The thought of eternal punishment not only causes man to fear death, it often causes him to lose his reason. It destroys interest in life and makes happiness impossible.</p><p>In truth, no man knows, and no man has ever known, what heaven or hell is like, nor does any man know if it either place actually exists. This very lack of positive knowledge opens the door of the human mind to the charlatan so he may enter and control that mind with his stock of legerdemain and various brands of pious fraud and trickery.</p><p>This fear is useless. Death will come, no matter what anyone may think about it. Accept it is a necessity, and pass the thought out of your mind. It must be necessity, or it would not come at all. Perhaps it is not as bad as it has been pictured.</p><p>If death is not a mere change or transition, then nothing comes after death except a long, eternal, peaceful sleep, and sleep is nothing to be feared. Thus you must wipe out, forever, the fear of death.</p><p><strong>The symptoms of the fear of Death</strong></p><p>The habit of thinking about dying instead of making the most of life, due, generally, to lack of purpose, or lack of a suitable occupation. This fear is more prevalent among the aged, but sometimes the more youthful are victims of it. The greatest of all remedies for the fear of death is a burning desire for achievement, backed by useful service to others. A bust person seldom has time to think about dying.</p><p>The six basic fears become translated into a state of worry through indecision. Relieve yourself forever of the fear of death by reaching a decision to accept death as an inescapable event. Whip the fear of poverty by reaching a decision to get along with whatever wealth you can accumulate without worry. Put your foot upon the neck of the fear of criticism by reaching a decision not to worry about what other people think, do, or say. Eliminate the fear of old age by reaching a decision to accept it, not as a handicap, but as a great blessing which carries with it wisdom, self-control, and understanding not known to youth. Acquit yourself of the fear of ill health by the decision to forget symptoms. Master the fear of loss of love by reaching a decision to get along without love, if that is necessary.</p><p>A man whose mind is filled with fear not only destroys his own chances of intelligent action, but he transmits there destructive vibrations to the mind of all those that come into contact with him, and destroys, also, their chances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*KDTSCaljgXthKGd0FRy1QA.jpeg" /></figure><p>The book “Think and Grow Rich” by Napoleon Hill can be purchased at this <a href="https://www.amazon.com/Think-Grow-Rich-Landmark-Bestseller/dp/1585424331">link</a> (Amazon store)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8dab07d811a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Time Series Forecasting of Stock Prices with Python | Data Driven Investor]]></title>
            <link>https://medium.com/@u04561890/introduction-to-time-series-forecasting-of-stock-prices-with-python-data-driven-investor-1932e3874780?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/1932e3874780</guid>
            <category><![CDATA[forecasting]]></category>
            <category><![CDATA[timeseries]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[did]]></category>
            <category><![CDATA[stocks]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Tue, 07 Jul 2020 16:01:50 GMT</pubDate>
            <atom:updated>2020-07-07T19:08:01.391Z</atom:updated>
            <content:encoded><![CDATA[<p>In this simple tutorial, we will have a look at applying a time series model to stock prices. More specifically, a non-seasonal ARIMA model. We implement a <strong>grid search</strong> to select the optimal parameters for the model and forecast for the next 12 months.</p><h4>The ARIMA (p,d,q) model</h4><p>The acronym ARIMA stands for Auto-Regressive Integrated Moving Average and is one of the most common tools for forecasting a time series. Before we can apply ARIMA to a time series, the time series needs to be stationary. Stationary implies that<strong> </strong>the statistical properties are all constant over time, i.e there is no trend in the time series. Stationarity of a time series is often obtained by differencing the time series, and a time series that needs to be differenced is said to be an “integrated” version of a stationary series, hence the “I” in ARIMA. Once stationarity has been reached by a certain number of differences, we are left to determine the number of autoregressive terms (parameter p) and the number of lagged forecast errors in the prediction equation (parameter q). The number of lagged forecast errors is also often referred to as the “moving average”.</p><h4>Downloading the Data</h4><p>I will be using Amazon’s historic monthly stock price, which can be downloaded at the link: <a href="https://finance.yahoo.com/quote/AMZN/history?period1=1391904000&amp;period2=1581206400&amp;interval=1mo&amp;filter=history&amp;frequency=1mo">https://finance.yahoo.com/quote/AMZN/history?period1=1391904000&amp;period2=1581206400&amp;interval=1mo&amp;filter=history&amp;frequency=1mo</a>. Yahoo finance has various other stocks to choose from.</p><h4>Import the necessary libraries</h4><pre><strong>import</strong> <strong>numpy</strong> <strong>as</strong> <strong>np</strong><br><strong>import</strong> <strong>pandas</strong> <strong>as</strong> <strong>pd</strong><br><strong>import</strong> <strong>matplotlib.pyplot</strong> <strong>as</strong> <strong>plt</strong><br>%matplotlib inline<br><strong>from</strong> <strong>statsmodels.tools.eval_measures</strong> <strong>import</strong> rmse<br><strong>import</strong> <strong>seaborn</strong> <strong>as</strong> <strong>sns</strong><br><strong>import</strong> <strong>statsmodels.api</strong> <strong>as</strong> <strong>sm</strong><br><strong>import</strong> <strong>itertools</strong><br><strong>from</strong> <strong>statsmodels.tsa.arima_model</strong> <strong>import</strong> ARIMA, ARMA<br><strong>import</strong> <strong>warnings</strong><br>warnings.filterwarnings(&quot;ignore&quot;)</pre><p>Now it’s time to import the dataset and view it. We do so using the panda’s library and its read_csv function.</p><pre>data = pd.read_csv(&#39;filepath&#39;)<br>data.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*uo-8glAsqtPSOHbQyIFm5w.png" /></figure><p>We are only interested in the “Close” price. Also, we need to set the date as the index for the data frame.</p><pre>df = data[[&#39;Date&#39;,&#39;Close&#39;]] <br>df.Date = pd.to_datetime(df.Date) <br>df = df.set_index(&quot;Date&quot;) <br>df.head()</pre><p>Now that we have processed our data we can view the data as a line plot. Visualising our data is an important part of exploratory data analysis.</p><pre>df.plot(style=&quot;-&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*_m5vkcxg22wjZvGakluMlw.png" /></figure><p>When fitting an ARIMA model, we aim to find the values of our parameters p,d and q which optimise or minimise a certain metric of interest. There are many methods to achieve this goal and yet the correct parametrization of ARIMA models can be a tedious process that requires statistical expertise and time. In this tutorial, we hope overcome this issue by writing a grid search algorithm in python to select the optimal parameter values for our ARIMA(p,d,q) time series model.</p><p>The use of a “grid search” is to iteratively explore different combinations of parameters. For each combination of parameters, we fit an ARIMA model with the SARIMAX() function and assess its overall performance. Once we have explored the entire domain of parameters, our optimal set of parameters will be the one that yields the best performance for our criteria of interest. In this scenario, our criteria of interest is the Akaike information criterion (AIC). The AIC measures how well a model fits the data while taking into account the overall complexity of the model. We are therefore interested in finding a model that returns the lowest AIC value.</p><p>In the code below we define the parameters and generate all possible combinations of the parameters.</p><pre><em># Define the p, d and q parameters to take any value between 0 and 3<br></em>p = d = q = range(0, 3)</pre><pre><em># Generate all different combinations of p, q and q </em><br>pdq = list(itertools.product(p, d, q))</pre><p>In the next few lines of code, the SARIMAX() function is applied to all combinations of parameters and the model with the lowest AIC is printed.</p><pre>warnings.filterwarnings(&quot;ignore&quot;)</pre><pre>aic= []<br>parameters = []</pre><pre><strong>for</strong> param <strong>in</strong> pdq:<br>    <em>#for param in pdq:</em><br>        <strong>try</strong>:<br>            mod = sm.tsa.statespace.SARIMAX(df, order=param,           enforce_stationarity=<strong>True</strong>, enforce_invertibility=<strong>True</strong>)</pre><pre>results = mod.fit()<br>            <em># save results in lists</em><br>            aic.append(results.aic)<br>            parameters.append(param)<br>            <em>#seasonal_param.append(param_seasonal)</em></pre><pre>print(&#39;ARIMA<strong>{}</strong> - AIC:<strong>{}</strong>&#39;.format(param, results.aic))<br>        <strong>except</strong>:<br>            <strong>continue</strong></pre><pre><em># find lowest aic            </em><br>index_min = min(range(len(aic)), key=aic.__getitem__)             </pre><pre>print(&#39;The optimal model is: ARIMA<strong>{}</strong> -AIC<strong>{}</strong>&#39;.format(parameters[index_min], aic[index_min]))</pre><p>The output is: The optimal model is: ARIMA(0, 2, 1) — AIC:853.8946396688659</p><p>The next step is to fit the ARIMA(0,2,1) model to our time series.</p><pre>model = ARIMA(df, order=parameters[index_min]) <br>model_fit = model.fit(disp=0) print(model_fit.summary())</pre><p>Finally, we can forecast the next 12 months and visualise the data points thereafter.</p><pre>model_fit.plot_predict(start=2, end=len(df)+12) <br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*oodkyU33_d6ZS7cSWf_Q-g.png" /></figure><p>There we have it! Your first stock prediction algorithm. However, please note that it is extremely difficult to “time” the market and accurately forecast stock prices. This tutorial should not be seen as trading advice and the purchasing/selling of stocks is done at your own risk.</p><p><em>Originally published at </em><a href="https://www.datadriveninvestor.com/2020/07/07/introduction-to-time-series-forecasting-of-stock-prices-with-python/"><em>https://www.datadriveninvestor.com</em></a><em> on July 7, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1932e3874780" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Set Classification]]></title>
            <link>https://medium.datadriveninvestor.com/open-set-classification-22b292b4b300?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/22b292b4b300</guid>
            <category><![CDATA[open-set-classification]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Sun, 21 Jun 2020 17:00:43 GMT</pubDate>
            <atom:updated>2021-01-08T12:06:00.013Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine learning has taken the financial world by storm. Companies are implementing machine learning process to help understand risk and optimize stock trading algorithms, among other applications. More and more of these companies are realizing that for the machine learning technique to work well, the input data needs to be of a high standard. As the old saying goes, “Garbage in, garbage out.” The same applies to machine learning algorithms. If we feed the model with substandard and unclean data, we surely cannot expect interpretable results. The results will most likely resemble the quality of the input.</p><p>In real-world applications, it is often very difficult to knowingly obtain samples of data that will exhaust all classes when training a machine learning algorithm. In other words, if we want to train a classification algorithm that recognizes cars, it would be useful to feed the algorithm all types of cars, including super-cars, vintage, trucks etc. As you can see, to satisfy all classes of cars can be a tedious and difficult task.</p><p>A more realistic scenario is open set classification (OSC) or open world recognition. In this scenario, we suppose that incomplete knowledge of the data exists at training time, and during the testing phase, unknown classes can be submitted to an algorithm. This requires the classifiers to not only accurately classify the seen classes but also effectively deal with unseen ones. The goal of OSC is to develop algorithms that can distinguish between known and unknown data. These open set classifiers should handle unknown data that was not anticipated during the training phase.</p><p>Let’s look at an example of OSC in terms of object recognition. In the image below we have a “dog detector”, a model that has been trained on thousands of images to detect if there is a dog in an image. When presented images in the test data set, the model may falsely recognize unknown classes (classes not included in the training dataset), even when they perform well for known classes (images of dogs, for example). Most of the current machine learning models are closed-set classifiers, meaning that the input and target data sets come from the same class. In theory, OSC should classify the image of the clock as “Unknown” and not as a type of dog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yDOi-TwWwr_3mrJJHpKtnQ.png" /></figure><p>So before jumping in the deep end and applying machine learning techniques to all possible problems, first consider the quality of your data. Are you able to obtain all classes of your data? And if you aren’t, how will you model handle data that is new and unknown? Understanding new unknown data shares similar ideas to that of novelty and outlier detection.</p><p>Depending on the use case, various OSC have been proposed. Some within the deep neural network space and others using statistical properties of extreme value theory. <a href="https://arxiv.org/pdf/1811.08581.pdf">Geng et al</a>., 2018 discuss recent advances of OSC whilst covering various aspects ranging from related definitions, representations of models, datasets, evaluation criteria, and algorithm comparisons.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22b292b4b300" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/open-set-classification-22b292b4b300">Open Set Classification</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A New Kind of Science]]></title>
            <link>https://medium.com/@u04561890/a-new-kind-of-science-f4222ca987f0?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4222ca987f0</guid>
            <category><![CDATA[cellular-automata]]></category>
            <category><![CDATA[consciousness]]></category>
            <category><![CDATA[irreducible-complexity]]></category>
            <category><![CDATA[science]]></category>
            <category><![CDATA[computation]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Tue, 19 May 2020 19:34:02 GMT</pubDate>
            <atom:updated>2020-05-19T19:34:02.730Z</atom:updated>
            <content:encoded><![CDATA[<p>A new paradigm of thought.</p><p>Coauthor: <a href="https://medium.com/u/a313cd539359">Zach Wolpe</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*amuUyk-BDx6r9YQB.jpeg" /></figure><h4>See this simple pattern? What if it could change the way we think?</h4><blockquote>0 0 0 1 1 1 0</blockquote><p>What could this 7-bit binary string have to do with your consciousness? Or the very fabric of spacetime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r2l-Zo79O9g1vo0r.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jM7Tq7KsvTTr4vVf.jpeg" /></figure><p>To see the link, we have to think scientifically.</p><p>So<strong><em>, How</em></strong> do you think about science?</p><p>Science is a process by which we hope to learn about the structure of the world. If you think about it we’re just trying to describe what we observe to make predictions.</p><p>Mathematics has long been the primary <strong><em>tool </em></strong>to describe our findings. Nowhere has this been more successful than in Physics, though it applies everywhere.</p><p>The biological &amp; social sciences are particularly messy, &amp; defining equations that motivate human or organic behaviour has proven exceedingly difficult.</p><p>How can a simple equation define something as complex as a person’s behaviour? Or describe how a forest changes over time.</p><p>Science has thus become an intertwined story of theoretical ideas &amp; equations. The more clearly refined phenomena, the more reliance on equations over theory.</p><h3>Reductionism</h3><p>This approach to defining the world around us implies we can simplify the world to deterministic (or even stochastic) equations, with supporting theory.</p><p>The other fundamental doctrine of the scientific method is <strong><em>reductionism</em></strong>.</p><p>The reductionist view is that the whole is the sum of its parts. To understand a system we simply need to break it down to its constituents. For example, reductionism is the type of scientific reasoning that leads one to believe:</p><ul><li>If you want to understand how the body works</li><li>You need to understand how the organs work</li><li>Thus you need to understand how cells work</li><li>Then Molecules &amp; &amp; &amp;.</li></ul><p>Leading to the conclusion of <strong><em>Additivity</em></strong>.</p><p>For a long time to do modern science is to think this way. It’s a product of the enlightenment. It has taken us very far.</p><p>However, reducibility has another profound implication, one of computation. If you think about it, to reduce something to an equation is to ‘outrun’ or ‘out-compute’’ its process. If I throw a ball, we can use high school physics to work out where the ball will land before the events unfold. We’re able to predict, estimate the future based on the current state. Is this always true?</p><p>Now back to our little pattern. It’s an instance of <strong><em>cellular automata</em></strong>. It’s simple. It’s implications are not.</p><h3>Cellular Automata</h3><h3>A Brief history</h3><p>John von Neumann is considered to be the first person to introduce the notion of cellular automata through his work on abstract models of self-reproduction in biology. It is understood that John von Neumann’s goal was to design a machine whose complexity could grow automatically, similar to how biological organisms evolve or grow under natural selection. To achieve his goal, he needed to specify an abstract machine which, when run, would replicate itself. To define this type of machine in more detail, von Neumann developed the field of automata theory.</p><p>The initial cellular automaton that he constructed in 1952–3 consisted of a two- dimensional grid of cells with 29 possible colours for each cell. Complicated rules were specifically set up to emulate the operations of components of an electronic computer and various mechanical devices. At each timestep or new generation, each cell updates its state depending on the states of the surrounding cells at the prior timestep/generation. The rules governing these updates are identical for all cells.</p><p>Over the following decade since the development of cellular automata, it became clear that far simpler machines were able to achieve self-replication. However, von Neumann was interested in something more profound: the overall complexity, universality, and evolution of cellular automata. As a result, fascinating themes started to unfold in the domain of automata theory. Most notably, the attempt to encapsulate the essence of self-reproduction by mathematical studies of detailed properties of cellular automata.</p><p>By the mid-1970s, cellular automata were viewed as parallel computers with a foundation of detailed and technical mathematical theorems. For example, there was an attempt to connect cellular automata to mathematical discussions of dynamical systems. However, further mathematical work on cellular automata becomes quite abstruse and as a result interest in the field slowly subdued.</p><p>Despite the lack of attentiveness towards cellular automata, there was a case in which it did enter recreational computing in a transformative way. In 1970, John Conway had come up with a simple set of rules called ”The Game of Life” that was able to exhibit complex behaviour. This game became extremely popular and relevant through wide-spread media at the time. Many academics attempted to find special initial conditions that would give rise to specific patterns, shapes, or some form of repetitive behaviour. Unfortunately, not a lot of systematic investigation was done since these types of games were viewed more as recreational work.</p><p>In 1981 Stephen Wolfram started working on cellular automata in hopes of defining the field in a new way. He published his first paper on the field in 1983, which led to a rapid rise in interest over the following years. After nearly 20 years of researching cellular automata, Wolfram published a book called ”A New Kind of Science”, which introduced concepts of intrinsic randomness, computational irreducibility, computational equivalence, and much more. The sheer complexity that arose from these simple rules ushered Wolfram to suspect that the complexities that we view in nature may be structured similarly.</p><h3>How does it work?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FEXcnIOyFNEE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEXcnIOyFNEE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FEXcnIOyFNEE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/29bb2daa28b4b6d2d3ed1d125222463a/href">https://medium.com/media/29bb2daa28b4b6d2d3ed1d125222463a/href</a></iframe><p>To understand the workings of cellular automata we will consider the simplest version, which is the one-dimensional cellular automata (also known as the elementary cellular automata).</p><p>We start by constructing a simple grid. The grid is made up of a line of cells stacked horizontally next to one another. Each cell has a state. The number of states that a cell can acquire is finite with only two possibilities: 1 or 0 (also referred to as ”alive” or ”dead”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h1pugizjWIQTVjRj.png" /></figure><p>A cell and its two neighbour cells (adjacent cells, one on either side of the middle cell) form a neighbourhood of 3 cells. This implies that there are 28 = 8 possible configurations for a neighbourhood since each cell has only two possible states.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GLyNs4YlKDoM_fw4.png" /><figcaption><a href="https://natureofcode.com/book/chapter-7-cellular-automata/">The Nature of Code</a></figcaption></figure><p>A rule determines whether the cell in the next time-step/generation will be 0 or 1. In essence, there is an outcome associated with each possible neighbourhood configuration. Since there are 8 possible neighbourhood configurations, and each configuration has an outcome of either 0 or 1, it implies that there are 28 = 256 possible rules. We apply our rules to all cells in the first grid in order to visualize the change from generation 0 to generation 1. For visual purposes, 0 means white, and 1 means black. After many iterations, we can see a pattern form with each new generation appearing below the previous one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b7gylTebuEl-3nKe.png" /><figcaption><a href="https://natureofcode.com/book/chapter-7-cellular-automata/">The Nature of Code</a></figcaption></figure><h3>Links to consciousness</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fj58HZXEc65U%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dj58HZXEc65U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fj58HZXEc65U%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b591062d41500755f3f61ba6599b465/href">https://medium.com/media/8b591062d41500755f3f61ba6599b465/href</a></iframe><p>During his studies of the computational universe, Wolfram notices that even the simplest underlying rules were able to produce systems that were arbitrarily rich and complex. This got him thinking: Could the physical universe work this way? Could it be that behind all of this richness and complexity there are just a bunch of simple rules? If we take a look at the infamous rule 30, the underlying rules are basic, and yet to our astonishment, it produces something that we would not expect. Rule 30 has the feature that if we start with one black cell (”alive” cell) at the middle cell, the rule then develops a random sequence down the middle column of cells. An unexpected result that seems to break all intuition on how simple computational algorithms evolve.</p><p>When starring into the abyss, it seems instinctual to ask the question: What secret does nature have that allows it to have and make all of its complexity? Answering this question may possibly go hand in hand with thinking about the unexpected complexities of rule 30. However, the problem is that rule 30 seems to be unbreakable. It seems to have the feature that its computationally irreducible and we can’t say for certain what will happen at some future time-step, not unless we computationally run it. Nature seems to share this feature but in terms of evolution and natural selection. We have no idea what the natural world will look like a few hundred years.</p><p>With the development of artificial intelligence, researchers are determined to build machines that are able to mimic the functions of our brains. The hope is that to some extent we could computationally replicate the workings of the neurons within the human brain. There have been great strides in the past decade, but we are still far from fully understanding the complexities of the brain, especially in the domain of consciousness. Sure, computers may outperform humans in terms of brute computational tasks, but there’s still a long way to go before they are ”conscious”… Or is there?</p><p>How will we know when a machine becomes conscious? Does consciousness have certain characteristics that we can examine? Are we even conscious? Great philosophical points that make one’s head hurt. David Chalmers, a well-known Australian philosopher coined the term ”The Hard Problem of Consciousness”. This hard problem is the problem of how physical processes in the brain give rise to the subjective experience of the mind and of the world. The subjective experience from a personal perspective can be somewhat defined as: There is something like to be that person. It’s part of the ”inner movie” of the mind. This inner movie has multiple features, such as sound, vision, emotion, and feeling.</p><p>The subjective experience is the most mysterious of experiences and it has puzzled the greatest minds that have walked this Earth. Why is that the physical processes in the brain should produce these experiences? Why don’t our billion neurons fire in the darkness of the void? No one knows the answer to that right now. It’s a question that bridges philosophy and science, and at this moment, our scientific methods don’t have such a great grasp on the question.</p><p>Is it possible that the complexities seen in the computational universe are analogous to the hard problem of consciousness? Could the firing of our billions of neurons be viewed as underlying rules that evolve into the subjective experience? If such simple and basic rules that were shown before are able to produce immensely complex behaviours, it could indicate that underlying rules that are infinitely more complex may give rise to systems that are beyond our understanding. If rule 30 is irreducible, it doesn’t seem too far fetched that the same property may hold true for consciousness.</p><p>If at some point we do find out that consciousness is a byproduct of the computational universe, it may suggest that rule 30 and other programs are also conscious at some level. Then, assuming that the physical universe was computationally equivalent, would this imply that all of physics involves some element of consciousness? Nothing has been systematically proven thus far, and studying the computational universe might not ever give us the answers that we are looking for in terms of consciousness, but there’s the hope that it might lead us to ask the right questions.</p><p>Python Implementation</p><p>For those who want to play with CAs, here’s a simple python class defined to run a CA. Change the rule or make up your won. R visualization also available: <a href="https://github.com/ZachWolpe/Rule30-Cellular-Automata">https://github.com/ZachWolpe/Rule30-Cellular-Automata</a>.</p><h3>Irreducibility, Emergence &amp; Complexity</h3><p>So what’s so special about this pattern? Easy to overlook, but it embodies a powerful idea.</p><p>Firstly a contrast presents itself in the level of complexity produced. How do such simple algorithms cause such a wealth of convolution? This is non-trivial if you really think about it. Intuition tells us that simple rules should produce simple things. Cellular automata is not an algorithm, it’s a philosophy. Many complex things can arise from simple computations. Where else does this apply?</p><p>A second, equally notable observation is the inherent randomness of Rule 30. Rule 90 produces a fractal, masking endless structure. Rule 30 is in some regard as close to true randomness as we can manage (running down the central cells produces a pseudo-random generator). We experience a deterministic reality, but modern quantum mechanics (as fundamental science as part of our universal description as it gets) informs us of a probabilistic nature. &amp; what does it mean for randomness to emerge from a purely deterministic algorithm? One could spend a year thinking about this, &amp; perhaps it’s simple pseudo-randomness, however, it exaggerates the undeniability of the complexity of these structures.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTx8Dk1AqQ-8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTx8Dk1AqQ-8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FTx8Dk1AqQ-8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e6a2825f55134cb9ad6540d4c9b4e6b/href">https://medium.com/media/6e6a2825f55134cb9ad6540d4c9b4e6b/href</a></iframe><p>What if we now remove the toy algorithms &amp; think about these principles as a tool for scientific exploration. These algorithms illustrate a purely computational way of approaching understanding.</p><p>Firstly they are irreducible, there is no way of knowing, or calculating with an equation, what value a particular cell will hold. The only way of computing this is to run the computation &amp; observe the results. If natural phenomena exhibit the same properties, is it possible that some natural structures are irreducible, &amp; the only way to reveal their pattern is to allow time to ‘run the computation’? It also begs questions of the stochasticity in quantum mechanics — perhaps derivable from even simpler fundamental deterministic processes.</p><blockquote>Final Thought</blockquote><blockquote><em>The most interesting of all observations is that of emergence. So much of what we care about is so infinitely complex that to assume to be a product of simplistic mechanics would be dismissed as foolish. This is not the case. Emergence is observable — we have an existence proof. Now try to fathom what it means for the way we think about the world.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4222ca987f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can AI be fooled?]]></title>
            <link>https://medium.datadriveninvestor.com/can-ai-be-fooled-722f59bb2e9a?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/722f59bb2e9a</guid>
            <category><![CDATA[fooled]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[humans]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[vision]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Mon, 27 Apr 2020 16:49:13 GMT</pubDate>
            <atom:updated>2020-04-28T16:02:39.579Z</atom:updated>
            <content:encoded><![CDATA[<p>The prospect of computers being able to view the world as humans have been a subject of increasing interest in the past few decades. Through years of research, we have come to understand the complexity of the human visual system and how impressive it would be to replicate these processes in a machine. To replicate how humans “see” the world, computers would have to decipher multi-dimensional data and recognise patterns within the data. No easy feat of course.</p><p>A deep neural network (DNN) is a feedforward type of network that is used to model various complex non-linear relationships. In terms of computer vision (more specifically image recognition), a DNN that is trained to recognise traffic signs will use the data of the given image to calculate the probability that the sign in the image is a certain traffic sign. Recently, DNNs have been achieving near-human like performance in numerous tasks such as visual classification and pattern recognition.</p><p><a href="https://www.datadriveninvestor.com/2020/02/12/has-general-ai-exceeded-the-intellectual-capacity-of-humans/">Has General AI Exceeded the Intellectual Capacity of Humans? | Data Driven Investor</a></p><p>Now, given that DNNs are able to classify images so well, the question arises: Is there any difference between human and computer vision? Is it possible that there are images that seem unrecognisable to humans but are quite obvious to computers? Or vice versa. You might be happy to hear that human vision still surpasses computer vision in certain areas. It was recently shown that DNNs can be fooled, and quite easily in fact. A <a href="http://www.evolvingai.org/fooling">study</a> revealed that it is possible to create/evolve synthetic images that are unrecognisable to humans ( e.g. TV static) but are classified with high-certainty by computers to be familiar objects.</p><p>There are two ways in which to evolve these “fooling” images. Firstly by directly encoding the images: this is done by independently optimising the colour values in each pixel. The directly encoded images output visuals that resemble white noise (or TV static to us humans). DNN’s have classified the images below with high-certainty to be familiar objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*863zppZEAzrV5cKg21SnYg.png" /></figure><p>Secondly, one can evolve images with indirect encoding, which produces images with the use of more regular patterns. These types of images may be recognisable to humans and DNNs. Similarly, the images below are unrecognisable to humans but again DNNs have somehow classified them with high-certainty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*NI-yuaB-HhDlEsKr1czvKQ.png" /></figure><h4>Why are DNNs getting it so wrong?</h4><p>It all has to do with what the DNN focuses on. In the case of directly encoded images, DNNs may be looking at concentrated colour pixels that vaguely resemble an image it has been trained on. In other cases, the images may have the correct colour or pattern of a certain class, suggesting that an unrecognisable image is a familiar object.</p><h4>Why does fooling DNNs matter?</h4><p>Imagine a scenario where a facial recognition system is deployed to detect which staff members have access to certain files. A criminal might be able to fool or bypass the system by producing synthetic images. This is a considerable security risk and shows us that computer vision still has a long way to go before being able to replace humans</p><p><em>References</em></p><p><a href="http://anhnguyen.me/">Nguyen A</a>, <a href="http://yosinski.com/">Yosinski J</a>, <a href="http://jeffclune.com/">Clune J</a>. Deep Neural Networks are Easily Fooled: High Confidence Predictions for Unrecognizable Images. In Computer Vision and Pattern Recognition (CVPR ‘15), IEEE, 2015. (<a href="http://www.evolvingai.org/files/DNNsEasilyFooled_cvpr15.pdf">pdf</a>)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=722f59bb2e9a" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/can-ai-be-fooled-722f59bb2e9a">Can AI be fooled?</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How do Regression Trees Work?]]></title>
            <link>https://medium.datadriveninvestor.com/how-do-regression-trees-work-94999c5105d?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/94999c5105d</guid>
            <category><![CDATA[regression-tree]]></category>
            <category><![CDATA[regression-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 04:54:01 GMT</pubDate>
            <atom:updated>2020-04-15T08:58:37.169Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/datadriveninvestor/how-does-a-decision-tree-work-3b636cd94ee0">Previously</a> we spoke about decision trees and how they could be used in classification problems. Now we shift our focus onto regression trees. Regression trees are different in that they aim to predict an outcome which can be considered a real number (e.g. the price of a house, or the height of an individual). The term “regression” may sound familiar to you, and it should be. We see the term present itself in a very popular statistical technique called linear regression. Although linear regression and regression are not alike, the basic idea behind the “regression” part remains the same. Regression attempts to determine the relationship between one dependent variable and a series of independent variables.</p><p>In this article we hope to illustrate the difference between linear regression and regression trees in their usefulness, build our own regression tree and instantiate a regression tree in Python.</p><h3><strong>The Problem</strong></h3><p>Suppose we are scientists and have developed a brand new drug to treat the common flu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*bjyQC6A8dhYuKcFC_iunYw.png" /></figure><p>However, we don’t know the optimal dosage for our patients. To investigate this problem we run a clinical trial with different dosages and measure how effective each dosage is. In the end, we would like to accurately predict the efficiency of the drug at a certain dosage level.</p><h4>Linear Regression</h4><p>If we plot the results of the clinical trial in some hypothetical scenario, the data points may look similar to the graph below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lr4rzUCDO7cb3wWKvrSnUg.png" /><figcaption>Plot A</figcaption></figure><p>The data points in the plot above (Plot A) indicates that there is some positive correlation between drug dosage and drug efficiency. Meaning that in general, the higher the dose, the higher the efficiency. We could easily fit a straight line to this data with linear regression and use the line of best fit to draw predictions. For instance, a drug dosage of 23 mg has a predicted value of 63% efficiency. Unfortunately, data doesn’t always seem to present itself so well. More realistically, we might end up with data points being much noisier. This is seen in the plot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*HqqTwl1dB2XrFLyHU_91IQ.png" /><figcaption>Plot B</figcaption></figure><p>Applying linear regression to the data points (Plot B) above, we notice that there is a large difference between the predicted value and the actual value for a drug dosage of 23 mg. It seems evident that linear regression might not be the best method to model the data. Well, what other method could we use? Yep, you guessed it, it’s in the title: <strong>regression trees.</strong></p><p><a href="https://www.datadriveninvestor.com/2020/03/24/encoder-decoder-sequences-how-long-is-too-long/">Encoder Decoder Sequences: How Long is Too Long? | Data Driven Investor</a></p><h4>Regression Trees</h4><p>Regression trees are similar to decision trees but have leaf nodes which represent real values. To illustrate regression trees we will start with a simple example. Don’t worry, we’ll get into the details shortly. For the <em>root node</em> of our tree, we ask: “is dosage less than 14 mg?”. Then using the data points seen in Plot B, we should get a tree that looks similar to the one below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*lP8cFrVYC6u_9RDtu7DScQ.png" /><figcaption>Example of a regression tree</figcaption></figure><p>If the answer to the question in the root node is “True”, then we are directed to the left node, otherwise, we are directed to the right node, which carries on further.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*oNc8APhYCBZYuVNDKQD1Hw.png" /></figure><p>For the time being let’s focus on the first leaf node on the left-hand side: how did we get that value of 4.5%? Since we have a threshold of 14 in the root node, we look at observations which are<strong> less</strong> than 14 and calculate their <strong>average</strong>. In our case, the average of the first 6 observations is 4.5% (efficiency).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*xMWxnU8S-ZesWCatCgQ95Q.png" /></figure><p>Once this first leaf node is complete we can apply the same process to the nodes on the right-hand side. Each red block in the picture below represents a leaf node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*dsvYEUthFWoeDEMqmpvEyA.png" /></figure><blockquote><em>Let’s have a look at how we got the </em><strong><em>last leaf node</em></strong><em> on the </em><strong><em>right hand side</em></strong><em> (the leaf node with 100% efficiency)</em></blockquote><p>We get the last leaf node on the right-hand side by following the conditions set out by the nodes until the very end. If the dosage is more than 14 but less than 29 and 24, we are left with an interval which is highlighted in the picture below. The average drug effectiveness for the 4 observations in the red box is 100%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*hY2V0E9NHBOxow-tJoTq0Q.png" /></figure><p>So the tree uses the average value (100%) as the prediction value for dosages between 14.5 and 23.5.</p><h3>Building our own Regression Tree</h3><p>Now that we have gone through an example of what a regression tree looks like, let us develop one ourselves from the very beginning using the same unstructured data in Plot B. The first part of building a regression tree is <strong>deciding which threshold to have in the root node</strong>. Do you recall a similar question in the blog about decision trees?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*0gJLnRuyKtryaB01CaQqHA.png" /></figure><p>To help us decide, we will first focus on the observations with the <strong>two smallest dosages</strong>. The average dosage between those two patients is <strong>3 mg</strong>. We draw a vertical line at the point 3 to indicate a split in our data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*NPCcV6xp6gN-l-EY6Re35g.png" /></figure><p>The two dots which are highlighted red represent the two smallest dosages. The red dotted line splits the data into two parts. The next step is to calculate the average efficiency of the observations on the left and right-hand side of the red dotted line. On the left-hand side (less than 3 mg), there is only one observation, which results in an average of 0%. On the right-hand side (greater than 3mg), there are many observations with an average of 38.8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*Wj36hIG-wFWuHyK17pHC7Q.png" /></figure><p>We create a simple tree with “Dosage &lt; 3” as the root node and two subsequent leaf nodes. The average on the left-hand side of the dotted line goes into the left leaf node and the average on the right-hand side goes to the right leaf node. The values in the leaf nodes are the predictions that this simple tree will make for drug effectiveness.</p><blockquote><strong><em>How to determine how well our simple tree splits the data </em></strong><em>?</em></blockquote><p>The left leaf node has predicted the outcome perfectly. The actual efficiency for dosages less than 3mg is 0% and our tree predicted it as such. But how do we check the accuracy of the right-hand side when there are so many observations to consider?</p><p>We can use a method that is common in linear regression:</p><blockquote>Sum of Squared Residuals (SSR)</blockquote><p>A residual is a measure of the distance from a data point to a regression line. SSR measures the overall difference between our data and the values predicted by our regression tree. Generally, a lower SSR indicates that the regression model can better explain the data while a higher SSR indicates that the model poorly explains the data. The formula of SSR:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/148/1*TEcgOkHbFbiSoHgQ_MTjkQ.png" /><figcaption>Formula for SSR</figcaption></figure><p>We can visualise the residuals of our simple tree by constructing lines from the observed to the predicted value. Notice again that on the left-hand side the predicted value is equal to the observed value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*4yP6HKADZhWV4yYh1eVX5Q.png" /></figure><p>We can use the residuals to quantify the quality of the predictions made by our simple tree. Next, we calculate the SSR for the tree by adding the SSR of the left and right leaf nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*_Ko1JgHk1Q_DUPOsPjeZDw.png" /></figure><p>We get a total SSR value of 27.5 for the tree. The entire process is then applied to the second and third lowest observations, the third and fourth lowest observations and so on...</p><p>Once we have calculated all the SSR values for the trees made by the pairs of observations, we can plot the SSR values as a function of dosage threshold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*cYMZIUI5JpsfhCSsYCFIUQ.png" /></figure><p><strong>The lowest SSR value represents the dosage threshold which will be at the root node of the tree.</strong> In this case, the lowest SSR value is 14.</p><p>Once the root node has been decided, the data will be split up into a left and right node. These nodes also require an optimal threshold to split the data further. How do we go about choosing these thresholds? The same process which was applied to obtain the root node is now applied to the remaining nodes of the tree. Each node should have a threshold which represents the lowest SSR value available. Once the data cannot be split further (only one observation in the train data) or there it is redundant to split (if all observations have the same value), the node itself becomes the leaf node.</p><h3><strong>Building Regression Trees in Python</strong></h3><p>Here we will have a quick look at building a regression tree in Python with the Sklearn package</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVKsZjucxOyWWbEWh1I2hw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@codestorm?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Safar Safarov</a> on <a href="https://unsplash.com/s/photos/code?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong>About the Dataset</strong></p><p>We will be generating a random data set to represent the clinical trail example that was discussed earlier.</p><p><em>Note</em>: In the notebook, we do not clean the data. The reason for this is that the purpose of the blog is to illustrate how to run a regression tree classifier and not show data cleaning techniques. The onus is on the reader to properly clean the data. Data cleaning and preparation is an extremely important phase within the data science world and should not be overlooked.</p><p><strong>Import the necessary libraries</strong></p><pre>import pandas as pd<br>import numpy as np<br>from sklearn.tree import DecisionTreeRegressor<br>from sklearn.model_selection import train_test_split<br>import matplotlib.pyplot as plt</pre><p><strong>Create a Random Data Set</strong></p><pre>rng = np.random.RandomState(1)<br>X = np.sort(5 * rng.rand(80, 1), axis=0)<br>y = np.sin(X).ravel()<br>y[::5] += 3 * (0.5 - rng.rand(16))</pre><p>X and Y arrays are generated using the code above. The user can select their own parameters for reproducibility purposes.</p><p><strong>View the data set</strong></p><pre>plt.figure()<br>plt.xlabel(&quot;Dosage (mg)&quot;)<br>plt.ylabel(&quot;Efficiency&quot;)<br>plt.scatter(X, y)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*xsF4y_4rs5po3QikbsppAw.png" /></figure><p>Unlike the dependent variable in the example, we will consider some arbitrary measure for the efficiency of the drug dosages. Notice the trend in the plot. The optimal dosage seems to be around 1.8mg. Our goal is to predict the efficiency of a drug given the dosage, all with the help of regression trees.</p><p><strong>Create Training and Testing Data Sets</strong></p><p>Next step is to split our data into <strong>training</strong> and <strong>testing</strong> data sets. The training data set is used to train/create a regression tree. Then the regression tree is tested on our testing data set to see how well it performs on unseen data. We use the train_test_split function from Sklearn.model_selection to achieve this.</p><pre># Create the training and test sets<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=123)</pre><p><strong>Instantiate the Regression Tree Classifier</strong></p><p>Here we instantiate the regression tree classifier and set the parameters. All the parameters are detailed <a href="https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeRegressor.html">here</a>. We will only go through a few of them:</p><p>1) <strong>Criterion<em>{“mse”, “friedman_mse”, “mae”}, default=”mse”</em>:</strong> The function to measure the quality of a split. Supported criteria are “mse” for the mean squared error, which is equal to variance reduction as a feature selection criterion and minimizes the L2 loss using the mean of each terminal node, “friedman_mse”, which uses mean squared error with Friedman’s improvement score for potential splits, and “mae” for the mean absolute error, which minimizes the L1 loss using the median of each terminal node.</p><p>2) <strong>max_depth: <em>int, default=None: </em></strong>The maximum depth of the tree. If None, then nodes are expanded until all leaves are pure or until all leaves contain less than min_samples_split samples.</p><p>3) <strong>min_samples_split: <em>int or float, default=2</em>:</strong> The minimum number of samples required to split an internal node</p><p>The parameters may be tuned in order to find the best regression tree in terms of some chosen criterion. A grid search is a popular method used to return the optimal parameters.</p><pre>clf = DecisionTreeRegressor(max_depth=2)</pre><p><strong>Fit the Classifier to the Training Set</strong></p><pre>clf.fit(X_train, y_train)</pre><p><strong>Predict the Target Variable of the Test Set: y_pred</strong></p><p>In our case, it’s drug efficiency.</p><pre>y_pred = clf.predict(X_test)</pre><p><strong>View the predicted values versus the observed values in the test data set.</strong></p><pre>plt.figure()<br>plt.scatter(X_test, y_pred, s=20, edgecolor=&quot;black&quot;,<br>            c=&quot;darkorange&quot;, label=&quot;Observed values&quot;)<br>plt.scatter(X_test, y_test, s=20, edgecolor=&quot;black&quot;,<br>            c=&quot;blue&quot;, label=&quot;Predicted values&quot;)</pre><pre>plt.xlabel(&quot;Dosage (mg)&quot;)<br>plt.ylabel(&quot;Efficiency&quot;)<br>plt.title(&quot;Decision Tree Regression&quot;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*8nsRA0ZYqm-DukVpXjTgBw.png" /><figcaption>Regression tree on test data</figcaption></figure><p><strong>Caveat</strong></p><p>Regression trees with a large depth value have a high probability of overfitting the training data set. When this happens, the model is unlikely to perform well when exposed to new and unseen data. To overcome this obstacle one could decrease the maximum depth of the tree or increase the minimum number of samples required to split an internal node. Another popular technique is pruning the regression tree. Pruning is a technique that reduces the size of regression by removing sections of the tree that provide little power to classify instances.</p><p><em>References</em></p><p><a href="https://corporatefinanceinstitute.com/resources/knowledge/other/sum-of-squares/">Sum of Squares</a></p><p><a href="https://www.youtube.com/watch?v=g9c66TUylZ4&amp;t=493s">StatQuest with Josh Starmer</a></p><p><a href="https://scikit-learn.org/stable/auto_examples/tree/plot_tree_regression.html">Decision Tree Regression</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94999c5105d" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/how-do-regression-trees-work-94999c5105d">How do Regression Trees Work?</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Does a Decision Tree Work?]]></title>
            <link>https://medium.datadriveninvestor.com/how-does-a-decision-tree-work-3b636cd94ee0?source=rss-5d4a39f8d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b636cd94ee0</guid>
            <category><![CDATA[gini-impurity]]></category>
            <category><![CDATA[gini-index]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[decision-tree]]></category>
            <dc:creator><![CDATA[Luka Beverin]]></dc:creator>
            <pubDate>Wed, 01 Apr 2020 20:23:14 GMT</pubDate>
            <atom:updated>2020-04-03T15:10:17.405Z</atom:updated>
            <content:encoded><![CDATA[<p>We as humans make decisions every day, sometimes without even knowing it. Which shirt to wear? Tea or coffee? Do I take my kids to school today? Hopefully, you didn’t have to ponder too much about the last one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TjdkLfxWyIMAEYZ3CfcGcg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kennyzhang29?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Zhang Kenny</a> on <a href="https://unsplash.com/s/photos/decision-tree?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><blockquote>“I like to think of life as just one decision after another” — Jonah Lehrer</blockquote><p>Not a day goes by that we aren’t bombarded with choices to make. Some are easy as deciding which hat to wear and some are as difficult as deciding on which university to attend. In order to visualise a decision making process, we will have a look at an overly simplified example: do I go to the beach or do I stay at home and watch movies? Well, the answer almost always depends on what the weather is like on the day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*K0m-XbQ-N7h_AJUxDLAoIA.png" /></figure><p>First you look out your window and check the weather. If it’s raining then you stay at home, otherwise, if it’s <strong>not</strong> raining you go to the beach. A simple decision that doesn’t require an ounce of brainpower.</p><h4>Decision Trees in Machine Learning</h4><p>In a machine learning paradigm, a decision tree is a predictive modelling tool that has applications spanning a number of different areas. In general, decision trees are constructed via an algorithmic approach that identifies ways to split a data set based on different conditions. It is one of the most widely used and practical methods for <strong>supervised learning</strong>. Decision Trees are a non-parametric supervised learning method used for both classification and regression tasks. The goal is to create a model that predicts the value of a target variable by learning simple decision rules inferred from the data features. In our example, we want to predict what we are going to do today and the data feature is the weather, or more specifically whether it’s raining.</p><p><a href="https://www.datadriveninvestor.com/2020/02/19/cognitive-computing-a-skill-set-widely-considered-to-be-the-most-vital-manifestation-of-artificial-intelligence/">Cognitive computing - a skill-set widely considered to be the most vital manifestation of artificial intelligence. | Data Driven Investor</a></p><p>A decision tree is a tree-like graph with nodes representing the place where we pick an attribute and ask a question. Once the first question is answered we a directed to another node, either left or right depending on the answer, where a second question is asked. The second question may not have further questions but an answer. In the case that no more questions are asked, we refer to the node as a leaf node. This is analogous to a leaf being at the end of a tree, there is no more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*kv8wJQsw3WEam7-CZ3lQ3Q.png" /></figure><p>Decision trees classify the examples by sorting them down the tree from the root node to some leaf node, with the leaf node providing the classification to the example. In our weather example from before, the root node would be “Is it raining?” and the leaf nodes would be “Stay at home and watch movies” and “Go to the beach”.</p><h3><strong><em>Example of a Yes/No Decision Tree</em></strong></h3><p>Let’s illustrate this with help of an example. Let’s assume that we are doctors and want to predict whether a patient has the seasonal flu or not. The usual symptoms of a flu are cough, fever and tiredness. However, the previous doctors had a group of 200 patients who all entered their symptoms and the final outcome (all yes/no inputs). We have access to this data and would like to use the data to help us predict if a new patient has the flu or not. We will ask the patient the same questions and use the questions to build a decision tree.</p><figure><img alt="Data that the previous doctors acquired" src="https://cdn-images-1.medium.com/max/716/1*-wh78A1eTpK9EYCVRSDO4g.png" /></figure><p>In other words, we want to transform the table above into a decision tree. But how do we start? Which attribute should be at the Root Node? In our weather example it was pretty straight forward because we only had one attribute, but here we have 3..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*u2OFAxZbiu27nmaCeslJMw.png" /></figure><p>To decide which attribute should be at the root node we can start by looking at <strong>Cough</strong> alone and how well it predicts if a person has the flu. The diagram below has a tree which only takes <strong>Cough</strong> into account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*DQmPD3nLZEY2Ga3t2kpGLA.png" /></figure><p>With the tree above we can <strong>sort</strong> patients who said <strong>yes</strong> and <strong>no</strong> to having a <strong>cough</strong>. In the group that said yes to coughing we can sort them further. We sort them into patients that have the flu and those who don’t. The same can be done for people that said no to coughing. For instance, the second person has a cough and has the flu, so we put them in the left node under Yes. The third person also has the cough and the flu, so they also go in the same left node and are totalled. The fourth person has a cough but <strong>does not </strong>have the flu. This person goes into the left node but under “No”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*S4byQQs8X2rNhJv4qm73uw.png" /></figure><p>Ultimately, we continue this process for all 200 patients. We do this for <strong>Fever</strong> as well as <strong>Tiredness.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*j7WkOMGSLd17P_wlO_cRhw.png" /></figure><p>But remember our first question: <strong>Which attribute should at the Root Node? </strong>So far we have looked at how each attribute has separated patients with and without the flu. The next step is to decide <strong>which separation is the best</strong>. To do this we will have a look at the <strong>Gini</strong> <strong>impurity score</strong>.</p><p>The Gini impurity is a measurement of the likelihood of <strong>incorrect classification</strong> of a new instance of a random variable, if that new instance were <strong>randomly classified according to the distribution of class labels</strong> from the data set. The lower the Gini score the better.</p><h4>Gini Impurity formula:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*y78T1YV8wrb-DPbmNk2rKA.png" /></figure><p>where <em>p</em> is the probability of a certain classification <em>i.</em></p><p>Now let’s calculate the Gini impurity score for “Cough”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*3SMk52FU2a3TrDysEu7dkQ.png" /></figure><p>First we calculate the Gini impurity scores for the leaf nodes using the formula above, which are then used to calculate the Gini impurity for the parent node (Cough). The parent node is calculated using a weighted average approach. We get a Gini impurity score of 0.419 for “Cough. Applying the same process to “Fever” and “Tiredness” we get scores of 0.386 and 0.485 respectively. Notice that “<strong>Fever” </strong>has the<strong> lowest </strong>Gini impurity with a score of 0.386. In other words, “Fever” separates patients with and without flu the best.</p><blockquote>So we will use “Fever” as the Root Node.</blockquote><p>Once we select “Fever” as the root node, we will split the patients into a left and right node. If we focus on the left node for now, we will see that there are a total of 110 patients. Of those 110 patients, 90 have the flu and 20 do not.</p><blockquote><em>Now we have to figure out how well “</em><strong><em>Cough</em></strong><em>” and “</em><strong><em>Tiredness</em></strong><em>” separate these 110 patients in the left node.</em></blockquote><p>We will continue as we did before. We separate these 110 unique patients using “Cough” and “Tiredness” and then calculate their Gini impurity scores. The attribute with the lowest score will be chosen as the node that separates the first left node the best.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*uvngcDnw_vla-jWnFyyIJg.png" /></figure><p>We can apply this process to the right node as well. If the node itself has the lowest score then there is no point in separating the patients anymore and the node becomes the leaf node. This method is applied down the tree until we are only left with leaf nodes.</p><p>In the end we might get something looking similar to this …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*KUU2fsJ3_AO8sSR0eCDh_g.png" /></figure><p>The aim of the blog was to illustrate the intuition behind a “Yes”/”No” decision tree. But what if we had numeric values ?</p><h4>Decision Tree with Numeric Values</h4><p>What if the “Yes”/”No” answers in “Fever” were replaced with actual temperature readings ? How would we compile the tree then? Don’t panic, the process very similar to before. First we sort the values of the attribute in <strong>ascending order</strong> (smallest to largest). Then we compute the average for all adjacent patients. For example, if the first two values were 10 and 20, we’d get the average of those two values (average = (10+20)/2 = 15) and insert the value in between 10 and 20.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*EWeBpqTq7_XhqvnSJwsMjg.png" /></figure><p>Once we have inserted all the averages, we can use the averages to create a tree with a root node and two leaf nodes. In the picture above we have selected the value <strong>37.5 </strong>(average of 37 and 38) and used it as the attribute in the root node. It asks the question: which patients have a fever less than 37.5 degrees celsius? If the answer is Yes (True) then it goes into the left node, otherwise it goes into the right node. Can you see that we follow the same notion as before. After fulfilling our node we must calculate the Gini impurity score for the node (with “Fever &lt; 37.5” as the attribute). To obtain the Gini score we do the same as before: calculate Gini scores for the leaf nodes and then using weighted average methods we get the Gini impurtiy score for the root node.</p><p>This process is done for all averages. The average which returns the <strong>lowest Gini impurity score</strong> is selected to be the cut-off value in the root node or parent node.</p><h3>Building Decision Trees in Python</h3><p>Here we will have a quick look at building a decision tree in Python with the Sklearn package.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVKsZjucxOyWWbEWh1I2hw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@codestorm?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Safar Safarov</a> on <a href="https://unsplash.com/s/photos/code?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong>About the Dataset</strong></p><p>We will be using a cardiovascular disease data set which downloadable from <a href="https://www.kaggle.com/sulianova/cardiovascular-disease-dataset">Kaggle</a>. This data set has 70 000 records of patients data with 11 feature variables and 1 target variable. The target variable is the variable that we would like to predict with our decision tree. In the example in the previous section we had “Flu” as our target variable. In this new data set, the target variable is the presence or absence of cardiovascular disease. This is a binary value, which means that 1 represents presence and 0 represents absence.</p><p><em>Note</em>: In the notebook we do not clean the data. The reason for this is that the purpose of the blog is to illustrate how to run a decision tree classifier and not not show data cleaning techniques. The onus is on the reader to properly clean the data. Data cleaning and preparation is an extremely important phase within the data science world and should not be overlooked.</p><p><strong>Import the necessary libraries</strong></p><pre>import numpy as np<br>import pandas as pd<br>from sklearn import datasets<br>from sklearn.model_selection import train_test_split<br>from sklearn.tree import DecisionTreeClassifier<br>from sklearn.tree import export_graphviz<br>from sklearn.externals.six import StringIO  <br>from IPython.display import Image  <br>import pydotplus</pre><p><strong>Import the data</strong></p><pre>cardio = pd.read_csv(&quot;pathname&quot;, delimiter = &quot;;&quot;)</pre><p><strong>View the data set</strong></p><pre>cardio.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*S9kRnoTRLRhV9qND87G0Og.png" /></figure><p>The “age” variable seems rather strange but it is the respondents age in days (int). The “gender” variable is categorised with a code; Male =2 and Female = 1. The rest of the variable descriptions can be found <a href="https://www.kaggle.com/sulianova/cardiovascular-disease-dataset">here</a>. Next we have to create our <strong>feature</strong> and <strong>target</strong> variables.</p><p><strong>Feature and Target Variables</strong></p><pre># Feature variables <br>X = cardio.drop(&#39;cardio&#39;, axis=1)</pre><pre># Target variable<br>y = cardio[&#39;cardio&#39;]</pre><p><strong>Create Training and Testing Data Sets</strong></p><p>Next step is to split our data into <strong>training</strong> and <strong>testing</strong> data sets. The training data set is used to train/create our decision tree. Then the decision tree is tested on our testing data set to see how well it performs. We use the train_test_split function from Sklearn.model_selection to achieve this.</p><pre># Create the training and test sets<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=123)</pre><p><strong>Instantiate the Decision Tree Classifier</strong></p><p>Here we instantiate the decision tree classifier and set the parameters. All the parameters are detailed <a href="https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.htm">here</a>. We will only go through a few of them:</p><p>1) <strong>Criterion:{“gini”, “entropy”}, default=”gini”:</strong> The function to measure the quality of a split. Supported criteria are “gini” for the Gini impurity and “entropy” for the information gain.</p><p>2) <strong>max_depth: int, default=None:</strong> The maximum depth of the tree. If None, then nodes are expanded until all leaves are pure or until all leaves contain less than min_samples_split samples.</p><p>3) <strong>max_features: int, float or {“auto”, “sqrt”, “log2”}, default=None:</strong> The number of features to consider when looking for the best split.</p><p>When we instantiate our classifier we will choose a max_depth of 4 and use the Gini criterion. A max_depth which is too low may result in an oversimplified tree.</p><pre># Instantiate the classifier: clf<br>clf = DecisionTreeClassifier(max_depth=4, criterion=&quot;gini&quot;)</pre><p><strong>Fit the Classifier to the Training Set</strong></p><pre>clf.fit(X_train, y_train)</pre><p>When running the code above we get an output that looks like this ..</p><pre>DecisionTreeClassifier(ccp_alpha=0.0, class_weight=None,          <strong>criterion=&#39;gini&#39;</strong>, <strong>max_depth=4</strong>, max_features=None, max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, min_samples_leaf=1, min_samples_split=2,<br>min_weight_fraction_leaf=0.0, presort=&#39;deprecated&#39;, random_state=None, splitter=&#39;best&#39;)</pre><p><strong>Predict the Target Variable of the Test Set: y_pred</strong></p><pre>y_pred = clf.predict(X_test)</pre><p><strong>Compute the Accuracy of the Predictions on the Test Set</strong></p><p>The <strong>accuracy</strong> can be defined as the percentage of correctly classified instances.</p><pre>accuracy = float(np.sum(y_pred==y_test))/y_test.shape[0]<br>print(&quot;accuracy:&quot;, accuracy)</pre><blockquote>We obtain an accuracy of <strong>0.7303</strong></blockquote><blockquote>“Not great, not terrible” — Comrade Dyatlov</blockquote><p>The decision tree was able to predict the target variable ( presence of cardiovascular disease) with an accuracy of 0.7303. It’s not a perfect score but it’s significantly better than flipping a coin ( 0.50 accuracy). To improve this score we could use a grid search to fine tune our parameters or preprocess our data. A grid search iteratively goes through each parameter and returns the parameters which result in the best model fit according to some evaluation metric.</p><p><strong>Visualise the Decision Tree</strong></p><pre>dot_data = StringIO()</pre><pre>export_graphviz(clf, out_file=dot_data,  <br>                filled=True, rounded=True,<br>                special_characters=True, feature_names = X.columns,class_names=[&#39;0&#39;,&#39;1&#39;])<br>graph = pydotplus.graph_from_dot_data(dot_data.getvalue())  <br>graph.write_png(&#39;cardio.png&#39;)<br>Image(graph.create_png())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0WZcNhStNDpuKvKPdEXuw.png" /></figure><h3>Conclusion</h3><p>Decision trees are very easy to interpret and visualise. They also do well in capturing non-linear patterns and they don’t require as much data preprocessing as some other machine learning algorithms. However, as good as decision trees are, they also have their drawbacks. A small change in the data can cause a large change in the structure of the decision tree causing instability. Furthermore, decision trees can sometimes go far more complex in terms of calculations when compared to other algorithms. We often see that other algorithms can achieve a higher accuracy with the same data, so use with caution.</p><p>The notebook to this section can be found in my <a href="https://github.com/lukazambuca/Projects/blob/master/Decision_Tree.ipynb">GitHub</a>.</p><p><em>References</em></p><p><a href="https://www.youtube.com/watch?v=7VeUPuFGJHk">StatQuest with Josh Stamer</a></p><p><a href="https://www.hackerearth.com/practice/machine-learning/machine-learning-algorithms/ml-decision-tree/tutorial/">Decision Tree Tutorials &amp; Notes | Machine Learning | HackerEarth</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b636cd94ee0" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/how-does-a-decision-tree-work-3b636cd94ee0">How Does a Decision Tree Work?</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>