Make some ruff fixes (#8154)

* Make some ruff fixes

* Undo manual fix

* Undo manual fix

* Updates from ruff=0.0.251
This commit is contained in:
Christian Clauss
2023-03-01 17:23:33 +01:00
committed by GitHub
parent 1c15cdff70
commit 64543faa98
73 changed files with 151 additions and 203 deletions

View File

@@ -55,6 +55,7 @@ def output(example_no, data_set):
return train_data[example_no][1]
elif data_set == "test":
return test_data[example_no][1]
return None
def calculate_hypothesis_value(example_no, data_set):
@@ -68,6 +69,7 @@ def calculate_hypothesis_value(example_no, data_set):
return _hypothesis_value(train_data[example_no][0])
elif data_set == "test":
return _hypothesis_value(test_data[example_no][0])
return None
def summation_of_cost_derivative(index, end=m):

View File

@@ -229,7 +229,7 @@ def report_generator(
"""
# Fill missing values with given rules
if fill_missing_report:
df.fillna(value=fill_missing_report, inplace=True)
df = df.fillna(value=fill_missing_report)
df["dummy"] = 1
numeric_cols = df.select_dtypes(np.number).columns
report = (
@@ -338,7 +338,7 @@ def report_generator(
)
report.columns.name = ""
report = report.reset_index()
report.drop(columns=["index"], inplace=True)
report = report.drop(columns=["index"])
return report

View File

@@ -129,7 +129,7 @@ class SmoSVM:
# error
self._unbound = [i for i in self._all_samples if self._is_unbound(i)]
for s in self.unbound:
if s == i1 or s == i2:
if s in (i1, i2):
continue
self._error[s] += (
y1 * (a1_new - a1) * k(i1, s)
@@ -225,7 +225,7 @@ class SmoSVM:
def _choose_alphas(self):
locis = yield from self._choose_a1()
if not locis:
return
return None
return locis
def _choose_a1(self):
@@ -423,9 +423,8 @@ class Kernel:
return np.exp(-1 * (self.gamma * np.linalg.norm(v1 - v2) ** 2))
def _check(self):
if self._kernel == self._rbf:
if self.gamma < 0:
raise ValueError("gamma value must greater than 0")
if self._kernel == self._rbf and self.gamma < 0:
raise ValueError("gamma value must greater than 0")
def _get_kernel(self, kernel_name):
maps = {"linear": self._linear, "poly": self._polynomial, "rbf": self._rbf}