<jupyter_start><jupyter_text><jupyter_code>import logging, sys
logging.disable(sys.maxsize)
!pip install microprediction
!pip install git+https://github.com/kieferk/pymssa.git
from microprediction import MicroReader
mr = MicroReader()
YS = mr.get_lagged_values(name='emojitracker-twitter-winking_face.json')[0:1000]
YS[:5]
from pymssa import MSSA
import pandas as pd 
import datetime 
import numpy as np 
import warnings
warnings.filterwarnings('ignore')

def run(ys):
    burnin = 950

    def next_value(ys):
        mssa = MSSA(n_components='svht',
            window_size=None,
            verbose=True)
        mssa.fit(pd.DataFrame(ys))
        y_hat = mssa.forecast(1).squeeze()
        return y_hat

    y_hats = list()
    for t in range(len(ys)):
        if t > burnin:
            y_hat = next_value(ys[:t])
        elif t >= 1:
            y_hat = ys[t - 1]
        else:
            y_hat = 0
        y_hats.append(y_hat)
    return y_hats
XS = run(YS)
import matplotlib.pyplot as plt
plt.plot(YS[950:],'*b')
plt.plot(XS[950:],'g')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12104283054003724, 'fraction_numerical': 0.017690875232774673, 'mean_word_length': 3.0262172284644193, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '243333', 'license': 'MIT', 'n_tokens_mistral': 428, 'n_tokens_neox': 399, 'n_words': 82, 'path': 'hello_mssa_colab.ipynb', 'repo_name': 'microprediction/microprediction-notebooks', 'size': '1074'}