Skip to content

Commit af8cab2

Browse files
committed
Removed matplotlib dependency & visualizations
1 parent b6f9c96 commit af8cab2

File tree

3 files changed

+2
-70
lines changed

3 files changed

+2
-70
lines changed

scratchml/regression/MultipleLinearRegression.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
import matplotlib.pyplot as plt
32

43
from ..utils import mean_squared_error, mean_absolute_error, root_mean_squared_error
54
from ..utils import InvalidValueException, ModelNotTrainedException
@@ -105,41 +104,3 @@ def evaluate(self, X, y, loss='mse'):
105104
'score': r2
106105
}
107106

108-
def visualize(self, X, y):
109-
"""Visualize the features along with actual and predicted outputs.
110-
111-
Args:
112-
X (array-like): Evaluation data of shape (k,n)
113-
y (array-like): Evaluation output of shape (k,)
114-
115-
Returns:
116-
None
117-
"""
118-
if(self.__trained == False):
119-
raise ModelNotTrainedException(self.visualize.__name__)
120-
121-
X = np.array(X, 'float64')
122-
y = np.array(y, 'float64')
123-
yhat = self.predict(X)
124-
125-
if not len(X.shape) == 1 or X.shape[1] == 1:
126-
X = np.mean(X, axis=1)
127-
128-
sorted_index_order = np.argsort(X)
129-
X = X[sorted_index_order]
130-
y = y[sorted_index_order]
131-
yhat = yhat[sorted_index_order]
132-
133-
plt.figure(num=None, figsize=(7, 4), dpi=80, facecolor='w', edgecolor='k')
134-
plt.title(self.__class__.__name__)
135-
plt.plot(X, yhat, '#85144b', label="Actual Values", alpha=0.5)
136-
plt.scatter(X, y, color='#2ECC40', label="Predicted Values", alpha=0.45)
137-
138-
plt.ticklabel_format(axis="both", style="sci", scilimits=(0,0))
139-
140-
plt.xlabel("Independent Variable")
141-
plt.ylabel("Dependent Variable")
142-
plt.legend()
143-
144-
plt.show()
145-

scratchml/regression/SimpleLinearRegression.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
import matplotlib.pyplot as plt
32

43
from ..utils import mean_squared_error, mean_absolute_error, root_mean_squared_error
54
from ..utils import InvalidValueException, ModelNotTrainedException
@@ -96,33 +95,3 @@ def evaluate(self, x, y, loss='mse'):
9695
'score': r2
9796
}
9897

99-
def visualize(self, x, y):
100-
"""Visualize the features along with actual and predicted outputs.
101-
102-
Args:
103-
x (array-like): Evaluation data of shape (k,)
104-
y (array-like): Evaluation output of shape (k,)
105-
106-
Returns:
107-
None
108-
"""
109-
if(self.__trained == False):
110-
raise ModelNotTrainedException(self.visualize().__name__)
111-
112-
sorted_index_order = np.argsort(x)
113-
x = np.array(x, 'float64')[sorted_index_order]
114-
y = np.array(y, 'float64')[sorted_index_order]
115-
yhat = self.predict(x)
116-
117-
plt.figure(num=None, figsize=(7, 4), dpi=80, facecolor='w', edgecolor='k')
118-
plt.title(self.__class__.__name__)
119-
plt.plot(x, yhat, '#85144b', label="Actual Values", alpha=0.5)
120-
plt.scatter(x, y, color='#2ECC40', label="Predicted Values", alpha=0.45)
121-
122-
plt.ticklabel_format(axis="both", style="sci", scilimits=(0,0))
123-
124-
plt.xlabel("Independent Variable")
125-
plt.ylabel("Dependent Variable")
126-
plt.legend()
127-
128-
plt.show()

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"Programming Language :: Python :: 3.6",
2727
"Programming Language :: Python :: 3.7",
2828
"Programming Language :: Python :: 3.8",
29+
"Programming Language :: Python :: 3.9",
30+
"Programming Language :: Python :: 3.10",
2931
"License :: OSI Approved :: MIT License",
3032
"Operating System :: OS Independent",
3133
"Topic :: Scientific/Engineering :: Artificial Intelligence",

0 commit comments

Comments
 (0)