<jupyter_start><jupyter_text>Let'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 and examine dataset...<jupyter_code>dataset = pandas.read_csv("data/ccp-consumer-lending-half-year.csv")
print (dataset)
array = dataset.values
num_data_points = 3

for i in range(0, len(array) - (num_data_points - 1)):
    begin = i
    end = i + (num_data_points - 1)
    
    X = array[begin:end+1,2:4]   # data = avg_gross_loan_book, net_lending
    Y = array[begin:end+1,1]     # result = NPAT

    model = LinearRegression()
    model.fit(X, Y) # train model
    
    print("Period %s to %s: " % (array[begin,0], array[end,0]), end =" ")
    print("p = %sbr + %sl + %s" % (model.coef_[0], model.coef_[1], model.intercept_))<jupyter_output>Period 1HFY14 to 1HFY15:  p = 0.140936039634br + -0.064399199089l + -5567.40604369
Period 2HFY14 to 2HFY15:  p = 0.000873579448887br + -0.232666977089l + 6621.85593883
Period 1HFY15 to 1HFY16:  p = 0.101672186835br + -0.331734973293l + 1420.70009581
Period 2HFY15 to 2HFY16:  p = 0.113066609345br + -0.235471748635l + -2906.92436252
Period 1HFY16 to 1HFY17:  p = 0.0547529021572br + -0.353939061014l + 7304.3014326
Period 2HFY16 to 2HFY17:  p = 0.110760929767br + -0.490240059925l + 3298.77326195
Period 1HFY17 to 1HFY18:  p = 0.0166480875203br + -0.572513045014l + 19490.3384469
Period 2HFY17 to 2HFY18:  p = 1.0645668191br + -1.54720783081l + -130936.871049<jupyter_text>Where```p = Net profit before tax (NPBT).r = Reporting period. Full year = 2, half year = 1.b = Average gross loan book.l = Net lending for the period.```  FY19 PredictionsAssumptions:* Average gross loan book will be $196m.* Net lending will be $50m, on the upper range of the forecast. Quoting a high number here will actually reduce EBIT.<jupyter_code>b = 196000
l = 50000
r = 2

p = model.coef_[0] * b * r + model.coef_[1] * l + model.intercept_

print("EBIT = %s" % p)
print("NPAT = %s" % (p * 0.7))<jupyter_output>EBIT = 209012.930498
NPAT = 146309.051349
{'fraction_non_alphanumeric': 0.10922712933753943, 'fraction_numerical': 0.1640378548895899, 'mean_word_length': 4.5514223194748356, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '496508', 'license': 'MIT', 'n_tokens_mistral': 1259, 'n_tokens_neox': 975, 'n_words': 243, 'path': 'notebooks/ccp/CreditCorpConsumerLending-WayOffWithLinear.ipynb', 'repo_name': 'drworm/invest-notebooks', 'size': '2536'}