Matrix Madness

Linear algebra is an important tool used in modern deep learning algorithms. Unfortunately, when I did my undergrad in Electrical and Computer Engineering, I had no idea that the ability to transform vectors and matrices would ever be practicably useful for anything (other than giving me migraines at 2AM the night before my midterm exams). So, once I had learned enough to pass the course, I immediately forgot everything.

It was only when I decided to pursue a deeper understanding of machine learning and AI, in order to apply it to my business and to my work in finance, that it dawned on me. I should have paid attention in Linear Algebra II when I was back at the UofA in Engineering school! Well, since I didn’t, and even if I did, all my books on the subject mysteriously burned up in the great notes fire of ’09, I guess it’s time to re-learn me some matrix math.

Lucky for me, Udacity has brought on some of the best professional educators in the world for their AI Nanodegree program including former Khan Academy animator and 3 Blue 1 Brown creator, Grant Sanderson.

So, now I’m super good at manipulating matrices thanks to the magic of a YouTube superstar and the LaTeX plugin for WordPress websites.

A = \begin{bmatrix} a_{11} & \cdots & a_{1j} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots & \ddots & \vdots \\ a_{i1} & \cdots & a_{ij} & \cdots & a_{in} \\ \vdots & \ddots & \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mj} & \cdots & a_{mn} \end{bmatrix}

…I spent 30 minutes trying to get this matrix to display correctly.

If you want to learn why vectors are cool and how to use matrix multiplication to rule the world, watch the video series that I’ve linked below.

We haven’t arrived at the part about why Linear Algebra is so important for creating neural networks and deep learning algorithms, but we will. If you’re still with me, keep plugging along, learn how to understand all matrix transformations using only the unit vector and a 2×2 matrix. Eventually, we’ll discover how to program a computer to predict Apple’s  share price the day after they launch a ‘new’ iPhone

/insert corny iPhone XS Max joke here/.

  • Loading stock data...

That’s all for today. Now go out on your own and learn the basics of linear algebra! If you message me directly, I’ll even send you my notes. Tomorrow, we’ll talk about why this stuff is important for machine learning.

Linear algebra joke: One year for halloween I was ‘Snakes on a Plane’

If you’re still here and you’re wondering why yesterday we were talking about valuing a company and today we’re talking about undergraduate linear algebra, you’re probably not alone. So I’ll tell you why: It’s going to take a foundational understanding of programming, mathematics and finance to get where we need to go. To understand machine learning, we have to understand how the software is built and to build software that is capable of doing what a CFA can do, we’ll need to know what a CFA knows. I’m bringing you along on this journey as I learn the fundamentals on both ends, machine learning and finance. Let’s see how it goes!

Do you get it now?

How to Value a Business (Or a Project)

The best-kept secret of financial professionals is that it’s actually pretty easy to value a company, that is, decide how much you should be willing to pay for the business or its shares. My goal is to automate this process using machine learning algorithms to select the appropriate data and apply the formulas in the correct manner. This level of sophistication is still a few months (years?) away, at least by my skillset. For now, we’re going to cover the basics of project valuation via the discounted cash flow (DCF) methodology. Later on, we’ll see if we can get a computer to do the calculations for us.

Note: I’ll be using the terms company and project interchangeably here. However, for companies in more than one industry or market segment, you’ll need to use multiple discount rates because the Beta (systematic risk of the segment divided by the market risk) will vary depending on the industry.

You can probably find a lot of the information that I’m about to disclose (or all of it) in an introductory finance textbook or even from a free resource like Investopedia. That’s fine. Lots of people do not choose to read textbooks or financial-wiki sites in their free time, so I’m going to go over the basics here if you’re interested in the subject, but not quite interested enough to open a book.

Here we go. Are you ready?

All that is needed to value a company is:
    1.  Some revenue projections,
    2.  Some cost projections,
    3.  An appropriate discount rate (or cost of capital) for the company

That’s it!

Obviously, these things can be easy or very difficult to come by depending on several factors including the type of company (or project), the stability of the market, and the quality of the information available about the business.

Let’s assume //quite a big assumption, but hey, that’s what we’re going to do right now// that you’re able to come up with some reasonable revenue and cost projections for the business that you want to value and that you’re able to calculate an appropriate WACC (Weighted Average Cost of Capital) or discount rate.

Then what do you do?

Basically, you take the company’s projected revenue over a given period (let’s say every year for 5 years), subtract the cash costs on the business in each year and you’ve got the company’s Free Cash Flows (we’re skipping a few steps here like subtracting taxes, adding back depreciation, and subtrac

ting Capital Expenditures (CapEx) and changes in Net Working Capital, but we’ll save those for later).

Here’s an example of a company with some projected revenue and some projected costs going out 5 years:

