Skip to content

Commit ac5bfc5

Browse files
authored
Merge pull request #2 from flamehaven01/codex/fix-linting-issues-with-black-k1h3bc
Fix ruff lint violations in ml module
2 parents d0e15f7 + 4e5641f commit ac5bfc5

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/slop_detector/ml/classifier.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,21 @@ def predict(self, features: Dict[str, float]) -> Tuple[float, float]:
273273
raise RuntimeError("Model not trained. Call train() first.")
274274

275275
# Convert features to vector
276-
X = np.array([[features[feat] for feat in self.FEATURE_NAMES]])
276+
x = np.array([[features[feat] for feat in self.FEATURE_NAMES]])
277277

278278
if self.model_type == "random_forest":
279-
proba = self.rf_model.predict_proba(X)[0]
279+
proba = self.rf_model.predict_proba(x)[0]
280280
return proba[1], max(proba)
281281

282282
elif self.model_type == "xgboost":
283283
if not self.xgb_model:
284284
raise RuntimeError("XGBoost model not available")
285-
proba = self.xgb_model.predict_proba(X)[0]
285+
proba = self.xgb_model.predict_proba(x)[0]
286286
return proba[1], max(proba)
287287

288288
elif self.model_type == "ensemble":
289-
rf_proba = self.rf_model.predict_proba(X)[0]
290-
xgb_proba = self.xgb_model.predict_proba(X)[0] if self.xgb_model else rf_proba
289+
rf_proba = self.rf_model.predict_proba(x)[0]
290+
xgb_proba = self.xgb_model.predict_proba(x)[0] if self.xgb_model else rf_proba
291291

292292
# Weighted average
293293
ensemble_proba = 0.5 * rf_proba + 0.5 * xgb_proba

src/slop_detector/ml/training_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def extract_features(self, file_path: Path, detector) -> Optional[TrainingExampl
186186
avg_function_length = total_func_lines / len(functions) if functions else 0.0
187187
else:
188188
avg_function_length = 0.0
189-
except:
190-
avg_function_length = 0.0
189+
except Exception:
190+
avg_function_length = 0.0
191191

192192
# Count cross-language and hallucination patterns
193193
cross_language_count = sum(

0 commit comments

Comments
 (0)