Posts

Showing posts from 2019

Predict EPL results (Part 2: Neural Network example)

Image
Neural Network explained Artificial Neural Network is a model that receives input in vector/matrix form and uses them to compute the output  It is made up of 3 different layers namely input layer, hidden layer and output layer.  Each layer is made up of 1 or more artificial neurons (aka nodes)  The nodes are interconnected with one another Each node is assigned to a weight value denoted by  w  that determines how much emphasis is given to the learned information extracted from the raw training data  Note: A   Neural Network with 1 hidden layer is known as  Shallow Neural Network Types of Neural Networks Feedforward Neural Network Convolutional Neural Network (CNN) Recurrent Neural Network - Long Short Term Memory (LSTM) Networks Recursive Neural Network Neural Network Architecture The figure below shows a  Neural Network Architecture  that is made up of n  features,  h  hidden layers and ...

Install Python, Numpy, Matplotlib and Scipy on Windows

Image
Step-by-Step Guide 1) Download Python Go to Python website  From the 'Download' tab, select the Operating System (OS)  Then, click on the Python version that you want to download Select the Operating System and Python version For Windows users, download ' Windows x86-64 executable installer ' Select the file 2) Install Python After the file has downloaded, click on it On the Setup page, select the 'Add Python 3.7 to PATH' Python Setup Page Once the installation is done, click on 'Modify' to add or remove features Modify Setup Select the features that you want to download and choose the install location. Then click 'Install' Download additional features 3)  Install Numpy From the command prompt, change to the install location of the Python Key in the command 'pip install numpy' Install Numpy 4) Install Matplotlib Key in the command 'pip instal...

How to connect Python to MySQL Workbench

Image
Step-by-Step Guide 1) Download MySQL: For Windows user , you can download  MySQL Installer that allows you to install all the products in one package. Link as follows https://dev.mysql.com/downloads/windows/installer/8.0.html Download MySQL Installer (For Windows only!) Begin download Otherwise, you can download the product 1 by 1  (Remember to select your Operating System for all!) MySQL Workbench  MySQL Connector / Python   (Note: You have to download Python first. And remember to select the OS and Python version!) MySQL Community Server For Windows users... 2) How to setup MySQL Installer We are going to show how to download and install MySQL Community Server only... Double click the file and install it Once it has finished installing, you will see this window below and click on the 'Add' option Click 'Add' option Agree on their License terms and click 'next' Agree on License Terms Selec...

Easiest way to crawl data out from a web page in Python

Image
Tried & Tested This post tells you how to crawl / extract / scrape data from a web page in an easy and proven way.... Data Claw Machine Let's say we want to stay updated to all the latest news of EPL. But we don't have time to read through all the articles. So, we think of getting the titles of the featured news in the EPL web page. Step-by-Step Guide 1) Launch Anaconda Navigator  2) Launch Jupyter  Launch "Jupyter" in Anaconda Navigator 3) Create a new Python notebook Create new Python notebook 4) Import all the libraries Import libraries 5) Get the URL of EPL web page Get URL 6) Use BeautifulSoup to parse the web page Make soup to parse the web page 7) Check the HTML structure of the web page Check the HTML  structure 8)   Use BeautifulSoup to crawl all the "Featured Articles"  find_all will look into every section in the HTML script that has the class "featuredAr...

Predict EPL results (Part 1: Logistic Regression Example in Python)

Image
Logistic Regression It estimates the probability of an outcome (aka dependent variable) based on a set of one or more input (aka independent variables or "features") Can be used for binary classification problem (only 2 possible outcomes) or multiclass classification problem (more than 2 outcomes) For example, it can be used to predict the chances of a particular transaction is fraud given some input information like the customer's details, transaction details etc.  If there are more than 2 outcomes like the EPL game (i.e. win, draw and lose), logistic regression also can be used as it can determine the possibilities of each outcome.  Logistic Regression Function is defined as follows: Logistic Regression Function Note: f(x) represents the probability of an output y  given each input x .  From the formula above, it tells us that it can take in any input x (positive or negative) and produce an output y in the range of 0.0 to 1.0.  Back to...

What's next after Deep Learning courses?