Year 0 1 2 3 4 5
Revenue $20,000 $20,000 $20,000 $20,000 $20,000
Costs ($50,000) ($5,000) ($5,000) ($5,000) ($5,000) ($5,000)
Cash Flows ($50,000) $15,000 $15,000 $15,000 $15,000 $15,000

Next, we take the free cash flows that we calculated above, and we discount each of them by an appropriate ‘discount factor’ that we calculate using our discount rate.

Where: r is the discount rate and n is the period (or year)

All of my finance professors are about to roll over in their beds right now (they’re not dead), but let’s say the discount rate that we found for the company is 10%. Here’s what we end up with for the discount factor over the 5-year period.

Year 0 1 2 3 4 5
Revenue $20,000 $20,000 $20,000 $20,000 $20,000
Costs ($50,000) ($5,000) ($5,000) ($5,000) ($5,000) ($5,000)
Cash Flows ($50,000) $15,000 $15,000 $15,000 $15,000 $15,000
Discount Factor         1.00        0.91        0.83        0.75        0.68        0.62
Discount Rate 10%

Now we just multiply our free cash flows by the discount factor for each year to get the present value (PV) of the future cash flows. Once we have the PV of the cash flows, we can add them all together to find out what the project is worth to us, also known as the project’s NPV or Net Present Value.

Year 0 1 2 3 4 5
Revenue $20,000 $20,000 $20,000 $20,000 $20,000
Costs ($50,000) ($5,000) ($5,000) ($5,000) ($5,000) ($5,000)
Cash Flows ($50,000) $15,000 $15,000 $15,000 $15,000 $15,000
Discount Factor               1.00              0.91              0.83              0.75              0.68            0.62
PV Cash Flows ($50,000) $13,636 $12,397 $11,270 $10,245 $9,314
Project NPV $6,862
Discount Rate 10%

If you want a primer on what present value means, and what the time-value of money represents, here’s a good video on it from Khan Academy:

That’s it! We’ve valued a business. We now know that if this company was only going to operate for five years, and then cease to exist, that it would be worth about $6,800 to us in our pocket today.

In general, we accept projects that have a positive NPV and reject projects that have a negative NPV. I’ll cover the reasons for this in another post down the line. For now, at least, we are able to value a company given only its revenue, costs, and an appropriate discount rate. Things are going to get a lot more complicated from here so enjoy the simplicity while it lasts.

Python Is Awesome

If you’ve ever looked into what it takes to become a developer of AI software, you probably know that Python is the language of choice for 95% of Machine Learning applications out there.

So, why Python? It’s not super easy to learn. Students can learn graphical programming languages like Apple’s Swift much faster. It’s not the speediest. There are other programming languages that are better optimized to develop the GPU and CPU intensive tasks that Machine Learning software requires. Unfortunately, it’s not even the most ubiquitous (for applications outside of machine learning and data science). Many programmers are much more familiar with Javascript for web development. It is free, so it does have that going for it.

Here’s what Quora has to say about it:

“…it is a general language that does a little of everything at a good enough complexity-performance tradeoff with a full suite of tools for productionizing machine learning.”

Thia Kai Xin, Head of Data (Tech In Asia), Co-Founder of DataScience SG.

Essentially, Python is effective enough to get the job done. Major companies like Google, Facebook, and Uber all use Python for the majority of their ML software development, so that helps. If you want a job at a major tech company, and you want to develop artificial intelligence applications, you’ll probably need to understand Python pretty well.

So, what can Python do? It’s built on an open-source licence, so there’s no need to worry about licensing fees. Python comes pre-installed on all Apple desktops and can be easily installed on Windows or Linux builds. The latest version of Python (Python 3.7) can be easily integrated with mathematical packages like NumPy and with clever development visualization tools like Jupyter Notebooks.

“The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.”

Project Jupyter – jupyter.org

There are many, many online and in-person courses available that teach Python, including many free and low cost options. Udacity offers a free intro to Python course that you can sign up for right now. 

Python is easy to learn and powerful. It’s accessible to pretty much anyone with a computer and there are lots of ways to get started. Here’s an example of what you can do with Python in only a few days of practice:

Using only freely available libraries and packages, along with some tutelage from Udacity’s AI Programming Fundamentals program, a student can learn to program a deep-neural-net, a type of machine learning tool, that is able to distinguish images of various types of animals, including dog breeds, with a high degree of accuracy. That’s pretty amazing. Someone with limited programming experience can learn how to build their own AI program in less time than it takes to fail your first University midterm.

If you’re interested in programming these types of tools or if you’re curious about how they work, I highly suggest you head over to the 3 Blue 1 Brown YouTube channel and watch his videos on Neural Networks. The animations are world-class and the topics are simplified enough to be understood but still cover the topic in great depth. I’ve linked the first video in the series below and I can’t recommend the channel enough.

