Air pollution forecast for Madrid
Air pollution is one of the major problems the world has to face.
Having a way to monitor these levels in order to be able to make appropriate decisions can be key for public administrations.
We want to predict the levels of atmospheric pollutants for the following week in Madrid.
Contents:
- Application type.
- Data set.
- Neural network.
- Training strategy.
- Model selection.
- Testing analysis.
- Model deployment.
This example is solved with Neural Designer.
To follow it step by step, you can use the free trial.
1. Application type
This is a forecasting project, since the variables to be predicted are the values of five pollutants for the next week.
The goal here is to obtain an accurate prediction for each of them.
2. Data set
The file madrid-forecasting.csv contains 2959 samples, each of them with 15 inputs.
The dataset is transformed to a time series with lags and steps ahead. The output variables are 35, one for each pollutant for 7 days of the week.
The following list summarizes the variables information:
Regarding time attributes:
- day
- month
- weekday
As far as contamination attributes, all values are presented using the Air Quality Index:
- PM2.5: value of particulate matter less than 2.5 microns in diameter.
- PM10: value of particulate matter less than 10 microns in diameter.
- O3: tropospheric ozone value (at ground level).
- NO2: nitrogen dioxide value.
- SO2: sulfur dioxide value.
Lastly, regarding meteorological attributes:
- precipitations: amount of rainfall in mm.
- tavg: average daily temperature.
- tmax: maximun daily temperature
- tmin: minimum daily temperature
- pressure: atmospheric pressure in hPa.
- windspeed: average wind speed in km/h.
- humidity: relative humidity in percentage.
The target variables represents the value of each pollutant for one day of the week, so in total there are thirty-five target variables.
The instances are split at random into training (60%), selection (20%), and testing (20%) subsets.
Once the data set has been set, we are ready to perform a few related analytics. With that, we check the provided information and make sure that the data has good quality.
We can calculate the data statistics and draw a table with the minimums, maximums, means, and standard deviations of all variables in the data set. The next table depicts the values.
In addition, we can obtain the existing inputs-targets correlations for each variable, thus having information regarding the importance of the different factors on atmospheric pollutants.
We can appreciate the great influence that one contaminant has on the rest (if the levels of one go up, typically they all go up). In addition, the effect of meteorological conditions on air quality is observed. For example, PM2.5 levels decrease with higher wind speed, due to the dispersion of particles that this causes.
3. Neural network
The second step is to set a neural network to represent the forecasting function. For this class of applications, the neural network is composed of:
- Scaling layer.
- Perceptron layers.
- Unscaling layer.
The scaling layer uses the minimum and maximum scaling method.
The number of perceptron layers is 2:
- The first perceptron layer has 22 inputs and 10 neurons.
- The second perceptron layer has 10 inputs and 35 neurons (the number of target variables).
The perceptron layer uses the hyperbolic tangent activation function.
In this graphical representation we can see the arquitecture of the neural network.
4. Training strategy
The procedure used to carry out the learning process is called a training strategy.
The training strategy is applied to the neural network to obtain the best possible performance.
The type of training is determined by how the adjustment of the parameters in the neural network takes place.
We set the Minkowski error with L1 regularization as the loss index.
On the other hand, we use the quasi-Newton method as optimization algorithm.
The following chart shows how the training and selection errors decrease with the quasi-Newton method’s epochs during the training process.
As we can see, both curves’ behavior is similar along with the iterations, which means that no over-fitting has appeared.
The final training and selection errors are training error = 0.598 ME and selection error = 0.657 ME.
That indicates that the neural network has good generalization capabilities.
5. Model selection
The objective of model selection is to find the network architecture with the best generalization properties,
that is, that which minimizes the error on the selected instances of the data set.
Order selection algorithms train several network architectures with a different number of neurons
and select that with the smallest selection error.
The incremental order method starts with a small number of neurons and increases the complexity at each iteration.
The following chart shows the training error (blue) and the selection error (orange) as a function of the number of neurons.
6. Testing analysis
Once the model is trained, we perform a testing analysis to validate its prediction capacity.
We use a subset of data that has not been used before, the testing instances.
To check the results we have obtained in this example, the graphs comparing the real value of the contamination are shown below.
As we can see in the graph above for the PM2.5, the prediction fits the actual values very well in all cases, being only slightly worse for NO2. We can say that the results are satisfactory.
7. Model deployment
The neural network is now ready to predict the activity of new people in the so-called model deployment phase.
The file madrid-air-forecasting.py
implements the
mathematical expression
of the neural network in Python.
This piece of software can be embedded in any tool to make predictions on new data.
Besides, we can use the mathematical expression of the neural network, which is listed next.
scaled_PRECIPITATIONS(mm)_lag_1 = (PRECIPITATIONS(mm)_lag_1-1.091740012)/3.984080076;
scaled_TAVG(C)_lag_1 = (TAVG(C)_lag_1-15.37049961)/8.109100342;
scaled_TMAX(C)_lag_1 = (TMAX(C)_lag_1-22.01239967)/8.915679932;
scaled_TMIN(C)_lag_1 = (TMIN(C)_lag_1-8.648309708)/6.886229992;
scaled_PRESSURE(hPa)_lag_1 = (PRESSURE(hPa)_lag_1-1017.619995)/7.228189945;
scaled_WINDSPEED(km/h)_lag_1 = (WINDSPEED(km/h)_lag_1-10.53849983)/5.421120167;
scaled_HUMIDITY(percentage)_lag_1 = (HUMIDITY(percentage)_lag_1-58.40459824)/19.56760025;
scaled_DAY_lag_0 = (DAY_lag_0-15.70590019)/8.798629761;
scaled_MONTH_lag_0 = (MONTH_lag_0-6.370520115)/3.47461009;
scaled_WEEKDAY_lag_0 = (WEEKDAY_lag_0-3.991130114)/1.996219993;
scaled_PM2.5(AQI)_lag_0 = (PM2.5(AQI)_lag_0-54.69229889)/19.66959953;
scaled_PM10(AQI)_lag_0 = (PM10(AQI)_lag_0-24.6970005)/12.00650024;
scaled_O3(AQI)_lag_0 = (O3(AQI)_lag_0-32.8608017)/14.49969959;
scaled_NO2(AQI)_lag_0 = (NO2(AQI)_lag_0-24.10029984)/10.27149963;
scaled_SO2(AQI)_lag_0 = (SO2(AQI)_lag_0-3.101670027)/2.045360088;
scaled_PRECIPITATIONS(mm)_lag_0 = (PRECIPITATIONS(mm)_lag_0-1.089869976)/3.983299971;
scaled_TAVG(C)_lag_0 = (TAVG(C)_lag_0-15.37279987)/8.108019829;
scaled_TMAX(C)_lag_0 = (TMAX(C)_lag_0-22.01580048)/8.912940025;
scaled_TMIN(C)_lag_0 = (TMIN(C)_lag_0-8.649029732)/6.88616991;
scaled_PRESSURE(hPa)_lag_0 = (PRESSURE(hPa)_lag_0-1017.609985)/7.228730202;
scaled_WINDSPEED(km/h)_lag_0 = (WINDSPEED(km/h)_lag_0-10.54090023)/5.422639847;
scaled_HUMIDITY(percentage)_lag_0 = (HUMIDITY(percentage)_lag_0-58.39049911)/19.55699921;
perceptron_layer_1_output_0 = tanh( -7.81672e-07 + (scaled_PRECIPITATIONS(mm)_lag_1*-5.1068e-05) + (scaled_TAVG(C)_lag_1*-8.19004e-05) + (scaled_TMAX(C)_lag_1*6.85665e-05) + (scaled_TMIN(C)_lag_1*-0.000105821) + (scaled_PRESSURE(hPa)_lag_1*2.53781e-05) + (scaled_WINDSPEED(km/h)_lag_1*0.000128805) + (scaled_HUMIDITY(percentage)_lag_1*0.000108651) + (scaled_DAY_lag_0*3.11461e-05) + (scaled_MONTH_lag_0*7.65274e-05) + (scaled_WEEKDAY_lag_0*0.000261137) + (scaled_PM2.5(AQI)_lag_0*-8.43789e-06) + (scaled_PM10(AQI)_lag_0*-2.4731e-05) + (scaled_O3(AQI)_lag_0*4.1529e-07) + (scaled_NO2(AQI)_lag_0*-3.07216e-05) + (scaled_SO2(AQI)_lag_0*0.504349) + (scaled_PRECIPITATIONS(mm)_lag_0*5.77838e-05) + (scaled_TAVG(C)_lag_0*-5.5772e-05) + (scaled_TMAX(C)_lag_0*-8.92538e-05) + (scaled_TMIN(C)_lag_0*0.000482141) + (scaled_PRESSURE(hPa)_lag_0*7.62514e-05) + (scaled_WINDSPEED(km/h)_lag_0*3.44847e-05) + (scaled_HUMIDITY(percentage)_lag_0*-6.46703e-05) );
perceptron_layer_1_output_1 = tanh( -0.0245757 + (scaled_PRECIPITATIONS(mm)_lag_1*-2.81286e-05) + (scaled_TAVG(C)_lag_1*3.45359e-05) + (scaled_TMAX(C)_lag_1*-0.000245359) + (scaled_TMIN(C)_lag_1*-0.000620736) + (scaled_PRESSURE(hPa)_lag_1*0.00743974) + (scaled_WINDSPEED(km/h)_lag_1*0.0067267) + (scaled_HUMIDITY(percentage)_lag_1*-0.000113467) + (scaled_DAY_lag_0*-7.56794e-05) + (scaled_MONTH_lag_0*1.7313e-05) + (scaled_WEEKDAY_lag_0*-0.000678773) + (scaled_PM2.5(AQI)_lag_0*-3.75441e-05) + (scaled_PM10(AQI)_lag_0*-0.00145189) + (scaled_O3(AQI)_lag_0*-6.16092e-05) + (scaled_NO2(AQI)_lag_0*0.0581054) + (scaled_SO2(AQI)_lag_0*0.634665) + (scaled_PRECIPITATIONS(mm)_lag_0*0.000655515) + (scaled_TAVG(C)_lag_0*4.65228e-06) + (scaled_TMAX(C)_lag_0*-0.0339807) + (scaled_TMIN(C)_lag_0*0.000101102) + (scaled_PRESSURE(hPa)_lag_0*0.0574812) + (scaled_WINDSPEED(km/h)_lag_0*0.0452492) + (scaled_HUMIDITY(percentage)_lag_0*0.000112177) );
perceptron_layer_1_output_2 = tanh( 4.73652e-05 + (scaled_PRECIPITATIONS(mm)_lag_1*-2.54399e-05) + (scaled_TAVG(C)_lag_1*-0.445912) + (scaled_TMAX(C)_lag_1*-0.000953647) + (scaled_TMIN(C)_lag_1*-0.243009) + (scaled_PRESSURE(hPa)_lag_1*0.000360695) + (scaled_WINDSPEED(km/h)_lag_1*-5.85611e-05) + (scaled_HUMIDITY(percentage)_lag_1*0.000163799) + (scaled_DAY_lag_0*-8.38313e-05) + (scaled_MONTH_lag_0*-0.140473) + (scaled_WEEKDAY_lag_0*8.02343e-06) + (scaled_PM2.5(AQI)_lag_0*-8.36781e-06) + (scaled_PM10(AQI)_lag_0*8.52817e-05) + (scaled_O3(AQI)_lag_0*-9.44177e-05) + (scaled_NO2(AQI)_lag_0*1.09307e-05) + (scaled_SO2(AQI)_lag_0*0.000127797) + (scaled_PRECIPITATIONS(mm)_lag_0*0.000105503) + (scaled_TAVG(C)_lag_0*-0.000276237) + (scaled_TMAX(C)_lag_0*-0.0624502) + (scaled_TMIN(C)_lag_0*-0.0812166) + (scaled_PRESSURE(hPa)_lag_0*-7.73504e-05) + (scaled_WINDSPEED(km/h)_lag_0*0.000108611) + (scaled_HUMIDITY(percentage)_lag_0*0.000197993) );
perceptron_layer_1_output_3 = tanh( 1.43261e-05 + (scaled_PRECIPITATIONS(mm)_lag_1*-6.74796e-06) + (scaled_TAVG(C)_lag_1*0.00498189) + (scaled_TMAX(C)_lag_1*0.00351506) + (scaled_TMIN(C)_lag_1*0.00250454) + (scaled_PRESSURE(hPa)_lag_1*2.35997e-05) + (scaled_WINDSPEED(km/h)_lag_1*0.000163005) + (scaled_HUMIDITY(percentage)_lag_1*-0.00111114) + (scaled_DAY_lag_0*8.58258e-05) + (scaled_MONTH_lag_0*3.04926e-06) + (scaled_WEEKDAY_lag_0*2.29893e-05) + (scaled_PM2.5(AQI)_lag_0*-0.000255982) + (scaled_PM10(AQI)_lag_0*-4.95592e-05) + (scaled_O3(AQI)_lag_0*0.695519) + (scaled_NO2(AQI)_lag_0*-7.24479e-05) + (scaled_SO2(AQI)_lag_0*-4.07316e-05) + (scaled_PRECIPITATIONS(mm)_lag_0*0.000245261) + (scaled_TAVG(C)_lag_0*0.0016223) + (scaled_TMAX(C)_lag_0*0.136874) + (scaled_TMIN(C)_lag_0*0.00122895) + (scaled_PRESSURE(hPa)_lag_0*6.45547e-05) + (scaled_WINDSPEED(km/h)_lag_0*0.000109245) + (scaled_HUMIDITY(percentage)_lag_0*-0.0139903) );
perceptron_layer_1_output_4 = tanh( -0.000339497 + (scaled_PRECIPITATIONS(mm)_lag_1*-0.000127403) + (scaled_TAVG(C)_lag_1*-0.012499) + (scaled_TMAX(C)_lag_1*-0.00531632) + (scaled_TMIN(C)_lag_1*-0.0278514) + (scaled_PRESSURE(hPa)_lag_1*0.000987953) + (scaled_WINDSPEED(km/h)_lag_1*-8.8954e-05) + (scaled_HUMIDITY(percentage)_lag_1*0.0578135) + (scaled_DAY_lag_0*9.83378e-06) + (scaled_MONTH_lag_0*0.000184528) + (scaled_WEEKDAY_lag_0*9.61819e-05) + (scaled_PM2.5(AQI)_lag_0*-2.39028e-05) + (scaled_PM10(AQI)_lag_0*-6.65766e-05) + (scaled_O3(AQI)_lag_0*-0.476291) + (scaled_NO2(AQI)_lag_0*9.25723e-05) + (scaled_SO2(AQI)_lag_0*5.46071e-05) + (scaled_PRECIPITATIONS(mm)_lag_0*-0.000253871) + (scaled_TAVG(C)_lag_0*-0.01695) + (scaled_TMAX(C)_lag_0*-0.175283) + (scaled_TMIN(C)_lag_0*-0.000373679) + (scaled_PRESSURE(hPa)_lag_0*0.000252323) + (scaled_WINDSPEED(km/h)_lag_0*-0.000100844) + (scaled_HUMIDITY(percentage)_lag_0*0.0666698) );
perceptron_layer_1_output_5 = tanh( -2.0101e-05 + (scaled_PRECIPITATIONS(mm)_lag_1*-4.66055e-06) + (scaled_TAVG(C)_lag_1*0.000314665) + (scaled_TMAX(C)_lag_1*9.88436e-05) + (scaled_TMIN(C)_lag_1*0.000357146) + (scaled_PRESSURE(hPa)_lag_1*-0.00039053) + (scaled_WINDSPEED(km/h)_lag_1*-4.94624e-05) + (scaled_HUMIDITY(percentage)_lag_1*6.14653e-06) + (scaled_DAY_lag_0*-1.51509e-05) + (scaled_MONTH_lag_0*6.76326e-05) + (scaled_WEEKDAY_lag_0*6.01453e-06) + (scaled_PM2.5(AQI)_lag_0*-0.000252826) + (scaled_PM10(AQI)_lag_0*-2.79894e-06) + (scaled_O3(AQI)_lag_0*1.36108e-05) + (scaled_NO2(AQI)_lag_0*-0.00016473) + (scaled_SO2(AQI)_lag_0*-0.23789) + (scaled_PRECIPITATIONS(mm)_lag_0*1.89202e-05) + (scaled_TAVG(C)_lag_0*0.152784) + (scaled_TMAX(C)_lag_0*0.0128358) + (scaled_TMIN(C)_lag_0*5.36459e-05) + (scaled_PRESSURE(hPa)_lag_0*4.02565e-05) + (scaled_WINDSPEED(km/h)_lag_0*4.34919e-05) + (scaled_HUMIDITY(percentage)_lag_0*0.00451162) );
perceptron_layer_1_output_6 = tanh( -0.030549 + (scaled_PRECIPITATIONS(mm)_lag_1*0.000202304) + (scaled_TAVG(C)_lag_1*0.000221993) + (scaled_TMAX(C)_lag_1*-0.000625084) + (scaled_TMIN(C)_lag_1*0.000532645) + (scaled_PRESSURE(hPa)_lag_1*5.57061e-06) + (scaled_WINDSPEED(km/h)_lag_1*6.595e-05) + (scaled_HUMIDITY(percentage)_lag_1*0.0027244) + (scaled_DAY_lag_0*0.000590548) + (scaled_MONTH_lag_0*0.170191) + (scaled_WEEKDAY_lag_0*0.0421223) + (scaled_PM2.5(AQI)_lag_0*0.0956457) + (scaled_PM10(AQI)_lag_0*0.690919) + (scaled_O3(AQI)_lag_0*0.138305) + (scaled_NO2(AQI)_lag_0*0.00242706) + (scaled_SO2(AQI)_lag_0*0.0646637) + (scaled_PRECIPITATIONS(mm)_lag_0*-0.0523376) + (scaled_TAVG(C)_lag_0*-0.000739689) + (scaled_TMAX(C)_lag_0*-0.00539014) + (scaled_TMIN(C)_lag_0*5.02929e-06) + (scaled_PRESSURE(hPa)_lag_0*0.144) + (scaled_WINDSPEED(km/h)_lag_0*0.049733) + (scaled_HUMIDITY(percentage)_lag_0*0.00400631) );
perceptron_layer_1_output_7 = tanh( -0.0649532 + (scaled_PRECIPITATIONS(mm)_lag_1*-0.0249491) + (scaled_TAVG(C)_lag_1*-0.000180414) + (scaled_TMAX(C)_lag_1*-0.000265918) + (scaled_TMIN(C)_lag_1*-1.63438e-05) + (scaled_PRESSURE(hPa)_lag_1*0.178126) + (scaled_WINDSPEED(km/h)_lag_1*-0.016143) + (scaled_HUMIDITY(percentage)_lag_1*0.137997) + (scaled_DAY_lag_0*-0.0684977) + (scaled_MONTH_lag_0*0.619193) + (scaled_WEEKDAY_lag_0*0.0343206) + (scaled_PM2.5(AQI)_lag_0*0.000692766) + (scaled_PM10(AQI)_lag_0*-0.000336186) + (scaled_O3(AQI)_lag_0*-0.02083) + (scaled_NO2(AQI)_lag_0*0.24744) + (scaled_SO2(AQI)_lag_0*-8.70714e-05) + (scaled_PRECIPITATIONS(mm)_lag_0*-0.0199021) + (scaled_TAVG(C)_lag_0*-0.112318) + (scaled_TMAX(C)_lag_0*-0.39647) + (scaled_TMIN(C)_lag_0*-0.0572767) + (scaled_PRESSURE(hPa)_lag_0*0.0529541) + (scaled_WINDSPEED(km/h)_lag_0*-6.51429e-05) + (scaled_HUMIDITY(percentage)_lag_0*0.130355) );
perceptron_layer_1_output_8 = tanh( -6.68113e-05 + (scaled_PRECIPITATIONS(mm)_lag_1*-0.000149986) + (scaled_TAVG(C)_lag_1*0.000142894) + (scaled_TMAX(C)_lag_1*-0.000571091) + (scaled_TMIN(C)_lag_1*-0.000147398) + (scaled_PRESSURE(hPa)_lag_1*0.0510151) + (scaled_WINDSPEED(km/h)_lag_1*7.25422e-05) + (scaled_HUMIDITY(percentage)_lag_1*0.059848) + (scaled_DAY_lag_0*-0.0295105) + (scaled_MONTH_lag_0*0.162819) + (scaled_WEEKDAY_lag_0*4.74193e-05) + (scaled_PM2.5(AQI)_lag_0*0.000145023) + (scaled_PM10(AQI)_lag_0*-0.0569127) + (scaled_O3(AQI)_lag_0*0.000235277) + (scaled_NO2(AQI)_lag_0*-0.380642) + (scaled_SO2(AQI)_lag_0*0.668855) + (scaled_PRECIPITATIONS(mm)_lag_0*2.02137e-07) + (scaled_TAVG(C)_lag_0*9.65273e-05) + (scaled_TMAX(C)_lag_0*-0.0259473) + (scaled_TMIN(C)_lag_0*6.93011e-05) + (scaled_PRESSURE(hPa)_lag_0*-0.000106907) + (scaled_WINDSPEED(km/h)_lag_0*0.0022201) + (scaled_HUMIDITY(percentage)_lag_0*0.0643652) );
perceptron_layer_1_output_9 = tanh( -7.86793e-05 + (scaled_PRECIPITATIONS(mm)_lag_1*0.000152966) + (scaled_TAVG(C)_lag_1*-7.11746e-05) + (scaled_TMAX(C)_lag_1*-2.74158e-05) + (scaled_TMIN(C)_lag_1*-2.32577e-05) + (scaled_PRESSURE(hPa)_lag_1*2.9876e-05) + (scaled_WINDSPEED(km/h)_lag_1*-3.99519e-05) + (scaled_HUMIDITY(percentage)_lag_1*0.000202682) + (scaled_DAY_lag_0*-3.67383e-06) + (scaled_MONTH_lag_0*5.92813e-05) + (scaled_WEEKDAY_lag_0*-4.31914e-05) + (scaled_PM2.5(AQI)_lag_0*6.19982e-05) + (scaled_PM10(AQI)_lag_0*-3.20118e-05) + (scaled_O3(AQI)_lag_0*-1.25627e-06) + (scaled_NO2(AQI)_lag_0*6.23244e-05) + (scaled_SO2(AQI)_lag_0*-4.38673e-06) + (scaled_PRECIPITATIONS(mm)_lag_0*-0.000145078) + (scaled_TAVG(C)_lag_0*-1.47928e-05) + (scaled_TMAX(C)_lag_0*2.93817e-05) + (scaled_TMIN(C)_lag_0*-0.000177187) + (scaled_PRESSURE(hPa)_lag_0*-8.16072e-05) + (scaled_WINDSPEED(km/h)_lag_0*-1.46762e-05) + (scaled_HUMIDITY(percentage)_lag_0*-0.000474795) );
perceptron_layer_2_output_0 = ( -3.46359e-05 + (perceptron_layer_1_output_0*3.20489e-05) + (perceptron_layer_1_output_1*2.71725e-05) + (perceptron_layer_1_output_2*0.0345011) + (perceptron_layer_1_output_3*-0.251555) + (perceptron_layer_1_output_4*0.0151238) + (perceptron_layer_1_output_5*-3.77405e-05) + (perceptron_layer_1_output_6*1.33553) + (perceptron_layer_1_output_7*-3.14557e-05) + (perceptron_layer_1_output_8*0.000128907) + (perceptron_layer_1_output_9*-7.78877e-05) );
perceptron_layer_2_output_1 = ( 5.23802e-05 + (perceptron_layer_1_output_0*-0.000155758) + (perceptron_layer_1_output_1*0.000277113) + (perceptron_layer_1_output_2*5.22625e-05) + (perceptron_layer_1_output_3*0.000118586) + (perceptron_layer_1_output_4*-0.000205926) + (perceptron_layer_1_output_5*0.000188549) + (perceptron_layer_1_output_6*1.11221) + (perceptron_layer_1_output_7*-8.13394e-07) + (perceptron_layer_1_output_8*-8.16147e-05) + (perceptron_layer_1_output_9*0.000185861) );
perceptron_layer_2_output_2 = ( 0.000121286 + (perceptron_layer_1_output_0*-0.00110745) + (perceptron_layer_1_output_1*-0.0142645) + (perceptron_layer_1_output_2*-0.000537531) + (perceptron_layer_1_output_3*0.702565) + (perceptron_layer_1_output_4*-0.428656) + (perceptron_layer_1_output_5*0.000724993) + (perceptron_layer_1_output_6*-0.00298029) + (perceptron_layer_1_output_7*-0.244109) + (perceptron_layer_1_output_8*-0.000308922) + (perceptron_layer_1_output_9*0.000104683) );
perceptron_layer_2_output_3 = ( 0.258724 + (perceptron_layer_1_output_0*0.000284902) + (perceptron_layer_1_output_1*0.371748) + (perceptron_layer_1_output_2*0.000211852) + (perceptron_layer_1_output_3*-0.000216279) + (perceptron_layer_1_output_4*-0.000175684) + (perceptron_layer_1_output_5*-0.000434493) + (perceptron_layer_1_output_6*0.273574) + (perceptron_layer_1_output_7*0.543078) + (perceptron_layer_1_output_8*-0.169492) + (perceptron_layer_1_output_9*4.22357e-05) );
perceptron_layer_2_output_4 = ( 0.0919128 + (perceptron_layer_1_output_0*0.469546) + (perceptron_layer_1_output_1*0.984214) + (perceptron_layer_1_output_2*-0.000184898) + (perceptron_layer_1_output_3*-0.000238387) + (perceptron_layer_1_output_4*-0.00012874) + (perceptron_layer_1_output_5*-0.000158721) + (perceptron_layer_1_output_6*2.48945e-05) + (perceptron_layer_1_output_7*-8.57095e-05) + (perceptron_layer_1_output_8*0.295862) + (perceptron_layer_1_output_9*-5.80002e-05) );
perceptron_layer_2_output_5 = ( 5.03353e-05 + (perceptron_layer_1_output_0*0.000123188) + (perceptron_layer_1_output_1*0.0225777) + (perceptron_layer_1_output_2*1.06771e-05) + (perceptron_layer_1_output_3*-0.0837096) + (perceptron_layer_1_output_4*0.0208545) + (perceptron_layer_1_output_5*-0.0001248) + (perceptron_layer_1_output_6*0.980715) + (perceptron_layer_1_output_7*0.0838683) + (perceptron_layer_1_output_8*1.51713e-05) + (perceptron_layer_1_output_9*-0.00012069) );
perceptron_layer_2_output_6 = ( 1.22211e-05 + (perceptron_layer_1_output_0*4.35655e-05) + (perceptron_layer_1_output_1*0.00011792) + (perceptron_layer_1_output_2*-0.0681524) + (perceptron_layer_1_output_3*0.000169379) + (perceptron_layer_1_output_4*-2.33402e-05) + (perceptron_layer_1_output_5*-4.39116e-05) + (perceptron_layer_1_output_6*0.785699) + (perceptron_layer_1_output_7*6.34841e-05) + (perceptron_layer_1_output_8*2.39807e-05) + (perceptron_layer_1_output_9*0.000148962) );
perceptron_layer_2_output_7 = ( -1.36461e-05 + (perceptron_layer_1_output_0*-0.000213955) + (perceptron_layer_1_output_1*0.000103782) + (perceptron_layer_1_output_2*-0.11544) + (perceptron_layer_1_output_3*0.453558) + (perceptron_layer_1_output_4*-0.350025) + (perceptron_layer_1_output_5*0.000534493) + (perceptron_layer_1_output_6*-2.49493e-06) + (perceptron_layer_1_output_7*-0.419745) + (perceptron_layer_1_output_8*-0.000445672) + (perceptron_layer_1_output_9*9.08143e-05) );
perceptron_layer_2_output_8 = ( 0.263866 + (perceptron_layer_1_output_0*0.000816121) + (perceptron_layer_1_output_1*0.100419) + (perceptron_layer_1_output_2*-8.32819e-06) + (perceptron_layer_1_output_3*1.32432e-05) + (perceptron_layer_1_output_4*0.000106625) + (perceptron_layer_1_output_5*0.000223114) + (perceptron_layer_1_output_6*0.083279) + (perceptron_layer_1_output_7*0.51738) + (perceptron_layer_1_output_8*8.86281e-05) + (perceptron_layer_1_output_9*-1.71811e-05) );
perceptron_layer_2_output_9 = ( 0.119269 + (perceptron_layer_1_output_0*0.323714) + (perceptron_layer_1_output_1*0.724935) + (perceptron_layer_1_output_2*0.000417641) + (perceptron_layer_1_output_3*-0.000444558) + (perceptron_layer_1_output_4*0.000126404) + (perceptron_layer_1_output_5*-0.0843885) + (perceptron_layer_1_output_6*-0.000104443) + (perceptron_layer_1_output_7*-4.90112e-05) + (perceptron_layer_1_output_8*0.512959) + (perceptron_layer_1_output_9*5.77323e-05) );
perceptron_layer_2_output_10 = ( 9.14365e-05 + (perceptron_layer_1_output_0*0.000203984) + (perceptron_layer_1_output_1*2.68203e-06) + (perceptron_layer_1_output_2*9.65371e-05) + (perceptron_layer_1_output_3*-1.223e-05) + (perceptron_layer_1_output_4*6.02164e-05) + (perceptron_layer_1_output_5*-0.000176063) + (perceptron_layer_1_output_6*0.67824) + (perceptron_layer_1_output_7*0.132631) + (perceptron_layer_1_output_8*0.000832239) + (perceptron_layer_1_output_9*3.21353e-05) );
perceptron_layer_2_output_11 = ( 9.16609e-05 + (perceptron_layer_1_output_0*-7.47347e-05) + (perceptron_layer_1_output_1*0.00017543) + (perceptron_layer_1_output_2*-0.131299) + (perceptron_layer_1_output_3*0.000350568) + (perceptron_layer_1_output_4*-0.00132689) + (perceptron_layer_1_output_5*5.22762e-05) + (perceptron_layer_1_output_6*0.611037) + (perceptron_layer_1_output_7*0.000227911) + (perceptron_layer_1_output_8*0.000428426) + (perceptron_layer_1_output_9*-6.4008e-05) );
perceptron_layer_2_output_12 = ( 0.0002459 + (perceptron_layer_1_output_0*-5.79903e-05) + (perceptron_layer_1_output_1*-9.24577e-05) + (perceptron_layer_1_output_2*-0.182998) + (perceptron_layer_1_output_3*0.328777) + (perceptron_layer_1_output_4*-0.273363) + (perceptron_layer_1_output_5*-0.00437846) + (perceptron_layer_1_output_6*-0.00018323) + (perceptron_layer_1_output_7*-0.522545) + (perceptron_layer_1_output_8*3.08215e-05) + (perceptron_layer_1_output_9*6.00599e-05) );
perceptron_layer_2_output_13 = ( 0.269524 + (perceptron_layer_1_output_0*0.00468415) + (perceptron_layer_1_output_1*0.0221275) + (perceptron_layer_1_output_2*-7.01404e-05) + (perceptron_layer_1_output_3*-6.96474e-05) + (perceptron_layer_1_output_4*1.90535e-06) + (perceptron_layer_1_output_5*9.23821e-05) + (perceptron_layer_1_output_6*0.000738936) + (perceptron_layer_1_output_7*0.52711) + (perceptron_layer_1_output_8*-0.000236266) + (perceptron_layer_1_output_9*-4.17387e-05) );
perceptron_layer_2_output_14 = ( 0.130413 + (perceptron_layer_1_output_0*0.286392) + (perceptron_layer_1_output_1*0.608042) + (perceptron_layer_1_output_2*0.000177002) + (perceptron_layer_1_output_3*-7.44335e-05) + (perceptron_layer_1_output_4*8.77717e-05) + (perceptron_layer_1_output_5*-0.12782) + (perceptron_layer_1_output_6*0.000108504) + (perceptron_layer_1_output_7*-1.25161e-05) + (perceptron_layer_1_output_8*0.588732) + (perceptron_layer_1_output_9*0.000105984) );
perceptron_layer_2_output_15 = ( 8.96784e-05 + (perceptron_layer_1_output_0*2.5252e-05) + (perceptron_layer_1_output_1*3.57428e-05) + (perceptron_layer_1_output_2*3.31915e-05) + (perceptron_layer_1_output_3*-6.84871e-06) + (perceptron_layer_1_output_4*-1.32239e-05) + (perceptron_layer_1_output_5*-1.12183e-05) + (perceptron_layer_1_output_6*0.511053) + (perceptron_layer_1_output_7*0.120095) + (perceptron_layer_1_output_8*0.00486513) + (perceptron_layer_1_output_9*0.00012165) );
perceptron_layer_2_output_16 = ( 0.000129306 + (perceptron_layer_1_output_0*-2.33643e-05) + (perceptron_layer_1_output_1*0.000132205) + (perceptron_layer_1_output_2*-0.158468) + (perceptron_layer_1_output_3*-0.000254302) + (perceptron_layer_1_output_4*-0.000605249) + (perceptron_layer_1_output_5*0.000278947) + (perceptron_layer_1_output_6*0.516689) + (perceptron_layer_1_output_7*0.000169561) + (perceptron_layer_1_output_8*0.00105861) + (perceptron_layer_1_output_9*-4.6832e-06) );
perceptron_layer_2_output_17 = ( -0.000196106 + (perceptron_layer_1_output_0*3.16771e-05) + (perceptron_layer_1_output_1*3.60245e-05) + (perceptron_layer_1_output_2*-0.188436) + (perceptron_layer_1_output_3*0.268331) + (perceptron_layer_1_output_4*-0.272384) + (perceptron_layer_1_output_5*0.000348692) + (perceptron_layer_1_output_6*1.21933e-05) + (perceptron_layer_1_output_7*-0.570332) + (perceptron_layer_1_output_8*0.00012354) + (perceptron_layer_1_output_9*-4.36534e-05) );
perceptron_layer_2_output_18 = ( 0.267427 + (perceptron_layer_1_output_0*0.000684955) + (perceptron_layer_1_output_1*-4.32167e-05) + (perceptron_layer_1_output_2*-8.28169e-05) + (perceptron_layer_1_output_3*2.30211e-05) + (perceptron_layer_1_output_4*3.69312e-06) + (perceptron_layer_1_output_5*-1.55565e-05) + (perceptron_layer_1_output_6*6.31279e-05) + (perceptron_layer_1_output_7*0.525982) + (perceptron_layer_1_output_8*0.00113883) + (perceptron_layer_1_output_9*-0.00011737) );
perceptron_layer_2_output_19 = ( 0.133312 + (perceptron_layer_1_output_0*0.30327) + (perceptron_layer_1_output_1*0.470258) + (perceptron_layer_1_output_2*0.0001558) + (perceptron_layer_1_output_3*-6.41378e-05) + (perceptron_layer_1_output_4*0.000769986) + (perceptron_layer_1_output_5*-0.179019) + (perceptron_layer_1_output_6*0.000117757) + (perceptron_layer_1_output_7*0.000122419) + (perceptron_layer_1_output_8*0.645101) + (perceptron_layer_1_output_9*3.24587e-05) );
perceptron_layer_2_output_20 = ( 4.26476e-05 + (perceptron_layer_1_output_0*-0.000102727) + (perceptron_layer_1_output_1*1.42918e-06) + (perceptron_layer_1_output_2*-0.00016005) + (perceptron_layer_1_output_3*0.000120576) + (perceptron_layer_1_output_4*8.23697e-06) + (perceptron_layer_1_output_5*-1.24781e-05) + (perceptron_layer_1_output_6*0.434018) + (perceptron_layer_1_output_7*0.108539) + (perceptron_layer_1_output_8*0.0161262) + (perceptron_layer_1_output_9*-0.000211734) );
perceptron_layer_2_output_21 = ( -1.01187e-05 + (perceptron_layer_1_output_0*-7.2426e-05) + (perceptron_layer_1_output_1*-0.000134239) + (perceptron_layer_1_output_2*-0.169497) + (perceptron_layer_1_output_3*0.00021877) + (perceptron_layer_1_output_4*-5.71454e-05) + (perceptron_layer_1_output_5*-3.90743e-05) + (perceptron_layer_1_output_6*0.450924) + (perceptron_layer_1_output_7*-5.92217e-05) + (perceptron_layer_1_output_8*0.00028591) + (perceptron_layer_1_output_9*4.36126e-06) );
perceptron_layer_2_output_22 = ( 0.000233378 + (perceptron_layer_1_output_0*0.000146757) + (perceptron_layer_1_output_1*-2.7065e-06) + (perceptron_layer_1_output_2*-0.189098) + (perceptron_layer_1_output_3*0.269304) + (perceptron_layer_1_output_4*-0.238697) + (perceptron_layer_1_output_5*-8.06029e-05) + (perceptron_layer_1_output_6*4.95457e-05) + (perceptron_layer_1_output_7*-0.581339) + (perceptron_layer_1_output_8*-0.000231346) + (perceptron_layer_1_output_9*-1.92252e-05) );
perceptron_layer_2_output_23 = ( 0.265025 + (perceptron_layer_1_output_0*0.000113315) + (perceptron_layer_1_output_1*0.00141134) + (perceptron_layer_1_output_2*-5.43647e-05) + (perceptron_layer_1_output_3*-2.98675e-05) + (perceptron_layer_1_output_4*-6.38004e-05) + (perceptron_layer_1_output_5*-0.000186446) + (perceptron_layer_1_output_6*0.000247684) + (perceptron_layer_1_output_7*0.524429) + (perceptron_layer_1_output_8*3.08645e-05) + (perceptron_layer_1_output_9*-2.83489e-05) );
perceptron_layer_2_output_24 = ( 0.148252 + (perceptron_layer_1_output_0*0.185196) + (perceptron_layer_1_output_1*0.502774) + (perceptron_layer_1_output_2*0.000737988) + (perceptron_layer_1_output_3*-0.00282174) + (perceptron_layer_1_output_4*0.0160523) + (perceptron_layer_1_output_5*-0.113163) + (perceptron_layer_1_output_6*0.000173715) + (perceptron_layer_1_output_7*0.000417266) + (perceptron_layer_1_output_8*0.698148) + (perceptron_layer_1_output_9*-0.000113526) );
perceptron_layer_2_output_25 = ( 1.00297e-05 + (perceptron_layer_1_output_0*1.34087e-05) + (perceptron_layer_1_output_1*-3.1442e-05) + (perceptron_layer_1_output_2*-0.000280408) + (perceptron_layer_1_output_3*6.38609e-05) + (perceptron_layer_1_output_4*-0.000109041) + (perceptron_layer_1_output_5*5.21823e-05) + (perceptron_layer_1_output_6*0.384075) + (perceptron_layer_1_output_7*0.101424) + (perceptron_layer_1_output_8*0.0147324) + (perceptron_layer_1_output_9*-6.43515e-05) );
perceptron_layer_2_output_26 = ( 0.000193643 + (perceptron_layer_1_output_0*6.32104e-05) + (perceptron_layer_1_output_1*0.000173745) + (perceptron_layer_1_output_2*-0.202379) + (perceptron_layer_1_output_3*0.000104262) + (perceptron_layer_1_output_4*-0.000175468) + (perceptron_layer_1_output_5*-0.00019416) + (perceptron_layer_1_output_6*0.385723) + (perceptron_layer_1_output_7*6.30879e-05) + (perceptron_layer_1_output_8*2.56892e-05) + (perceptron_layer_1_output_9*-3.27888e-06) );
perceptron_layer_2_output_27 = ( 8.234e-06 + (perceptron_layer_1_output_0*-0.000105641) + (perceptron_layer_1_output_1*0.000123252) + (perceptron_layer_1_output_2*-0.158707) + (perceptron_layer_1_output_3*0.301557) + (perceptron_layer_1_output_4*-0.218392) + (perceptron_layer_1_output_5*0.000360659) + (perceptron_layer_1_output_6*0.000228842) + (perceptron_layer_1_output_7*-0.594878) + (perceptron_layer_1_output_8*-0.000117629) + (perceptron_layer_1_output_9*-3.71235e-05) );
perceptron_layer_2_output_28 = ( 0.267906 + (perceptron_layer_1_output_0*9.39902e-06) + (perceptron_layer_1_output_1*0.00535142) + (perceptron_layer_1_output_2*-7.33732e-05) + (perceptron_layer_1_output_3*-0.000556824) + (perceptron_layer_1_output_4*5.73547e-05) + (perceptron_layer_1_output_5*-0.000259201) + (perceptron_layer_1_output_6*0.0001472) + (perceptron_layer_1_output_7*0.533089) + (perceptron_layer_1_output_8*0.00024621) + (perceptron_layer_1_output_9*-0.000255737) );
perceptron_layer_2_output_29 = ( 0.151295 + (perceptron_layer_1_output_0*0.0586795) + (perceptron_layer_1_output_1*0.65625) + (perceptron_layer_1_output_2*0.000500205) + (perceptron_layer_1_output_3*2.05952e-05) + (perceptron_layer_1_output_4*0.0608418) + (perceptron_layer_1_output_5*-0.057616) + (perceptron_layer_1_output_6*2.70908e-05) + (perceptron_layer_1_output_7*0.000551598) + (perceptron_layer_1_output_8*0.631893) + (perceptron_layer_1_output_9*-5.24758e-05) );
perceptron_layer_2_output_30 = ( 0.000108599 + (perceptron_layer_1_output_0*7.99234e-05) + (perceptron_layer_1_output_1*1.28938e-05) + (perceptron_layer_1_output_2*-0.00749721) + (perceptron_layer_1_output_3*-0.000218512) + (perceptron_layer_1_output_4*0.000111247) + (perceptron_layer_1_output_5*-0.000123932) + (perceptron_layer_1_output_6*0.33153) + (perceptron_layer_1_output_7*0.10259) + (perceptron_layer_1_output_8*0.0086827) + (perceptron_layer_1_output_9*-2.01403e-05) );
perceptron_layer_2_output_31 = ( -0.000257073 + (perceptron_layer_1_output_0*0.00014712) + (perceptron_layer_1_output_1*-5.97125e-05) + (perceptron_layer_1_output_2*-0.244648) + (perceptron_layer_1_output_3*1.34943e-05) + (perceptron_layer_1_output_4*-1.43019e-06) + (perceptron_layer_1_output_5*-0.000211559) + (perceptron_layer_1_output_6*0.312907) + (perceptron_layer_1_output_7*-2.19024e-05) + (perceptron_layer_1_output_8*-6.29357e-05) + (perceptron_layer_1_output_9*-6.00737e-05) );
perceptron_layer_2_output_32 = ( 9.62746e-05 + (perceptron_layer_1_output_0*1.02039e-05) + (perceptron_layer_1_output_1*-0.000255286) + (perceptron_layer_1_output_2*-0.137271) + (perceptron_layer_1_output_3*0.342481) + (perceptron_layer_1_output_4*-0.175306) + (perceptron_layer_1_output_5*0.000214274) + (perceptron_layer_1_output_6*0.000357222) + (perceptron_layer_1_output_7*-0.596591) + (perceptron_layer_1_output_8*-0.000109935) + (perceptron_layer_1_output_9*-0.000152015) );
perceptron_layer_2_output_33 = ( 0.269349 + (perceptron_layer_1_output_0*0.000299573) + (perceptron_layer_1_output_1*0.00666976) + (perceptron_layer_1_output_2*-0.000309186) + (perceptron_layer_1_output_3*-0.000165958) + (perceptron_layer_1_output_4*0.000220691) + (perceptron_layer_1_output_5*2.30115e-05) + (perceptron_layer_1_output_6*0.00112501) + (perceptron_layer_1_output_7*0.53254) + (perceptron_layer_1_output_8*-8.01891e-06) + (perceptron_layer_1_output_9*6.21555e-05) );
perceptron_layer_2_output_34 = ( 0.154989 + (perceptron_layer_1_output_0*0.0479387) + (perceptron_layer_1_output_1*0.723618) + (perceptron_layer_1_output_2*0.00054167) + (perceptron_layer_1_output_3*-0.000752354) + (perceptron_layer_1_output_4*0.0569981) + (perceptron_layer_1_output_5*-0.0406807) + (perceptron_layer_1_output_6*4.40218e-05) + (perceptron_layer_1_output_7*0.00637018) + (perceptron_layer_1_output_8*0.569702) + (perceptron_layer_1_output_9*-3.59483e-05) );
unscaling_layer_output_0 = 10+0.5*(perceptron_layer_2_output_0+1)*(166-10);
unscaling_layer_output_1 = 4+0.5*(perceptron_layer_2_output_1+1)*(160-4);
unscaling_layer_output_2 = 1+0.5*(perceptron_layer_2_output_2+1)*(249-1);
unscaling_layer_output_3 = 2+0.5*(perceptron_layer_2_output_3+1)*(74-2);
unscaling_layer_output_4 = 0+0.5*(perceptron_layer_2_output_4+1)*(17-0);
unscaling_layer_output_5 = 10+0.5*(perceptron_layer_2_output_5+1)*(166-10);
unscaling_layer_output_6 = 4+0.5*(perceptron_layer_2_output_6+1)*(160-4);
unscaling_layer_output_7 = 1+0.5*(perceptron_layer_2_output_7+1)*(249-1);
unscaling_layer_output_8 = 2+0.5*(perceptron_layer_2_output_8+1)*(74-2);
unscaling_layer_output_9 = 0+0.5*(perceptron_layer_2_output_9+1)*(17-0);
unscaling_layer_output_10 = 10+0.5*(perceptron_layer_2_output_10+1)*(166-10);
unscaling_layer_output_11 = 4+0.5*(perceptron_layer_2_output_11+1)*(160-4);
unscaling_layer_output_12 = 1+0.5*(perceptron_layer_2_output_12+1)*(249-1);
unscaling_layer_output_13 = 2+0.5*(perceptron_layer_2_output_13+1)*(74-2);
unscaling_layer_output_14 = 0+0.5*(perceptron_layer_2_output_14+1)*(17-0);
unscaling_layer_output_15 = 10+0.5*(perceptron_layer_2_output_15+1)*(166-10);
unscaling_layer_output_16 = 4+0.5*(perceptron_layer_2_output_16+1)*(160-4);
unscaling_layer_output_17 = 1+0.5*(perceptron_layer_2_output_17+1)*(249-1);
unscaling_layer_output_18 = 2+0.5*(perceptron_layer_2_output_18+1)*(74-2);
unscaling_layer_output_19 = 0+0.5*(perceptron_layer_2_output_19+1)*(17-0);
unscaling_layer_output_20 = 10+0.5*(perceptron_layer_2_output_20+1)*(166-10);
unscaling_layer_output_21 = 4+0.5*(perceptron_layer_2_output_21+1)*(160-4);
unscaling_layer_output_22 = 1+0.5*(perceptron_layer_2_output_22+1)*(249-1);
unscaling_layer_output_23 = 2+0.5*(perceptron_layer_2_output_23+1)*(74-2);
unscaling_layer_output_24 = 0+0.5*(perceptron_layer_2_output_24+1)*(17-0);
unscaling_layer_output_25 = 10+0.5*(perceptron_layer_2_output_25+1)*(166-10);
unscaling_layer_output_26 = 4+0.5*(perceptron_layer_2_output_26+1)*(160-4);
unscaling_layer_output_27 = 1+0.5*(perceptron_layer_2_output_27+1)*(249-1);
unscaling_layer_output_28 = 2+0.5*(perceptron_layer_2_output_28+1)*(74-2);
unscaling_layer_output_29 = 0+0.5*(perceptron_layer_2_output_29+1)*(17-0);
unscaling_layer_output_30 = 10+0.5*(perceptron_layer_2_output_30+1)*(166-10);
unscaling_layer_output_31 = 4+0.5*(perceptron_layer_2_output_31+1)*(160-4);
unscaling_layer_output_32 = 1+0.5*(perceptron_layer_2_output_32+1)*(249-1);
unscaling_layer_output_33 = 2+0.5*(perceptron_layer_2_output_33+1)*(74-2);
unscaling_layer_output_34 = 0+0.5*(perceptron_layer_2_output_34+1)*(17-0);
We can integrate this model into a website and, using public data retrieved from APIs, obtain the weekly forecast.
References:
- The data for this problem has been taken from the Air Quality Historical Data Platform.
Related posts:
- Reducing the gas emissions of a combined cycle power plant using machine learning.
- Predict the total CO2 emissions a car produces using machine learning.