Well...for the past weeks, we have been rushing to complete the Andrew Ng's Deep Learning module so that we can complete it in a month.  About Andrew's Ng Deep Learning @ Coursera: For those who do not know, there are 5 courses for this Deep Learning module and each course will take about a few weeks to complete. You will have to input your credit card details before you can access the 7-days free trial for this module. Pretty smart way to lock in customers uhhh...Anyway, after the free trial period, if you wish to continue, you have to pay USD 49 per month. Otherwise, REMEMBER to 'un-enroll' the course.   https://www.coursera.org/specializations/deep-learning Confessions To be honest, we have only completed 99% of the module as  we didn't do the last programming assignment  😳. Why didn't we continue? Initially, we were very motivated to finish the whole module since we have already prepaid for the first month and we wanted to setup our AI busi...

Support Vector Machines (SVM)

From Week 7 of the lesson... Didn't really get what is Support Vector Machines (SVM) initially so went to google up a bit and watch some videos.  Summary: It is a supervised learning models used to analysis regression or classification problems Divide the classes of the data by a clear gap (aka "hyperplane") that is as wide as possible Can be used to classify multi-dimensional data thus the classifier is known as "hyperplane" Recommended Videos: Support Vector Machine (SVM) - Fun and Easy Machine Learning (7 mins): by Augmented Startups https://www.youtube.com/watch?v=Y6RRHw9uN9o  Support Vector Machines - The Math of Intelligence (Week 1) (30 mins); by Siraj Raval https://www.youtube.com/watch?v=g8D5YL6cOSE Learning: Support Vector Machines (49 mins): by MIT OpenCourseWare https://www.youtube.com/watch?v=_PwhiWxHK8o Also learnt about Gaussian Kernel ... It is used when there is a non-linear decision b...

Bias and Variance in Machine Learning

Sorry for the lack of updates...Have been rushing to complete the Machine Learning course as fast as possible... Good news!!! We managed to survive through the whole course!!!! Hahaha Summary of Week 6 lesson: Some definitions first before delving into the details... Bias:  The hypothesis is known to be biased if it tends to overestimate or underestimate a parameter Variance:  The hypothesis is known to have high variance if the data are far away from its average value Given the complexity of some data, a linear regression may not be able to formulate an accurate prediction. As the linear regression only factors in 1 specific feature of the data, the 'best-fit' line does not fit the data well enough. Such under-fitting problem leads to high training costs and also causes the hypothesis to be biased. Ways to reduce the bias: Add more features / Increase the degree of the polynomial Decrease λ  Use larger neural network As mentioned a...

Neural Network explained

Week 4 & 5 of the Machine Learning course delve into Neural Network Model. A Neuron Model contains a logistic unit that produces output based on the given inputs. Typically, a bias unit is included and it is set to 1. Note that the hypothesis used is based on the Logistic Regression Model. The  Neural Network Model consists of "Input" layer, "Hidden" layer and "Output" layer. "Input" layer Number of nodes = Number of features "Hidden" layer It is made up of 1 or more "Activation" units. "Output" layer Number of nodes = Number of classes More "Hidden" layers can be added to achieve better results. However, this results in higher computational costs. Random initialization is necessary for the initial value of theta (i.e. the "weights" of a specific "Activation" unit for each input). This breaks the symmetry of the matrix so that all the values of the "Activa...

Logistic Regression Model for classification problem

Week 3 of the Machine Learning course, we learnt about Logistic Regression Model . Classification problems can be binary or multi-class. A decision boundary that can be either linear or non-linear is used to classify the inputs of such problem. For the multi-class classification, we can use "1 versus all" method that choose one class and then lump others into a second class then apply binary logistic regression to each case until a minimum value is achieved.  Tip: Don't use linear regression for the classification problem as it may give hypothesis that exceed the range. Instead, use Logistic Regression Model that uses sigmoid / logistic function that always produce hypothesis between 0 and 1.  The hypothesis produced by  Logistic Regression Model is always in terms of probability of the inputs being in a specific class while the hypothesis produced by linear regression is based on an output value (e.g. price of housing property). Hence, Cost function in...