<jupyter_start><jupyter_text>Import libraries As a data scientist, you would typically use libraries such as: - `pandas` : used to read data into a structured tabular format known as a `DataFrame`. It supports reading data from files, databases and APIs. It allows for operations to be performed on the `DataFrame` before then being written out to another file or database. - `statsmodels` : used to train a model and perform forecasting. - `scikit-learn` : used to train a model and perform forecasting.  - And much more..! Depending on what you need to do. Go ahead an import these popular libraries into your notebook by running```pythonimport pandas as pd  import statsmodels.api as smimport matplotlib.pyplot as plt```If these libraries do not exist on your computer, you would see a `Module Not Found` error. In that case, go ahead and install these libraries by running: ```pip install pandas pip install statsmodelspip install matplotlib```  Reading in dataAs a Data Scientist, you would work closely with the Data Engineer to have the data pulled in from various sources to speed up your ability to create machine learning models. For this instructor demo, let's assume that a Data Engineer has prepared a dataset for you (as per the previous exercises we did), and the dataset is stored in `../resources/final_superstore.csv`. We can read in the data using: ```pythonpd.read_csv("file_path_here")```  Feature engineeringAs a Data Scientist, you would often have to generate new features (columns) from existing data. These new features are used in the building of a machine learning model. Create a new date column (feature) so that it can be used in a time series forecasting model.  Prepare your dataset to be used in a time series forecasting model by grouping your data by `order_date` and summing up `total_value`.    Train model As a Data Scientist, your role is to build a model that would answer a forwards-looking business question. For example: "How much revenue can I expect to generate in the next 3 months?" Depending on the question you are trying to answer, you will select different types of models. In this example, you will use SARIMAX, a time series forecasting method. ```pythonmodel = sm.tsa.statespace.SARIMAX(df,order=(1, 0, 0), seasonal_order=(1, 1, 1, 12))```Where: - `df`: your DataFrame with the date set as the index and a column for the values - `order`: the (p,d,q) order of the model. - `seasonal_order`: the (P,D,Q,s) order of the seasonal component of the model<jupyter_code># fit a time series model<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06257287213369607, 'fraction_numerical': 0.003497862417411582, 'mean_word_length': 4.72, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '299475', 'license': 'MIT', 'n_tokens_mistral': 664, 'n_tokens_neox': 636, 'n_words': 392, 'path': '3-machine-learning/01-ins-time-series-forecasting/unsolved/time-series-forecasting.ipynb', 'repo_name': 'jonathanneo/data-101', 'size': '2573'}