<jupyter_start><jupyter_text>Credit Corp's Consumer Lending SegmentNote: All numbers are in the form of $'000 unless otherwise statedLet's import some libraries first...<jupyter_code>import pandas
from pandas.plotting import scatter_matrix

from sklearn import datasets
from sklearn import model_selection
from sklearn import linear_model

# models
from sklearn.ensemble import RandomForestRegressor
from sklearn.neighbors import KNeighborsRegressor
from sklearn.preprocessing import StandardScaler, PolynomialFeatures
from sklearn.linear_model import LinearRegression, Ridge
from sklearn.tree import DecisionTreeRegressor
from sklearn.metrics import mean_squared_error, r2_score

import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Load the past few years of relevant data.<jupyter_code>dataset = pandas.read_csv("data/ccp-consumer-lending-full-year.csv")
print (dataset)<jupyter_output>period  revenue   npbt  gross_book_average  net_lending
0   FY14    19104  -3522             41465.5        49130
1   FY15    35826   1401             81343.0        51063
2   FY16    52418   8709            117278.5        55077
3   FY17    66374  17596            147714.5        46184
4   FY18    79336  23028            171786.0        52405<jupyter_text>Let us create a linear regression model with the whole dataset.<jupyter_code>array = dataset.values
    
X = array[:,3:5]   # data = avg_gross_loan_book, net_lending
Y = array[:,2]     # result = NPAT

model = LinearRegression()
model.fit(X, Y)    # train model

# the model's linear regression coefficients
print("Coefficients: \t%s" % model.coef_)
print("Intercept: \t%s" % model.intercept_)

print("\nThe equation would look like...")
print("p = %sr + %sl + %s" % (model.coef_[0], model.coef_[1], model.intercept_))<jupyter_output>Coefficients: 	[ 0.2111212  -0.28462548]
Intercept: 	265.191305252

The equation would look like...
p = 0.211121197019r + -0.284625478565l + 265.191305252<jupyter_text>Where```p = Net profit before tax (npbt)b = Average gross loan book (gross_book_average)l = Net lending for the period (net_lending)```  FY19 Predictions Based on management's forecastsAssumptions:* Gross loan book to end the year at $199.896m (long story on how I got to something so specific)* Average gross loan book will be $191.496m* Net lending will be $50m, on the upper range of the forecast. Quoting a high number here will actually reduce NPBT.<jupyter_code>gross_book_average = 191496
net_lending = 50000

npbt = model.predict([[gross_book_average, net_lending]])[0]

print("EBIT = $%sm" % (npbt/1000))
print("NPAT = $%sm" % (npbt/1000 * 0.7))<jupyter_output>EBIT = $26.4627821213m
NPAT = $18.5239474849m<jupyter_text>This sits inside the $17 - 19m range forecast by management, so our model is not crazy bad!  Based on a zero-growth scenarioThe higher the Net Lending completed by the company, the lower the reported Net Profit due to the way the company provisions the expected lossed upfront. So you get a situation where the NPAT is under-reported, unless the company stops growing its loan book. So what happens with NPAT when the loan book stops growing?* Assume 17.34% of gross loan book is the required net lending to maintain the loan book.* Last 5 years (FY14 - FY18) this figure has been: 14.22%, 17.88%, 16.82%, 13.99%, 17.34%.<jupyter_code>net_lending = gross_book_average * 0.1734

print("\nNet Lending Assumption = %s\n" % net_lending)

npbt_zero_growth = model.predict([[gross_book_average, net_lending]])[0]

print("EBIT: $%sm" % (npbt_zero_growth / 1000))
print("NPAT: $%sm" % (npbt_zero_growth * 0.7 / 1000))

print("\nNPAT buffer: $%sm" % ((npbt_zero_growth - npbt) / 1000))<jupyter_output>Net Lending Assumption = 33205.4064

EBIT: $31.242951362m
NPAT: $21.8700659534m

NPAT buffer: $4.7801692407m
{'fraction_non_alphanumeric': 0.09234411996842937, 'fraction_numerical': 0.0931333859510655, 'mean_word_length': 4.415954415954416, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '10035', 'license': 'MIT', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1259, 'n_words': 400, 'path': 'notebooks/ccp/CreditCorpConsumerLending-Regression.ipynb', 'repo_name': 'drworm/invest-notebooks', 'size': '3801'}