Polynomial Regression Python Code - Loan Default Prediction
Import necessary libraries import pandas import numpy import matplotlib.pyplot from sklearn.linear_model import LinearRegression from sklearn.preprocessing import PolynomialFeatures Importing data into project data = pandas.read_csv('loan_default_rate_dataset.csv') print(data) Assign Input Columns to X variable and Output column to Y Variable x = data[['Credit_Score','Annual_Income','Loan_Amount']] y = data['Loan_Default_Probability'] Importing Polynomial Features to do cross connections, squares in x data. So data will expand and model can learn unpredictable patterns poly = PolynomialFeatures(degree=2) training the X variable using the polynomial feature. So it will do cross connections, squares in x data and learn the complex patterns. x_poly = poly.fit_transform(x) Now, since we learned the complex patterns and expanded the x values into x_poly variable, we can do linear regression from the Polynomial X data and Y data. model = LinearRegres...