<jupyter_start><jupyter_text>Load data<jupyter_code>data = onp.array(pd.read_csv("../skgaip/wind/MS_winds.dat", names=list(range(57))))
# Columns = 57 stations
# Rows = wind speed readings (m/s)
data
# Normalization
# NOTE: This is a bug; they claim this normalizes from 0 to 1, but it doesn't
# NOTE: Their variable also refer to min and max as mean and std, respectively so...
data = (data - data.min()) / data.max()<jupyter_output><empty_output><jupyter_text>Load stored inputs/outputs for verifying<jupyter_code>inputs = pickle.load(open("../skgaip/wind/input.pkl", "rb"))
outputs = pickle.load(open("../skgaip/wind/output.pkl", "rb"))
pre = pickle.load(open("../skgaip/wind/pre.pkl", "rb"))
post = pickle.load(open("../skgaip/wind/post.pkl", "rb"))
minmax = pickle.load(open("../skgaip/wind/minmax.pkl", "rb"))
models = pickle.load(open("../skgaip/wind/models.pkl", "rb"))["models"]<jupyter_output><empty_output><jupyter_text>Verify inputs<jupyter_code>from timecast.utils import historify

historified = historify(jnp.asarray(data), num_histories=8375, history_len=12)
onp.testing.assert_array_almost_equal(historified, inputs["result"])
onp.testing.assert_array_almost_equal(historified[:6000], inputs["X_train"])
onp.testing.assert_array_almost_equal(data[12:6012,:], inputs["y_train"])
onp.testing.assert_array_almost_equal(historified[6000:6361], inputs["xTest"])
onp.testing.assert_array_almost_equal(data[6012:6373,:], inputs["yTest"])<jupyter_output><empty_output><jupyter_text>Verify predictions<jupyter_code># Copied from https://github.com/amirstar/Deep-Forecast/blob/4dcdf66f8ae3070ab706b30a6e3cf888f36e0536/multiLSTM.py#L210
def predict(X, models):
    results = onp.zeros_like(onp.zeros((X.shape[0], X.shape[2])))
    
    for ind in range(len(X)):
        modelInd = ind % 6
        if modelInd == 0:
            testInputRaw = X[ind]
            testInputShape = testInputRaw.shape
            testInput = onp.reshape(testInputRaw, [1, testInputShape[0], testInputShape[1]])
        else:
            testInputRaw = onp.vstack((testInputRaw, results[ind-1]))
            testInput = onp.delete(testInputRaw, 0, axis=0)
            testInputShape = testInput.shape
            testInput = onp.reshape(testInput, [1, testInputShape[0], testInputShape[1]])
    
        pred = models[modelInd].predict(testInput)
        results[ind] = pred

    return results
pred = predict(inputs["xTest"], models)
onp.testing.assert_array_almost_equal(pred, outputs["pred"])
test_true = data[6012:6373,:] * minmax["max"] + minmax["min"]
test_pred = outputs["pred"] * minmax["max"] + minmax["min"]
jnp.absolute(test_true - test_pred).mean(axis=0).mean()<jupyter_output><empty_output><jupyter_text>Predict all data<jupyter_code>historified.shape
pred = predict(historified, models)
pred.shape
historified.shape
true = data[12:]
true.shape
jnp.absolute(true - pred).mean(axis=0).mean()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1566678093932122, 'fraction_numerical': 0.030853616729516628, 'mean_word_length': 5.316017316017316, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '375100', 'license': 'MIT', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1046, 'n_words': 165, 'path': 'notebooks/2020-04-29 Replicate wind.ipynb', 'repo_name': 'danielsuo/toy_flood', 'size': '2917'}