<jupyter_start><jupyter_text>Create a frame with data that we'll use to train the ARX modelThe frame has columns for the observed value "y" and several other columns that contain exogenous variables (visitors, weekends, seasonality, etc).<jupyter_code>schema = [("y", ta.float64),("visitors", ta.float64),("wkends", ta.float64),("seasonality", ta.float64),("incidentRate", ta.float64), ("holidayFlag", ta.float64),("postHolidayFlag", ta.float64),("mintemp", ta.float64)]
csv = ta.CsvFile("train_atk.csv", schema=schema, skip_header_lines=1)
frame = ta.Frame(csv)
frame.inspect()<jupyter_output><empty_output><jupyter_text>Create and train the modelCreate an ARX model, and then train the model by providing the frame of data, the "y" column, a list of "x" columns, y max lag, x max lag, and a boolean flag indicating if the intercept should be dropped.The ARX model train() return 'c' (an intercept term, or 0 for no intercept) and a list of coefficients (one for each "x" column).<jupyter_code>arx = ta.ArxModel()
y_column = "y"
x_columns = ["visitors","wkends","seasonality","incidentRate","holidayFlag","postHolidayFlag","mintemp"]
y_max_lag = 0
x_max_lag = 0
no_intercept = True
arx.train(frame, y_column, x_columns, y_max_lag, x_max_lag, no_intercept)<jupyter_output>Done [=========================] 100.00% Time 00:00:01
Done [=========================] 100.00% Time 00:00:02<jupyter_text>So, in this example the coefficients are:| x              | coefficient            ||----------------|------------------------|| vistors        | -1.136026484226831e-08 ||wkends          |  8.637677568908233e-07 ||seasonality     |  15238.143039368977    ||incidentRate    | -7.993535860373772e-09 ||holidayFlag     | -5.198597570089805e-07 ||postHolidayFlag |  1.5691547009557947e-08||mintemp:        |  7.409621376205488e-08 | Create a frame that contains test dataThe test data is in test_atk.csv and has the same schema that we used for training.<jupyter_code>test_csv = ta.CsvFile("test_atk.csv", schema=schema, skip_header_lines=1)
test_frame = ta.Frame(test_csv)
test_frame.inspect()<jupyter_output>Done [=========================] 100.00% Time 00:00:02<jupyter_text>PredictUsing the frame of test data, run ARX predict().<jupyter_code>p = arx.predict(test_frame, y_column, x_columns)
p.inspect(n=p.row_count,columns=["y", "predicted_y"])
arx.publish()<jupyter_output>Done [=========================] 100.00% Time 00:00:02
{'fraction_non_alphanumeric': 0.17904290429042904, 'fraction_numerical': 0.07879537953795379, 'mean_word_length': 5.25, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '511994', 'license': 'Apache-2.0', 'n_tokens_mistral': 945, 'n_tokens_neox': 815, 'n_words': 209, 'path': 'python-client/ARX Demo.ipynb', 'repo_name': 'skavulya/atk', 'size': '2424'}