PINE LIBRARY

azLibKnn - PV

27
Library "azLibKnn"
Provides functions to use a classification algorithm (KNN) to make classifications or predictions about the grouping of an individual data point.

featurize(src, flb, clb)
  Adapts the given source into a KNN Feature based on the feature and classification lookback settings.
  Parameters:
    src: (series float) Source. The value series to calculate the feature from.
    flb: (simple int) Optional. Feature Lookback. Specify how many periods to include from the source series. Default is 1.
    clb: (simple int) Optional. Classification Lookback. Specify which periods to include from the source series. Default is 1.
  Returns: (series float) Calculated feature value. In this case the average source value in the feature lookback period.

classify(srcOpen, srcClose, clb, cb, summarize)
  Get calculated classification from given open and close price sources based on classification lookback and base settings.
  Parameters:
    srcOpen: (series float) Source Open Prices. The open price series to be used in the classification calculation.
    srcClose: (series float) Source Close Prices. The close price series to be used in the classification calculation.
    clb: (simple int) Optional. Classification Lookback. Specify which periods to include from the source series. Default is 1.
    cb: (simple string) Optional. Classification Base. Specify how to calculate the classification. Default is 'PRICEDIFF'.
    summarize: (simple bool) Optional. Summarize. Specify if the classification needs to be summarized to 0 (NEUTRAL), 1 (BULL), -1 (BEAR) or that the raw classification value needs to be used. Default is false (raw value).
  Returns: (series float) Calculated (optionally summarized) classification value.

train(features1, features2, classifications, f1, f2, c, max, maxMode)
  Stores the combination of features and classification to the KNN Model.
  Parameters:
    features1: (series array<float>) Id of Features 1 array.
    features2: (series array<float>) Id of Features 2 array.
    classifications: (series array<float>) Id of Classifications array.
    f1: (series float) New Feature 1 value to add to the model.
    f2: (series float) New Feature 2 value to add to the model.
    c: (series float) New Classification value to add to the model.
    max: (simple int) Optional. Specify the maximum model size. Default is 240.
    maxMode: (simple string) Optional. Specifies the mode to use when the model reaches the maximum size. Default is FIFO.

predict(features1, features2, classifications, p1, p2, k)
  Make a prediction based on parameter 1 and parameter 2, finding k nearest neighbours and use their classifications
  Parameters:
    features1: (series array<float>) Id of Features 1 array.
    features2: (series array<float>) Id of Features 2 array.
    classifications: (series array<float>) Id of Classifications array.
    p1: (series float) Parameter 1 value to calculate distances from.
    p2: (series float) Parameter 2 value to calculate distances from.
    k: (simple int) Optional. Specify k nearest neighbours. Use odd value to avoid draw decissions. Default is 27.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.