{'fraction_non_alphanumeric': 0.029903039191721666, 'fraction_numerical': 0.008147967082212987, 'mean_word_length': 4.690310616597126, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Earnings Prediction with Deep Leaning

In the financial sector, a reliable forecast the future financial performance of a company is of great importance for investors' investment decisions. In this paper we compare long-term short-term memory (LSTM) networks to temporal convolution network (TCNs) in the prediction of future earnings per share (EPS). The experimental analysis is based on quarterly financial reporting data and daily stock market returns. For a broad sample of US firms, we find that both LSTMs outperform the naive persistent model with up to 30.0% more accurate predictions, while TCNs achieve and an improvement of 30.8%. Both types of networks are at least as accurate as analysts and exceed them by up to 12.2% (LSTM) and 13.2% (TCN).


Introduction
Investors rely first and foremost on earnings predictions when making investment decisions, e.g., buy, hold, or sell a firm's shares. Besides using own projections, they heavily rely on earnings forecasts provided by financial analysts. Consequently, forecasting earnings is one of the main tasks of financial analysts working at major financial institutions, e.g., broker firms. Analysts invest significant resources to provide accurate forecasts. However, forecasting is a difficult undertaking as numerous factors have an influence on the prediction performance. In this paper, we predict publicly listed US firms' quarterly earnings per share with state-ofthe-art techniques from the field of deep neural networks based on companies' time series data.
We structure the remainder of this paper as follows. In Section 2, we present related work on prediction of financial data. The base time series model and quality measures are introduced in Section 3. We describe the data preprocessing process in Section 4. Objective of our work is to compare LSTM networks with TCNs, which will be introduced in Section 5. Section 6 presents the experimental analysis, and Section 7 draws conclusions.

Related Work
Analyst forecasts are often used to benchmark the accuracy of earnings predictions obtained from models. However, due to recent regulation on financial analysts working conditions, e.g., limiting the private access to management, a drop in analyst coverage has been observed [1]. Automated earnings prediction models supported by artificial intelligence may fill this gap. Empirical evidence is missing whether artificial intelligence can provide meaningful forecasts.
Some evidence exists that fraud, e.g., illegal manipulation of earnings, can be predicted using machine learning [4]. In their study, Bao et al. (2020) find that ensemble learning with raw accounting numbers has predictive power for future fraud cases. Their approach outperforms logistic regression models based on financial ratios commonly used by prior research [6] as well as a supportvector-machine model [5], where a financial kernel maps raw accounting numbers into a set of financial ratios. Yet, the prediction of restatements is relatively less challenging as it is a binary decision tree (future restatement vs. no future restatement). To the contrary, predicting future earnings is more challenging as all discrete values are theoretically possible and information from multiple sources, e.g., financial statements, stock market data, have to be considered.
To our knowledge, no study has yet predicted future earnings using artificial intelligence. Closest to this study is the work of Ball and Ghysels (2018) [3]. They use a mixed data sampling regression method (but no neural networks) to predict future earnings and find that their predictions beat analysts' predictions in certain cases, e.g., when the firm size is smaller and analysts' forecast dispersion is high.

Time Series Model
The goal in data-driven prediction based on time series is to find a function φ that yields a future value y based on the data of the past β time steps x = (q t−β+1 , . . . , q t ) (Fig. 1). In this paper, the time-span between two time steps is 3 months. A non-perfect predictorφ(x) =ŷ can be evaluated using the mean squared error (MSE) to the real value y. Fig. 1: Illustration of time series model for prediction of earnings of a company with quarterly reports q t at time step t. We seek a mapping φ from pattern x of earning data of the past to label y of the predicted earning for the future t = t + τ . The window size β describes the time span of considered past earnings.
To evaluate our model we compare it with the persistent model and the analysts forecast. The persistence model is a simple baseline that uses the current value as a prediction for the next time step. For each model the MSE is calculated. Therefore, larger deviations are more punished than smaller ones.
Since the difficulty of forecasting the given data varies greatly over time and between different companies, the error value in itself is not meaningful. Therefore we use a relative comparison between the different models, namely the skill score (SS) [11]:

Data Preprocessing
As input data, we use accounting data (e.g., total assets and cost of goods sold) from Computstat Quarterly as well as daily stock market price and return data from CRSP (Daily Shares). At first both datasets Computstat Quarterly and Daily Shares are reduced to the most important parameters 4 per time-step and firm. Different value ranges of individual parameters x are "normalized" and scaled using the total assets atq: and studentized: where z is the mean of z i . Outliers of eps which are partially erroneous are removed by using the first (last) percentile as minimum (maximum). We create company samples of a given window size (number of quarters). Smaller data gaps a filled using linear interpolation, while samples with larger gaps are rejected. The quarterly data are merged with the corresponding daily stock data Daily Shares, which are also being studentized. 3 For the comparison with the persistent model only data points are used for which analyst forecasts exist. 4 The following parameters of the data records are used. The parameters in brackets are only used for the assignment and selection of the samples.

Deep Neural Networks
An LSTM network [8] belongs to the family of recurrent neural networks. It employs backward connections, which allow saving information in time. LSTM cells internally consists of three gates: forget, input, and output gates, see Fig. 2. An LSTM cell employs internal states h and s propagated through time. Yellow boxes represent ANN layers, orange circles represent element wise operations. Input x t is concatenated with h t−1 and fed to the forget, input, and output gates.
The forget gate determines which information should be forgotten, the input gate specifies to which amount the new input data is taken into account, and the output gate state specifies the information to output based on the internal state. With these functional components, an LSTM is well suited for time series data.
LSTM networks have successfully been applied to numerous domains, e.g., for wind power prediction [12] and for speech recognition [7]. A TCN [2] is a special kind of convolutional neural network [9]. While convolutional neural networks are primarily used for classification tasks in image, text or speech, TCNs can be applied to time series data. TCNs extend their counterparts by causal convolutions and dilated convolutions. The TCN has a one-dimensional time series input. Causal convolutions only use the current and past information for each filter. The dilation defines the distance between the used input data elements of each filter. An example for both concepts is visualized in Fig. 3 with a dilated causal convolution with kernel size k = 2 and dilations 1, 2, 4. In our experiments we increase d exponentially, i.e. d i = 2 i and select an appropriate number of layers to cover the given time span. TCNs also find numerous applications, e.g., in satellite image time series classification [10].

Experimental Analysis
For our experiments we employed two datasets: A for the choice of a proper architecture and parameters and B for the final experiment with the selected best architecture. The training set of A includes all samples whose predicted EPS values lie in the period 2012 to end of 2016. The last 10% of the training set is used for validation only. The test set is in the following half year after the training, so it is independent and has no unfair knowledge. For data set B, the period is extended by half a year, so that its test data have not been seen before.
Each model is trained with a batch size 1024 for 1000 epochs and a dropout rate of 0.3 for each intermediate layer and the recurrent edges of an LSTM layer. Dense layers apply tanh as activation function, except for the last layer using a linear one. The window size of Computstat Quarterly and Daily Shares is set to 20, i.e., the last 20 quarters of earning reports and the last 20 daily stock market returns form a pattern. The model is optimized using Adam and MSE as loss. Each epoch's best model w.r.t. validation error is used for testing. Each experiment is repeated five times. Statistics include mean and standard deviation.
Furthermore, we have experimentally selected the best architectures as representatives for LSTM and TCN (Fig. 4). Computstat Quarterly and Daily Shares are used as input (green). The dimensions are given in parentheses. Since the shares data is put into a dense layer (D), the time input 20 × 22 is flattened to 220. After a few layers the two inputs are joined by a merge layer. For the TCN 32 filters and a kernel size of 3 were used. The last dense layer with only one neuron outputs the predicted EPS value. As financial and non-financial companies show a significantly different behavior in many regards, we analyze the prediction in independent experiments. Table 1 compares the prediction performance with three different sets of companies: all companies (all), no financial companies (nofin), only financial companies (onlyfin). The data sets without financial firms usually give the best results. The worst results are achieved when only financial companies are taken into account.
We test the best model an an independent dataset B. Table 2 shows the results of the bests configurations of Table 1. The results for the non-financial companies are similar to the results observed before with an MSE that is 12-13% better than the analysts' predictions. The predictions for all companies are slightly better, but worse than on dataset A.  These results suggest that LSTM networks and TCNs are indeed able to provide meaningful earnings predictions. Even after acknowledging for the variation across the repetitions (e.g., standard errors based on three repetitions), the range of significance (e.g., mean estimate plus/minus standard error) is well above zero in all cases. This is remarkable, as we only used widely available public data on companies such as balance sheet information and stock market price and return data. Hence, we can conclude that our networks outperform both the persistent model and the mean forecast of financial analysts based on a subsample of non-financial firms (e.g., manufacturing firms).

Conclusion
Our experimental analysis has shown that LSTM networks and TCNs are powerful models in the application of earnings prediction. We base our prediction models on quarterly accounting data such as cost of goods sold and total assets as well as stock market price and return data. Using these widely available time series data, the persistent model was significantly outperformed. The LSTMs performed slightly better in our analysis using the same set of variables. In the future, we will extend the experimental analysis to further data sets and integrate further domain knowledge to improve the financial predictions. Our findings are relevant to both broker firms and investors. Broker firms may want to consider developing LSTM networks and TCN to supplement their analysts' forecast. Investors could build up their own forecast models using artificial intelligence, particularly when there are no forecasts available from financial analysts, which became a more urgent issue recently due to the drop in analyst coverage induced by regulation.