{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Let's import some libraries first..." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas\n", "from pandas.plotting import scatter_matrix\n", "\n", "from sklearn import datasets\n", "from sklearn import model_selection\n", "from sklearn import linear_model\n", "\n", "# models\n", "from sklearn.ensemble import RandomForestRegressor\n", "from sklearn.neighbors import KNeighborsRegressor\n", "from sklearn.preprocessing import StandardScaler, PolynomialFeatures\n", "from sklearn.linear_model import LinearRegression, Ridge\n", "from sklearn.tree import DecisionTreeRegressor\n", "from sklearn.metrics import mean_squared_error, r2_score\n", "\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load and examine dataset..." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " period npbt avg_gross_loan_book net_lending revenue\n", "0 1HFY14 -2830 27424.5 17511 7000\n", "1 2HFY14 -692 49041.0 31619 12104\n", "2 1HFY15 2907 67541.0 16220 16603\n", "3 2HFY15 -1400 85802.0 34800 19223\n", "4 1HFY16 2053 110302.0 31900 26204\n", "5 2HFY16 6100 127976.5 23200 26214\n", "6 1HFY17 4513 145476.5 30391 29735\n", "7 2HFY17 13083 158238.0 15793 36639\n", "8 1HFY18 8292 166238.0 24394 37566\n", "9 2HFY18 14736 177548.0 28011 41770\n" ] } ], "source": [ "dataset = pandas.read_csv(\"data/ccp-consumer-lending-half-year.csv\")\n", "print (dataset)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Period 1HFY14 to 1HFY15: p = 0.140936039634br + -0.064399199089l + -5567.40604369\n", "Period 2HFY14 to 2HFY15: p = 0.000873579448887br + -0.232666977089l + 6621.85593883\n", "Period 1HFY15 to 1HFY16: p = 0.101672186835br + -0.331734973293l + 1420.70009581\n", "Period 2HFY15 to 2HFY16: p = 0.113066609345br + -0.235471748635l + -2906.92436252\n", "Period 1HFY16 to 1HFY17: p = 0.0547529021572br + -0.353939061014l + 7304.3014326\n", "Period 2HFY16 to 2HFY17: p = 0.110760929767br + -0.490240059925l + 3298.77326195\n", "Period 1HFY17 to 1HFY18: p = 0.0166480875203br + -0.572513045014l + 19490.3384469\n", "Period 2HFY17 to 2HFY18: p = 1.0645668191br + -1.54720783081l + -130936.871049\n" ] } ], "source": [ "array = dataset.values\n", "num_data_points = 3\n", "\n", "for i in range(0, len(array) - (num_data_points - 1)):\n", " begin = i\n", " end = i + (num_data_points - 1)\n", " \n", " X = array[begin:end+1,2:4] # data = avg_gross_loan_book, net_lending\n", " Y = array[begin:end+1,1] # result = NPAT\n", "\n", " model = LinearRegression()\n", " model.fit(X, Y) # train model\n", " \n", " print(\"Period %s to %s: \" % (array[begin,0], array[end,0]), end =\" \")\n", " print(\"p = %sbr + %sl + %s\" % (model.coef_[0], model.coef_[1], model.intercept_))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Where\n", "```\n", "p = Net profit before tax (NPBT).\n", "r = Reporting period. Full year = 2, half year = 1.\n", "b = Average gross loan book.\n", "l = Net lending for the period.\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## FY19 Predictions\n", "\n", "Assumptions:\n", "\n", "* Average gross loan book will be $196m.\n", "\n", "* Net lending will be $50m, on the upper range of the forecast. Quoting a high number here will actually reduce EBIT.\n" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "EBIT = 209012.930498\n", "NPAT = 146309.051349\n" ] } ], "source": [ "b = 196000\n", "l = 50000\n", "r = 2\n", "\n", "p = model.coef_[0] * b * r + model.coef_[1] * l + model.intercept_\n", "\n", "print(\"EBIT = %s\" % p)\n", "print(\"NPAT = %s\" % (p * 0.7))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.6" } }, "nbformat": 4, "nbformat_minor": 2 }