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
151 changes: 151 additions & 0 deletions data/input/iris.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
x3,x4,x1,x2,x5,y
5.1,3.5,1.4,0.2,a,0
4.9,3,1.4,0.2,a,0
4.7,3.2,1.3,0.2,a,0
4.6,3.1,1.5,0.2,a,0
5,3.6,1.4,0.2,a,0
5.4,3.9,1.7,0.4,a,0
4.6,3.4,1.4,0.3,a,0
5,3.4,1.5,0.2,a,0
4.4,2.9,1.4,0.2,e,0
4.9,3.1,1.5,0.1,e,0
5.4,3.7,1.5,0.2,e,0
4.8,3.4,1.6,0.2,e,0
4.8,3,1.4,0.1,e,0
4.3,3,1.1,0.1,e,0
5.8,4,1.2,0.2,e,0
5.7,4.4,1.5,0.4,e,0
5.4,3.9,1.3,0.4,e,0
5.1,3.5,1.4,0.3,e,0
5.7,3.8,1.7,0.3,e,0
5.1,3.8,1.5,0.3,s,0
5.4,3.4,1.7,0.2,s,0
5.1,3.7,1.5,0.4,s,0
4.6,3.6,1,0.2,s,0
5.1,3.3,1.7,0.5,s,0
4.8,3.4,1.9,0.2,s,0
5,3,1.6,0.2,s,0
5,3.4,1.6,0.4,s,0
5.2,3.5,1.5,0.2,s,0
5.2,3.4,1.4,0.2,s,0
4.7,3.2,1.6,0.2,s,0
4.8,3.1,1.6,0.2,e,0
5.4,3.4,1.5,0.4,s,0
5.2,4.1,1.5,0.1,a,0
5.5,4.2,1.4,0.2,s,0
4.9,3.1,1.5,0.2,a,0
5,3.2,1.2,0.2,s,0
5.5,3.5,1.3,0.2,a,0
4.9,3.6,1.4,0.1,e,0
4.4,3,1.3,0.2,s,0
5.1,3.4,1.5,0.2,a,0
5,3.5,1.3,0.3,s,0
4.5,2.3,1.3,0.3,e,0
4.4,3.2,1.3,0.2,s,0
5,3.5,1.6,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number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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/model.py 45 0 100%
mllib/lib/knn.py 70 0 100%
mllib/lib/model.py 44 0 100%
-----------------------------------------------------
TOTAL 162 0 100%
TOTAL 231 0 100%
9 changes: 9 additions & 0 deletions logs/pylint/lib-knn-py.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
************* Module mllib.lib.knn
knn.py:176: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)
knn.py:177: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)
knn.py:178: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)
knn.py:179: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: 4 additions & 0 deletions logs/pylint/tests-test_knn-py.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

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

18 changes: 14 additions & 4 deletions mllib/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from lib import cfg, utils # noqa: F841
from lib.cluster import Cluster # noqa: F841
from lib.model import GLMNet # noqa: F841
from lib.knn import KNN # noqa: F841

# =============================================================================
# --- DO NOT CHANGE ANYTHING FROM HERE
Expand All @@ -52,13 +53,13 @@
CLI.add_argument("-f", "--filename",
nargs=1,
type=str,
default=["store.csv"],
default=["iris.csv"],
help="input csv filename")

args = CLI.parse_args()

fn_ip = args.filename[0]
fn_ip = "store.csv"
fn_ip = "iris.csv"

# =============================================================================
# --- Main
Expand All @@ -79,12 +80,21 @@
start_t = time.time_ns()
df_ip = pd.read_csv(path + "input/test_glmnet.csv")
glm_mod = GLMNet(df=df_ip,
y_var=["y"],
x_var=["x1", "x3"])
y_var="y",
x_var=["x1", "x2"])
print("\nGLMNet\n")
for k, v in glm_mod.model_summary.items():
print(k, str(v).rjust(69 - len(k)))
print(elapsed_time("Time", start_t),
sep="\n")
# --- KNN
start_t = time.time_ns()
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")
# --- EOF
print(sep, elapsed_time("Total time", start), sep, sep="\n")
Loading