Posts

Showing posts with the label prediction Models

Polynomial Regression Python Code - Loan Default Prediction

Image
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...

Showing Relationship between X and Y Values using Linear Regression Line in Python - Machine Learning

Image
Importing Libraries for this project import numpy as np  import pandas as pd from sklearn.linear_ model import LinearRegression  import matplotlib.pyplot as plt  Importing Data file into python code  filepath = 'PythonRegressionPracticeWorkbook.csv'  data = pd.read_csv(filepath)  print(data)  Assigning Input / Independent Column to X and assigning dependent / Output Column to Y variables  x = data[['Square Feet']]  y = data['Price']  Training the X and Y variables using Linear Regression Model to find how X affects Y model = LinearRegression()  model.fit(x,y)  Checking Slope, Intercept values from the learned Model slope = model.coef_[0]  intercept = model.intercept_  print("Slope:", slope)  print("Intercept:",intercept)  Predicting the output value / Y value for each X value / input value  y_pred = model.predict(x)  Plotting Scatter plot with Regression Line to show both Original X and Y values, P...

Commonly used Prediction Models in Machine Learning? Explain Each Model and How it Works?

Image
Regression models are a type of machine learning model used to predict. It tries to find a relationship between columns.  Regression Models are ready-made mathematical formulas created to make life easier . 1. Linear Regression: Linear Regression is a model that checks whether there is a relationship between two or more columns. The relationship means: if one column value increases, will the other column value also increase or decrease. If you study more hours, your marks will increase. If you have more work experience, your salary will increase. These are called positive relationships. Example: Students Mark - It can change over time, It is a Numerical score. Sales - It can change over time, It is a Numerical Count. Temperature - It can change over time. It is Number based. Here is a Simple Linear Regression Graph: If you have a Students Marks & Study time data for past 1 year, you can predict future marks using Linear Regression. 2. Logistic Regression: It is used for Pr...