What does support Vector machine (SVM) mean?

Please explain Support Vector Machines (SVM) like I am a 5 year old So I want to share it with you. (If there is a mistake welcome to advise!)

The SVM is what?

Support Vector Machine (SVM). Look at the wiki first, of course.

Support Vector Machines are learning models used for classification: which individuals in a population belong where? So... howdo SVM and the mysterious “kernel” work?
Copy the code


Well, here’s the story:

On valentine’s Day a long time ago, the warrior had to save his lover, but the devil played a game with him. The devil seemed to regularly place two colored balls on the table and said, “You divide them with a stick? Requirement: Try to put more balls in and still apply.” . Article details address: www.botvs.com/bbs-topic/6…

  • Let’s use Python to implement a SVM classifier to predict buying and selling


The program is based on the inventor’s quantitative platform, and the subject matter is electronic currency, because electronic currency is suitable for backtesting. The sklearn machine learning library is a simple strategy for Python learning. The sklearn machine learning library is a simple strategy for Python learning.

numpy pandas TA-Lib scipy statsmodels sklearn cvxopt hmmlearn pykalman arch matplotlib
Copy the code

Firm need to be managed machine installation strategy requires libraries, strategy source address: www.botvs.com/strategy/21…

from sklearn import svm
import numpy as np

def main():
    preTime = 0
    n = 0
    success = 0
    predict = None
    pTime = None
    marketPosition = 0
    initAccount = exchange.GetAccount()
    Log("Running...")
    while True:
        r = exchange.GetRecords()
        if len(r) < 60:
            continue
        bar = r[len(r)-1]
        if bar.Time > preTime:
            preTime = bar.Time
            if pTime is not None and r[len(r)-2].Time == pTime:
                diff = r[len(r)-2].Close - r[len(r)-3].Close
                if diff > SpreadVal:
                    success += 1 if predict == 0 else 0
                elif diff < -SpreadVal:
                    success += 1 if predict == 1 else 0
                else:
                    success += 1 if predict == 2 else 0
                pTime = None
                LogStatus("Number of predictions", n, "Number of successes", success, "Accuracy :".'%.3f %%' % round(float(success) * 100 / n, 2))
        else:
            Sleep(1000)
            continue
        inputs_X, output_Y = [], []
        sets = [None, None, None]
        for i in xrange(1, len(r)-2, 1):
            inputs_X.append([r[i].Open, r[i].Close])
            Y = 0
            diff = r[i+1].Close - r[i].Close
            if diff > SpreadVal:
                Y = 0
                sets[0] = True
            elif diff < -SpreadVal:
                Y = 1
                sets[1] = True
            else:
                Y = 2
                sets[2] = True
            output_Y.append(Y)
        if None in sets:
            Log("The sample size is too small to predict...")
            continue
        n += 1
        clf = svm.LinearSVC()
        clf.fit(inputs_X, output_Y)
        predict = clf.predict(np.array([bar.Open, bar.Close]).reshape((1, -1)))
        pTime = bar.Time
        
        Log("Forecast current Bar end :", bar.Time, ['rose'.'down'.'cross'][predict])
        if marketPosition == 0:
            if predict == 0:
                exchange.Buy(initAccount.Balance/2)
                marketPosition = 1
            elif predict == 1:
                exchange.Sell(initAccount.Stocks/2)
                marketPosition = -1
        else:
            nowAccount = exchange.GetAccount()
            ifmarketPosition > 0 and predict ! = 0: exchange.Sell(nowAccount.Stocks - initAccount.Stocks) nowAccount = exchange.GetAccount() marketPosition = 0elifmarketPosition < 0 and predict ! = 1:while True:
                    dif = initAccount.Stocks - nowAccount.Stocks
                    ifDif < 0.01:break
                    ticker = exchange.GetTicker()
                    exchange.Buy(ticker.Sell + (ticker.Sell-ticker.Buy)*2, dif)
                    while True:
                        Sleep(1000)
                        orders = exchange.GetOrders()
                        for order in orders:
                            exchange.CancelOrder(order.Id)
                        if len(orders) == 0:
                            break
                    nowAccount = exchange.GetAccount()
                marketPosition = 0
            ifmarketPosition == 0: LogProfit(_N(nowAccount.Balance - initAccount.Balance, 4), nowAccount) ``` <br> [reading] (HTTP: / / https://quant.la/Article/View/33/%E7%94%A8Python%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AASVM%E5%88%86%E7%B1%BB%E5%99%A 8%E7%AD%96%E7%95%A5.html)Copy the code