File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change 1
- # spam_detector_ai/test_and_tuning/test.py
2
-
3
1
import os
4
2
import sys
3
+ from pathlib import Path
4
+
5
+ project_root = Path (__file__ ).parent .parent .parent
6
+ sys .path .append (str (project_root ))
5
7
6
8
from sklearn .metrics import accuracy_score , classification_report , confusion_matrix
7
9
from sklearn .model_selection import train_test_split
11
13
from spam_detector_ai .prediction .predict import SpamDetector
12
14
from spam_detector_ai .training .train_models import ModelTrainer
13
15
14
- sys .path .insert (0 , os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , '..' )))
15
-
16
16
17
17
class TestModel :
18
18
def __init__ (self ):
19
19
self .classifier_types = [ClassifierType .NAIVE_BAYES , ClassifierType .RANDOM_FOREST , ClassifierType .SVM ]
20
20
self .logger = init_logging ()
21
- # Determine the directory of this file
22
- current_dir = os .path .dirname (os .path .abspath (__file__ ))
23
- # Assuming the spam_detector_ai directory is one level up from the current directory
24
- base_dir = os .path .dirname (current_dir )
25
- data_path = os .path .join (base_dir , 'data/spam.csv' )
21
+ data_path = os .path .join (project_root , 'spam_detector_ai' , 'data' , 'spam.csv' )
26
22
self .initial_trainer = ModelTrainer (data_path = data_path , logger = self .logger )
27
23
self .processed_data = self .initial_trainer .preprocess_data_ ()
28
24
You can’t perform that action at this time.
0 commit comments