Skip to content
Merged
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
19 changes: 10 additions & 9 deletions logs/cov.out
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Name Stmts Miss Cover Missing
-----------------------------------------------------
mllib/__init__.py 7 0 100%
mllib/lib/__init__.py 7 0 100%
mllib/lib/cluster.py 103 0 100%
mllib/lib/knn.py 70 0 100%
mllib/lib/model.py 44 0 100%
-----------------------------------------------------
TOTAL 231 0 100%
Name Stmts Miss Cover Missing
-----------------------------------------------------------------------------------------
/media/ph33r/Data/Project/mllib/Git/mllib/__init__.py 7 0 100%
/media/ph33r/Data/Project/mllib/Git/mllib/lib/__init__.py 7 0 100%
/media/ph33r/Data/Project/mllib/Git/mllib/lib/cluster.py 103 0 100%
/media/ph33r/Data/Project/mllib/Git/mllib/lib/knn.py 70 0 100%
/media/ph33r/Data/Project/mllib/Git/mllib/lib/model.py 44 0 100%
/media/ph33r/Data/Project/mllib/Git/mllib/lib/tree.py 79 0 100%
-----------------------------------------------------------------------------------------
TOTAL 310 0 100%
2 changes: 1 addition & 1 deletion logs/pip.out
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./bin/run_tests.sh: line 78: pipreqs: command not found
INFO: Successfully saved requirements file in /media/ph33r/Data/Project/mllib/Git/requirements.txt
9 changes: 0 additions & 9 deletions logs/pylint/lib-glmnet_ts-py.out

This file was deleted.

9 changes: 9 additions & 0 deletions logs/pylint/lib-tree-py.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
************* Module mllib.lib.tree
tree.py:73:45: I1101: Module 'metrics' has no 'rsq' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
tree.py:74:45: I1101: Module 'metrics' has no 'mae' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
tree.py:75:46: I1101: Module 'metrics' has no 'mape' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
tree.py:76:46: I1101: Module 'metrics' has no 'rmse' member, but source is unavailable. Consider adding this module to extension-pkg-whitelist if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

4 changes: 0 additions & 4 deletions logs/pylint/tests-test_glmnet_ts-py.out

This file was deleted.

File renamed without changes.
24 changes: 24 additions & 0 deletions mllib/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from lib.cluster import Cluster # noqa: F841
from lib.model import GLMNet # noqa: F841
from lib.knn import KNN # noqa: F841
from lib.tree import RandomForest # noqa: F841
from lib.tree import XGBoost # noqa: F841

# =============================================================================
# --- DO NOT CHANGE ANYTHING FROM HERE
Expand Down Expand Up @@ -92,6 +94,28 @@
df_ip = pd.read_csv(path + "input/iris.csv")
mod = KNN(df_ip, "y", ["x1", "x2", "x3", "x4"], method="classify")
print("\nKNN\n")
for k, v in mod.model_summary.items():
print(k, str(v).rjust(69 - len(k)))
print(elapsed_time("Time", start_t),
sep="\n")
# --- Random forest
start_t = time.time_ns()
df_ip = pd.read_csv(path + "input/iris.csv")
x_var = ["x1", "x2", "x3", "x4"]
y_var = "y"
mod = RandomForest(df_ip, y_var, x_var, method="classify")
print("\nRandom forest\n")
for k, v in mod.model_summary.items():
print(k, str(v).rjust(69 - len(k)))
print(elapsed_time("Time", start_t),
sep="\n")
# --- XGBoost
start_t = time.time_ns()
df_ip = pd.read_csv(path + "input/iris.csv")
x_var = ["x1", "x2", "x3", "x4"]
y_var = "y"
mod = XGBoost(df_ip, y_var, x_var, method="classify")
print("\nXGBoost\n")
for k, v in mod.model_summary.items():
print(k, str(v).rjust(69 - len(k)))
print(elapsed_time("Time", start_t),
Expand Down
8 changes: 4 additions & 4 deletions mllib/lib/knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class KNN():
Example
-------
>>> mod = KNN(df=df_ip, y_var="y", x_var=["x1", "x2", "x3"])
>>> df_op = mod.predict(df_predict)
>>> df_op = mod.predict(x_predict)

"""

Expand Down Expand Up @@ -189,7 +189,7 @@ def _compute_metrics(self):
for key in model_summary}
self.model_summary = model_summary

def predict(self, df_predict: pd.DataFrame) -> pd.DataFrame:
def predict(self, x_predict: pd.DataFrame) -> pd.DataFrame:
"""Predict y_var/target variable.

Parameters
Expand All @@ -205,8 +205,8 @@ def predict(self, df_predict: pd.DataFrame) -> pd.DataFrame:
Pandas dataframe containing predicted `y_var` and `x_var`.

"""
df_op = df_predict.copy(deep=True)
df_predict = pd.get_dummies(df_predict)
df_op = x_predict.copy(deep=True)
df_predict = pd.get_dummies(x_predict)
df_predict_tmp = pd.DataFrame(columns=self.x_var)
df_predict = pd.concat([df_predict_tmp, df_predict])
df_predict = df_predict.fillna(0)
Expand Down
Loading