Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# ML Module that makes learning process smooth

### Project Overview
Expand Down
20 changes: 12 additions & 8 deletions mlhybridx/check.py → mlhybridx/EasyReg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import sys
import pandas as pd
from .hub import check_file,ols,multiple,GDR,SE,split_data,train_data,predict_gdr,predict_olr,perdict_multiple, By_default
from .hub import check_file,ols,multiple,GDR,SE,split_data,train_data,predict_gdr,predict_olr,perdict_multiple, By_default, visuals
import time

class EasyRegressor:
Expand Down Expand Up @@ -89,7 +89,7 @@ def model_gdr(self, lr=0.0001, epochs=50):
def predict(self, model, val=None):
self.df()
x, y = split_data(self.data, self.target)
x_train, x_test, y_train, y_test = train_data(x, y, self.test_size)
x_train, x_test, y_train, self.y_test = train_data(x, y, self.test_size)
m,b = ols(x_train, y_train)
try:
if model == 'ols':
Expand All @@ -98,8 +98,8 @@ def predict(self, model, val=None):
pred = predict_olr(float(val),m,b)
output = f"Predicted Values = {pred}"
return self.typer(output)
pred = predict_olr(x_test, m, b)
output = f"Predicted values = {pred}"
self.pred = predict_olr(x_test, m, b)
output = f"Predicted values = {self.pred}"
return self.typer(output)

if model == 'mlr':
Expand All @@ -108,8 +108,8 @@ def predict(self, model, val=None):
pred = perdict_multiple(float(val),m,b)
output = f"Predicted Values = {pred}"
return self.typer(output)
pred = predict_olr(x_test, m, b)
output = f"Predicted values = {pred}"
self.pred = predict_olr(x_test, m, b)
output = f"Predicted values = {self.pred}"
return self.typer(output)

if model == 'gdr':
Expand All @@ -118,8 +118,8 @@ def predict(self, model, val=None):
pred = predict_gdr(x_test, m, b)
output = f"Predicted values = {pred}"
return self.typer(output)
pred = predict_gdr(x_test, m, b)
output = f"Predicted values = {pred}"
self.pred = predict_gdr(x_test, m, b)
output = f"Predicted values = {self.pred}"
return self.typer(output)
except ValueError:
print("Inalid params")
Expand All @@ -144,3 +144,7 @@ def score(self, score, model):
m,b = GDR(x_train,y_train,lr=0.01,epochs= 50)
y_pred = predict_gdr(x_test,m,b)
return SE(y_test, y_pred, score)


def plot(self, y_pred, y_actual, plot_type:str):
return visuals(y_pred, y_actual, plot_type)
36 changes: 36 additions & 0 deletions mlhybridx/Visualization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns


def visuals(self, y_pred, y_actual, plot_type:str, title:str, xlabel: str, ylabel:str):

title = f'{plot_type} Chart'
xlabel = f'{xlabel}'
ylabel = f'{ylabel}'
if plot_type == 'plot':
sns.lineplot(x=y_actual, y=y_pred, color='blue', label='Line 1')
sns.lineplot(x=y_actual, y=y_pred, color='red', label='Line 2')
plt.legend()
plt.title(title)
plt.xlabel(xlabel)
plt.ylabel(ylabel)

plt.show()


if plot_type == 'scatter':
sns.scatterplot(x=y_actual, y=y_pred, color='blue', label='Line 1')
sns.lineplot(x=y_actual, y=y_pred, color='red', label='Line 2')
plt.legend()
plt.title(title)
plt.xlabel(xlabel)
plt.ylabel(ylabel)

plt.show()


def main():
visuals([1,2,3,4,5],[2,5,8,8,5],'plot')

main()
2 changes: 1 addition & 1 deletion mlhybridx/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .check import EasyRegressor
from .EasyReg import EasyRegressor
Binary file added mlhybridx/__pycache__/EasyReg.cpython-310.pyc
Binary file not shown.
Binary file added mlhybridx/__pycache__/Visualization.cpython-310.pyc
Binary file not shown.
Binary file added mlhybridx/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added mlhybridx/__pycache__/algorithm.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file added mlhybridx/__pycache__/default.cpython-310.pyc
Binary file not shown.
Binary file added mlhybridx/__pycache__/hub.cpython-310.pyc
Binary file not shown.
Binary file added mlhybridx/__pycache__/predict.cpython-310.pyc
Binary file not shown.
Binary file added mlhybridx/__pycache__/scores.cpython-310.pyc
Binary file not shown.
Binary file added mlhybridx/__pycache__/split.cpython-310.pyc
Binary file not shown.
Binary file added mlhybridx/__pycache__/train.cpython-310.pyc
Binary file not shown.
9 changes: 7 additions & 2 deletions mlhybridx/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .split import split_data
from .predict import predict_olr, perdict_multiple, predict_gdr
from .train import train_data
from .Visualization import visuals

def datasets():
flight = sns.load_dataset('flights').replace({'Jan': 1, 'Feb':2,'Mar':3,'Apr':4,'May':5,'Jun':6,'Jul':7,'Aug':8,'Sep':9,'Oct':10,'Nov':11,'Dec':12})
Expand Down Expand Up @@ -45,7 +46,9 @@ def By_default():
m,b = ols( x_train, y_train)
print(f"m = {m}\nb = {b} ")
pred = predict_olr(x_test,m,b)
print(f" Predicted value = {pred}")
print(f" Predicted Value = {pred}")

visuals(pred, y_test,'plot')

print("\n\n\n//////////////////////////////////////////// ●▬▬▬▬◤ By Multiple Regression ◢▬▬▬▬● ///////////////////////////////////////\n")
x_train, x_test, y_train, y_test = train_data( x, y , size)
Expand All @@ -55,7 +58,7 @@ def By_default():
print(f" Predicted value = {pred}")


print("\n\n\n///////////////////////////////////// ●▬▬▬▬◤ By Gradient Descent Regression ◢▬▬▬▬● //////////////////////////////////////\n")
print("\n\n\n//////////////////////////////// ●▬▬▬▬◤ By Gradient Descent Regression ◢▬▬▬▬● //////////////////////////////////////\n")
print("\n\n\n For lr = 0.001 and epochs = 50\n\n")
x_train, x_test, y_train, y_test = train_data( x, y , size)
intercept_, coef_= GDR(x_train, y_train, lr=0.001, epochs=50)
Expand All @@ -67,6 +70,8 @@ def By_default():








3 changes: 2 additions & 1 deletion mlhybridx/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
from .split import split_data
from .predict import predict_olr, perdict_multiple, predict_gdr
from .train import train_data
from .default import By_default
from .default import By_default
from .Visualization import visuals
98 changes: 77 additions & 21 deletions test/test.ipynb

Large diffs are not rendered by default.