This project provides a decision tree-based model for predicting room numbers based on the receiving Wi-Fi signal strengths.
Before running the code, ensure you have the following dependencies installed on the Lab Machines:
- Python 3.10.12
- NumPy 1.24.3
- Matplotlib 3.7.2
To install the dependencies, run:
pip install matplotlib==3.7.2 numpy==1.24.3
Make sure you update the __main__
section of the decision_tree.py
file:
# Main for script execution:
if __name__ == '__main__':
dataset_path='wifi_db/clean_dataset.txt'
model = DecisionTreeModel(dataset_path, folds=10)
model.run()
dataset_path
: File path of the dataset to load and run the program on.folds
: Number of cross validation folds to perform on the dataset.
-
Download the file
decision_tree.py
to your local machine. -
Update the
__main__
as required with the dataset's file path. -
Execute the main script:
python decision_tree.py
This will do the followings:
- Build a Decision Tree Model on the entire dataset.
- Run cross validation based on the choosen number of
folds
. - Generate necessary plots and compute various cross validation classification metrics.
Upon successful execution, you will get:
- A visualization of the Decision Tree Model trained on the full dataset as
Tree.png
. - A confusion matrix saved as
Confusion_Matrix.png
generated from the k-fold cross validation. - A plot representing loss vs. depth of the tree saved as
Loss_vs_Depth.png
showing data-subsets become purer with increasing tree depth. - The maximum depth of the initial Decision Tree Model produced, printed on console.
- The accuracy of the algorithm computed from k-fold cross validation, printed on console.
- Cross validation classification metrics such as recall, precision and F1-measure for each class, printed on console.
- The macro-averaged values of the above metrics from each class, printed on console.
The .png
images produced will be saved in the same directory where the script is being executed.