SequencePredictorFunction

SequencePredictorFunction[]

represents a function generated by SequencePredict that predicts the next elements from a sequence.

Details and Options

  • SequencePredictorFunction works like Function.
  • SequencePredictorFunction[][seq] attempts to predict the next element in the sequence seq.
  • SequencePredictorFunction[][{seq1,seq2,}] attempts to predict all the seqi.
  • SequencePredictorFunction[][seq,prop] gives the specified property associated with seq.
  • In SequencePredictorFunction[][{},prop], {} is interpreted as an empty list of sequences rather than an empty sequence.
  • Sequence seq is assumed to be a subsequence of an unknown infinite sequence.
  • Possible properties include:
  • "NextElement"most likely next element
    "NextElement"nindividually most likely next n elements
    "NextSequence"nmost likely next length-n sequence of elements
    "RandomNextElement"random sample from the next-element distribution
    "RandomNextElement"nrandom sample from the next-sequence distribution
    "Probabilities"association of probabilities for all possible next elements
    "SequenceProbability"probability for the predictor to generate the given sequence
    "SequenceLogProbability"log probability for the predictor to generate the sequence
    "Properties"list of all properties available
  • In SequencePredictorFunction[][,"SequenceProbability"], some probability mass is kept for unknown elements.
  • SequencePredictorFunction[][data,,opts] specifies that the sequence predictor should use the options opts when applied to data.
  • Possible options are:
  • PerformanceGoal Automaticwhich aspect of performance to optimize
    RandomSeeding Automaticwhat seeding of pseudorandom generators should be done internally
  • Possible settings for PerformanceGoal include:
  • "Quality"maximize accuracy of the prediction
    "Speed"maximize speed of the prediction
    Automaticautomatic tradeoff among speed and accuracy
  • Possible settings for RandomSeeding include:
  • Automaticautomatically reseed every time the function is called
    Inheriteduse externally seeded random numbers
    seeduse an explicit integer or strings as a seed

Examples

open allclose all

Basic Examples  (1)

Create a sequence predictor function with SequencePredict and a training set of subsequences:

Use the sequence predictor function to predict the next element:

Obtain the probabilities of the next element given the sequence:

Obtain a random next element according to the preceding distribution:

Obtain multiple predictions at a time:

Predict the most likely next element and reuse this intermediate guess to predict the following element:

Predict the most likely following sequence:

Compare the probabilities for the preceding sequences:

Scope  (4)

Train a sequence predictor on a list of strings:

Predict the next character following a given string:

Predict the next four characters:

Obtain the probabilities for each character to follow the given string:

Train a sequence predictor on the list of common English words, each word treated as a sequence of characters:

Predict the most likely next character from a given sequence:

For the sequence predictor trained in the preceding example, each word is considered as a subsequence of an infinite sequence. Use the character | to mark boundaries between words:

Build a new sequence predictor aware of word boundaries:

Create an English-like word generator trimming once the boundary is found:

Load a book from ExampleData:

Train a sequence predictor on this book at character level:

Sample a random string in the book style:

Train another sequence predictor, interpreting strings as word sequences rather than character sequences:

Complete the preceding string with 10 consecutive words (spaces and punctuation marks are considered as words):

Options  (2)

PerformanceGoal  (1)

Tune the computation time and precision when exploring the full sequence probability space:

Favor fast and approximated exploration:

Favor more in-depth exploration taking longer computation time:

Compare the results:

RandomSeeding  (1)

Create a sequence predictor function with SequencePredict and a training set of subsequences:

Obtain the probabilities of the next element given the sequence:

When obtaining random next elements, they will be sampled from the preceding distribution:

The RandomSeeding option prevents randomness from happening:

Possible Issues  (1)

An empty list is parsed as the list with no sequences inside and will return an empty list:

To obtain the most likely next element completing an empty sequence, nest it in a second list for disambiguation:

Wolfram Research (2017), SequencePredictorFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/SequencePredictorFunction.html (updated 2017).

Text

Wolfram Research (2017), SequencePredictorFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/SequencePredictorFunction.html (updated 2017).

CMS

Wolfram Language. 2017. "SequencePredictorFunction." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/SequencePredictorFunction.html.

APA

Wolfram Language. (2017). SequencePredictorFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SequencePredictorFunction.html

BibTeX

@misc{reference.wolfram_2024_sequencepredictorfunction, author="Wolfram Research", title="{SequencePredictorFunction}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/SequencePredictorFunction.html}", note=[Accessed: 06-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_sequencepredictorfunction, organization={Wolfram Research}, title={SequencePredictorFunction}, year={2017}, url={https://reference.wolfram.com/language/ref/SequencePredictorFunction.html}, note=[Accessed: 06-October-2024 ]}