So where is this all going and what applications does this have for people in finance?

Using the tools described above, I have already created software that tracks the share price of several tech giants and tries to predict their short-term market performance. Mind you, I have about a decade of software development experience, but nearly all of my experience is outside of the machine learning space.

Python is a great tool for experienced programmers and beginners alike to build some amazing software. Try it out for yourself, and when you get hooked, don’t blame me when you inevitably find yourself up past midnight solving the world’s problems one line of code at a time.

What is Collective Intelligence?

Something fascinating to me about the world is how so many billions of people can act for their own self interests, and yet we’re all able to eat. Fewer and fewer of us are dying from preventable illnesses and medical technology has evolved to a point where we’re thinking about extending and enhancing human life past a century.

Collective intelligence describes the apparatus by which groups of individuals act collectively in ways that seem intelligent. For centuries, at least around 8000 years, humanity has demonstrated some form of collective intelligence. We’ve formed civilizations, shaped the landscape around us, and even touched the surface of the moon. However, recently, the definition of collective intelligence is expanding to include non-human machines. The whole is becoming more than the sum of its parts and that whole contains robots.

Many people, including very smart people like Elon Musk and the late Stephen Hawking, are afraid of the impending artificial intelligence revolution. They’re scared that once the proverbial chicken has hatched, and we create an AI that can act on its own, we may already be too late to stop it. There’s a great article that a friend shared with me about how a simple handwriting robot could cause the death of all life on earth and eventually the entire observable universe, check it out here. So, there’s no shortage of doom and gloom abound about artificial intelligence and why it’s going to pee in our cheerios and make us all subservient to its whims #hailSkynet. Luckily, not everyone is so negative about the prospects for AI. In fact, there’s one way that even if the experts are right, and we can’t beat a true AGI (artificial general intelligence), we may be able to become one ourselves. 

The MIT Center for Collective intelligence is an organization devoted to exploring how people and computers can be connected so that – collectively – they act more intelligently than any person, group, or computer has ever done before.

That’s the answer! If we are afraid that AI is going to destroy us, we have to merge with it before it can. The good news is that there is a lot of evidence to suggest that Humans + Computers >> Computers alone. 

Leaving the negativity behind, many experts are demonstrating that Artificial Intelligence will help improve millions of lives. It will create meaningful work for people and let us focus on what we’re great at instead of what we must do to survive. Companies in industries ranging from Finance to Transportation, to Medicine, are using AI to make life better for their customers, and for their employees. Let’s hope that this trend continues.

I’ll be working on finding applications in my business for artificial intelligence, specifically one narrow piece of it, machine learning. I’m going to take you along with me as I dive into the conceptual and technical aspects of the technology. We’ll be learning together and exploring how existing AI can be used in business while beginning to understand how to create new AIs from the ground up. So far, I’ve learned to program with Python and I’ve even created software that uses convolutional neural networks able to identify images of certain animals (mainly dogs) and classify them into breeds with surprising accuracy. Soon I’ll be using these techniques to create financial modelling software to predict some market movement and make trades. If you are interested in joining me on this journey, sit back, grab a coffee, or a beer, and let’s get smarter together!

What is this about?

My name is Rosario Fortugno. I’m an electrical engineer, MBA, and clean-tech entrepreneur making my way into the worlds of finance and AI. 

This website is meant to provide some insight into my journey. My hope is that it communicates some of what I learn as I pursue my CFA (Chartered Financial Analyst) designation, highlighting examples from my business, as well as what I’m learning through the courses I’m taking in AI and machine learning from MIT and Udacity.

Basically, this is a way for me to show off my knowledge to the world… 

Every day, I’m going to summarize what I’ve learned. The source of the material will either be from my CFA prep material, my own business, InOrbis Intercity, my MIT and Udacity AI courses,  or just something I picked up along the way.

You’ll get a deep dive into the inner workings of my mind. The mind of a person who is probably trying to do too many things at once, but who is going to try to do them anyways, because, What the heck! Right?

Not only will you be learning alongside me, you will be joining me as I wade neck-deep into two of the most confusing and challenging spaces that the 21st century has to explore: artificial intelligence, and financial analysis.

A lot of what I discuss will be sourced from my other courses, so I’ll always try to provide links and images for reference to the source material. While I’ve always considered myself to be relatively creative, my propensity for original thought is limited by my expertise, so where I share something that isn’t my own work, I will try to give credit where credit is due.

Here we go! Let’s dive right in and get started. Today’s topic is Understanding Machine Learning. An undoubtedly simple subject. Let’s see how it goes 😀