Skip to content

Commit

Permalink
Cluster SVM Lint Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
B3at committed Aug 20, 2024
1 parent bdd8308 commit 8eaf952
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugins/cluster_svm_visualization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ClusterSVM(QHAnaPluginBase):
name = _plugin_name
version = __version__
description = "Prints provided Data into a Scatter Plot with SVM."
tags = ["cluster","SVM", "visualization"]
tags = ["cluster", "SVM", "visualization"]

def __init__(self, app: Optional[Flask]) -> None:
super().__init__(app)
Expand Down
6 changes: 4 additions & 2 deletions plugins/cluster_svm_visualization/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class MicroFrontend(MethodView):
"""Micro frontend for the Cluster SVM Visualization plugin."""

@VIS_BLP.html_response(
HTTPStatus.OK, description="Micro frontend for the Cluster SVM Visualization plugin."
HTTPStatus.OK,
description="Micro frontend for the Cluster SVM Visualization plugin.",
)
@VIS_BLP.arguments(
InputParametersSchema(
Expand All @@ -107,7 +108,8 @@ def get(self, errors):
return self.render(request.args, errors)

@VIS_BLP.html_response(
HTTPStatus.OK, description="Micro frontend for the Cluster SVM Visualization plugin."
HTTPStatus.OK,
description="Micro frontend for the Cluster SVM Visualization plugin.",
)
@VIS_BLP.arguments(
InputParametersSchema(
Expand Down
1 change: 0 additions & 1 deletion plugins/cluster_svm_visualization/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class InputParametersSchema(FrontendFormBaseSchema):
},
)


@post_load
def make_input_params(self, data, **kwargs) -> InputParameters:
return InputParameters(**data)
16 changes: 8 additions & 8 deletions plugins/cluster_svm_visualization/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ def visualization_task(self, db_id: int) -> str:
size="size",
hover_name="ID",
color="Cluster ID",
hover_data={"size":False}
)
hover_data={"size":False},
)

if do_svm:
cluster_list = [[] for _ in range(0, max_cluster+1)]
cluster_list = [[] for _ in range(0, max_cluster + 1)]
for idx, label in enumerate(label_list):
cluster_list[label].append([pt_x_list[idx], pt_y_list[idx]])
cluster_list[label].append([pt_x_list[idx], pt_y_list[idx]])

for i, cl1 in enumerate(cluster_list):
for j, cl2 in enumerate(cluster_list):
Expand All @@ -114,9 +114,9 @@ def visualization_task(self, db_id: int) -> str:
cluster_label = cluster_label + [j for _ in range(0, len(cl2))]
cl = cl1 + cl2

clf = svm.SVC(kernel='linear')
clf = svm.SVC(kernel="linear")
clf.fit(cl, cluster_label)

a = -clf.coef_[0][0] / clf.coef_[0][1]
b = clf.intercept_[0] / clf.coef_[0][1]

Expand All @@ -126,8 +126,8 @@ def visualization_task(self, db_id: int) -> str:
go.Scatter(
x=x_range,
y=[a * x - b for x in x_range],
mode='lines',
name=f'SVM for cluster {i} and {j}',
mode="lines",
name=f"SVM for cluster {i} and {j}",
hoveron="fills",
)
)
Expand Down

0 comments on commit 8eaf952

Please sign in to comment.