Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correcting KNN and TS Plots #854

Merged
merged 1 commit into from
Nov 11, 2023
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
7 changes: 6 additions & 1 deletion verticapy/machine_learning/vertica/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,12 @@ def score(
"logloss",
"log_loss",
):
y_score = self._get_y_score(allSQL=True)
if self._model_type == "KNeighborsClassifier":
y_score = self._get_y_score(
pos_label=pos_label, cutoff=cutoff, allSQL=True
)
else:
y_score = self._get_y_score(allSQL=True)
else:
y_score = self._get_y_score(pos_label=pos_label, cutoff=cutoff)
final_relation = self._get_final_relation(pos_label=pos_label)
Expand Down
6 changes: 6 additions & 0 deletions verticapy/machine_learning/vertica/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,12 @@ def _get_y_score(
WHEN proba_predict > {cutoff} THEN '{self.classes_[1]}'
ELSE '{self.classes_[0]}'
END)"""
elif allSQL:
return f"""
(CASE
WHEN predict_neighbors = '{pos_label}' THEN proba_predict
ELSE NULL
END)"""
else:
return f"""
(CASE
Expand Down
2 changes: 1 addition & 1 deletion verticapy/plotting/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ def _compute_tsa(
start = 1
j = -1
else:
j = start - 1
j = start
start = 0
has_se = False
if X_pred.shape[1] > 1:
Expand Down