Machine Learning Practice: Learning Taiwan Stock Index Trends with Scikit (Part 1) – Machine Learning 101
Machine learning is a statistical analysis method. Put simply, the problems it can handle fall roughly into four categories: classification, regression, clustering, and rule extraction.

Don’t worry! This one is all substance, no fluff—and no more Ctrl + C stuff, I promise.

Machine learning is a statistical analysis method. The core idea: we give it a pile of data and ask it to give us a result.
That result might be the exact answer we want (for example, turn left or turn right), or it might be some abstract concept that we then use to classify things.
Put simply, the problems machine learning can handle fall roughly into four categories: classification, regression, clustering, and rule extraction.
1. Classification: We train the machine learning model on a set of data with known answers, for example: X = [0,2,3,3,4,5,6,7,8] Y = Taipei X = [0,7,3,3,4,5,6,7,8] Y = Kaohsiung X = [0,4,3,3,4,5,6,7,8] Y = Taichung X = ... We feed it tons of phone numbers, and the answers are their area codes. We expect the model to learn to tell which city a phone number belongs to just by looking at it. That’s a classification problem. Once the model is trained, we feed it X = [0,2,1,2,3,4,5,6,7,8] If the model answers Taipei, it has learned successfully! 2. Regression: We train the machine learning model on a set of data with known answers, for example: X = [0,1,2,3] Y = 12 X = [0,3,4,2] Y = 22 X = [0,1,1,1] Y = 23 X = ... We feed it tons of random number strings, and the answer is the sum of each string. We expect the model to learn to return a number whenever it sees a string of random numbers. To explain: the biggest difference from classification is the prediction. When the prediction is continuous, it’s a regression problem. When the prediction is discrete, it’s a classification problem (or something else). For a real-world regression example, click this link: it uses river water levels and rainfall from the past six hours to predict the water level two hours later. 3. Clustering: Give the machine learning model a pile of data with no known answers, plus some grouping logic (such as point-to-point distance), and let it sort the data into groups. EX: Facebook face recognition 4. Rule Extraction This one is more abstract. It’s like using analysis to discover rules. Say you throw in 10,000 photos, and after clustering you notice you and your sister always end up in the same group. Then you could reasonably suspect that you and your sister have the same dad and mom. Photo recognition -> blood relation. I’d say that’s roughly what rule extraction is! If that sounds like nonsense, no problem. Suppose you run regression forecasts on sales of 10,000 products and discover that beer and diapers follow the same purchase cycle. Then you could reasonably suspect that people are more likely to have babies after drinking, sales forecast -> drinking leads to babies.
At this point, we basically understand what kinds of problems machine learning can solve.
But the real question is: how does it solve them?
Usually we pick one algorithm, or a combination of several, to tackle the problem at hand. Any algorithm whose results converge is worth a try.
So what algorithms are out there?
1. Regression Algorithms This is the regression method. The water level forecast was solved this way. Of course, there are many specialized regression methods, but we won’t go into them here. 2. Instance-based Algorithms These take facts that have already happened and infer what will happen when a certain sign appears in the future. 3. Clustering Algorithms Grouping: scatter a bunch of points in a space of any number of dimensions, define a Euclidean distance yourself, and whatever clusters together belongs together. Representative algorithms include k-Means and k-Median. 4. Kernel Algorithms Before the big data era, this was the most powerful family of algorithms in machine learning. The best known is the support vector machine (Supported Vector Machine, SVM). The idea is to map the original data into higher dimensions and then classify it. After all, some degree of polynomial function will always split the data perfectly. 5. Ensemble Algorithms I’m quite fond of this one. It learns from the results of various already-trained machines and computes a result once more. Think of it like AlphaGo: it needs to know the state of the board now, the state after the move you just made, and how things will play out after its next move, and uses all of that to decide where to play. 6. Neural Network Algorithms These mimic our nerve cells: feed a pile of data into the neurons, and the neurons respond nonlinearly. 7. Deep Learning This is a kind of mutant variant of neural networks, and it’s the main method we’ll cover next. Picture lots of neurons sending signals into and out of each other, until the whole nervous system outputs a single signal or a category.
Of course, there are many other kinds of algorithms. Basically, just look up the papers when you need them.
Here are some references for anyone who wants to dig deeper.
[1] Practical Machine Learning Problem
[2] A Visual Introduction to Machine Learning (Chinese edition)
[3] Coursera — Machine Leanring








![[Tech Talk] Python 101](/assets/605852e084fb2346c3ea1559/60d97a7ac780931f83b3a365_60a5dbb5df894306f2930b52_manja-vitolic-gKXKBY-C-Dk-unsplash%20(1)-p-1080.jpeg)











