Posts

Showing posts with the label Machine learning

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

Linear Regression Prediction of future values in Python using Scatter Plot - Machine Learning

Image
We are Importing Necessary Libraries for this project  import pandas as pandas  import numpy as numpy  import matplotlib.pyplot as pyplot  from sklearn.linear_model import LinearRegression Importing Data using Pandas library and creating table dataframe data = pandas.read_csv('python_linear_regression_prediction_python_data.csv')  print(data) Assigning Input / Independent columns to X variable and Assigning Output / Dependent Column to Y Variable x = data[['Experience_Years','Calls_Made','Meetings_Conducted']]  y = data['Sales_Amount'] Asking Linear Regression Model to learn data from X and Y variables model = LinearRegression() model.fit(x,y) Printing Coefficient and Intercept to check their values print("Coefficient:",model.coef_)  print("Intercept",model.intercept_) Adding New Inputs / Independent Values to predict Output / Dependent values new_data = pandas.DataFrame({ 'Experience_Years': [8, 12, 15], '...

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

What is Prediction in Machine Learning? Why is it Useful?

Image
Prediction - Finding out what will happen in Future. It may not be 100% Exact. But At least you know something is more likely to happen, with the help of prediction Analysis. This is called Predictive Analysis . One of the four important Types of Analysis. If you have last 10 months of students mark data, you can do predictive analysis and find future marks of the students. Why Predictive Analysis is Useful in Real Jobs? Sales Department : To Predict next month’s Profit, Sales, Product preference. Marketing Department : To Predict which customer is likely to buy a product. HR Department : To Predict which employee may leave the company in upcoming months. Education Sector : To Predict student performance and give early support before exams. Healthcare : To Predict patient risk level or future disease based on historic records. Government: To Predict Future Population Growth, Future Economy Level, Future Demands, Future Employment and business growth. Military: To Predict threats, Ear...

What is Artificial Intelligence? What is Machine Learning? What is Data Science? how they are related to each other?

Image
Artificial Intelligence means making Computers think like Human Brain, choosing correct & realistic decisions, answers based on the Current circumstance and importance. Personal Example: Data Science = What is Actually Happening in your Life. Machine Learning = What you are learning and experiencing in your Life. Artificial Intelligence = Taking Correct Decisions based on your Life Experience Another Example: You are AI Engineer & you created a Personal AI Friend using Python. Now, You give all information about your Financial Status, Economic Status, Emotional Status, Social Status, Current Situation in your Life, Current Situation in your Family, Current Situation in your Country etc etc... and your Current problems in an Excel file or SQL Database. Now you are giving this data to your AI tool which you created. 1. It will analyze the information, choose which is important and which is useless based on your current situation. 2. Now, it sends that important Information to Mac...