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"n individually most likely next n elements "NextSequence"n most likely next length-n sequence of elements "RandomNextElement" random sample from the next-element distribution "RandomNextElement"n random 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 Automatic which aspect of performance to optimize RandomSeeding Automatic what 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 Automatic automatic tradeoff among speed and accuracy - Possible settings for RandomSeeding include:
-
Automatic automatically reseed every time the function is called Inherited use externally seeded random numbers seed use an explicit integer or strings as a seed
Examples
open allclose allBasic 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:
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)
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:
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