Car Evaluation Model: Design And User Guide

Dive into our Car Evaluation Model, understanding its importance and usage. From its conception to implementation, we'll guide you through.

Case Study Overview

Car Evaluation Database (June 1997)

  • Creator/Donor: Marko Bohanec, Blaz Zupan

  • Origin: Based on a DEX decision model from 1990, this project evaluates car features.

Database Details:

  • Built on a hierarchical decision model.

  • Attributes:

    • buying: Buying price (categorical).

    • maint: Maintenance price (categorical).

    • doors: Number of doors (categorical).

    • persons: Car capacity (categorical).

    • lug_boot: Luggage boot size (categorical).

    • safety: Estimated safety (categorical).

    • class: Car evaluation level (categorical); ranges from unacceptable to very good.

  • No missing values.

Stats:

  • Instances: 1,728

  • Attributes: 6

  • Class Distribution:

    • unacc: 1,210 (70.023%)

    • acc: 384 (22.222%)

    • good: 69 (3.993%)

    • v-good: 65 (3.762%)

Program Design

A flow Chart of the Project

Figure 1 - A flow chart of the Project

The flow chart illustrates the process from acquiring a Kaggle dataset and storing it in MongoDB, to processing and applying a decision tree model for prediction.

GOOOL

Figure 2 - UML class diagram

  • A UML class diagram (Fig. 2) clarifies the OOP plan by illustrating classes and their interconnections, represented as lines.

Object-Oriented Architecture Design

Our car evaluation system exemplifies object-oriented programming, providing an organized framework for data processing and model implementation.

Building the Program

We start our Python program by importing the CSV data with pandas and performing initial quality checks.

Data Storage with MongoDB

We use MongoDB for its advantages over traditional databases. Our program integrates seamlessly with MongoDB for data upload and checks, and we retrieve data from it for preprocessing.

Implementing the Model

The implementation of the decision tree algorithm presents early challenges, particularly in handling the data. Data splitting, Predicting on the test set and model accuracy checks.

Then we have a main.py that gathers all the py files and runs them in a single file.

Visual Representation of the Decision Tree

Our program provides a visual display of the decision tree, including decision nodes, leaf nodes, and sub-trees, allowing users to visually understand the model.

Interacting with the GUI

Discover how to effectively use our Car Evaluation Model through the user-friendly graphical user interface (GUI) built with Streamlit, a powerful Python framework for web apps.

Secure Login

Upon launch, you'll encounter a friendly welcome screen. For security, we've implemented a login feature, requiring a username and password. For demonstration purposes, the credentials are currently set to "Caleb" for the username and "password123" for the password. In real-world use, you can customize these credentials.

Model Loading

After logging in, the program automatically handles model loading. The CarEvaluationModel class initializes with None at this stage, simplifying your experience.

Setting Car Features

Evaluate cars based on their attributes using our intuitive GUI. Input the car's details effortlessly:

  • Buying Price: Choose from "vhigh," "high," "med," or "low."

  • Maintenance Price: Select "vhigh," "high," "med," or "low."

  • Number of Doors: Options include "2," "3," "4," or "5more."

  • Number of Persons: Choose from "2," "4," or "more."

  • Luggage Boot Size: Options include "small," "med," or "big."

  • Safety Level: Select "low," "med," or "high."

Predict Car Class

Once you've entered the attributes, predict the car class by clicking "Predict." The program utilizes the decision tree model and displays the predicted class on the GUI for easy assessment.

Visualize the Decision Tree

In addition to predictions, our program lets you visualize the decision tree. Click "Show Decision Tree" to explore the model's decision-making process visually.

User Interface

Explore our Car Evaluation Model's user interface, designed for efficiency and ease of use. The GUI streamlines user interactions, ensuring a smooth experience throughout.

Welcome Screen & Security

Upon launch, users encounter a welcoming interface, setting a friendly tone for their car evaluation experience. User authentication enhances security; a username and password are required for access. Passwords undergo secure hashing and are matched with stored hashes in the MongoDB database for verification.

Function Buttons

In the GUI's main section, you'll find essential function buttons for user convenience:

  • Predict Car Class: Users can input car attributes and receive predictions regarding the car's acceptability class. This includes factors like buying price, maintenance cost, doors, passenger capacity, luggage boot size, and safety.

  • Show Decision Tree: Provides a visual representation of the decision tree model used in car evaluation, enabling users to explore decision-making processes.

Streamlit Framework

We used the Streamlit framework, a versatile Python library, to simplify web application creation with minimal effort. This enabled us to customize and optimize the interface to meet our specific needs.

User Interface Design Philosophy

This section provides a concise guide to effectively using the Car Evaluation Model program. It covers the entire process, from setup to prediction and evaluation.

How to Use the Program

This section offers a detailed guide on effectively using the Car Evaluation Model program. It spans the entire workflow, from environment setup to prediction and model evaluation.

Prerequisites

Before using the Car Evaluation Model program, ensure you have these prerequisites:

  1. Python Environment: Set up a Python environment.

  2. Virtual Environment (Optional): Consider creating and activating a virtual environment for isolating dependencies.

  3. Required Libraries: Install necessary Python libraries using pip install -r requirements.txt.

Step 1: Setting Up the Virtual Environment (Optional)

If using a virtual environment, follow these steps:

  1. Open your terminal or command prompt.

  2. Navigate to your project directory.

  3. Create a new virtual environment, e.g., python -m venv car_evaluation_venv.

  4. Activate it:

    • On Windows: car_evaluation_venv\Scripts\activate

    • On macOS and Linux: source car_evaluation_venv/bin/activate

Step 2: Running the Program

To run the Car Evaluation Model program:

  1. Data Loading: Run python main.py to load data, insert it into MongoDB, split it into train and test sets, build the model on the train set, predict on the test set, and evaluate accuracy.

  2. Start Streamlit: Execute streamlit run app.py to launch the web-based interface. Log in and interact with the Car Evaluation Model.

Step 3: User Interaction

In the Streamlit app:

  1. Log In: Enter your username and password to access the user-friendly interface.

  2. Set Car Features: On the sidebar, choose car features for evaluation, such as "Buying," "Maint," and more.

  3. Predict: After selecting car features, click "Predict" to see the model's evaluation.

  4. Show Decision Tree: To explore the decision-making process, click "Show Decision Tree" for a visual representation.

Insights and Mastery

We'll delve into the theory behind our Car Evaluation Model, discuss our algorithm choices, and share implementation insights. We'll also explore the model's accuracy implications and real-world applications.

Theoretical Foundations

Decision Trees

Our Car Evaluation Model's core is the decision tree algorithm. Decision trees are versatile in machine learning and ideal for classifying cars into acceptability classes.

Decision trees have nodes representing attribute choices and leaf nodes showing class labels. They guide car classification into 'unacc,' 'acc,' 'good,' or 'vgood' based on features.

MongoDB for Data Management

MongoDB, a NoSQL database, is crucial for flexible data storage and retrieval. Its ability to handle complex hierarchical data aligns well with our decision tree structure, significantly enhancing project success.

Algorithm Selection

The decision tree algorithm's suitability is validated by its widespread use in interpretable machine learning. It effectively reveals attribute hierarchy and aligns with our car evaluation task.

Project Insights

Data Preprocessing

We faced data preprocessing challenges. The dataset had categorical attributes converted to numerical values. We also addressed missing data, ensuring high-quality, complete data for model training and evaluation.

Model Evaluation

Our model underwent rigorous testing, particularly for accuracy. It was trained and tested using performance metrics, revealing strengths and areas for improvement, achieving 95% accuracy.

Implications and Real-World Applications

Our accurate Car Evaluation Model has real-world benefits. It helps consumers choose cars wisely by assessing factors like price, maintenance, and safety.

Moreover, it aids the automotive industry. Dealerships can optimize stock and pricing, while manufacturers gain insights into customer preferences.

This tool enhances the car buying experience and automotive market efficiency, supported by MongoDB.

REFERENCES

  1. Bohanec,Marko. (1997). Car Evaluation. UCI Machine Learning Repository. https://doi.org/10.24432/C5JP48.

  2. M. Masum. (2022). Car Evaluation Analysis Using Decision Tree Classifier. https://towardsdatascience.com/car-evaluation-analysis-using-decision-tree-classifier-61a8ff12bf6f

  3. Harjot Pahwa. (2019)The Classifier — Evaluating a Car’s Acceptability https://medium.com/analytics-vidhya/the-classifier-part-2-2-38df3de1f9b3

  4. Maheswari Raju. (2022) Supervised Machine Learning for Car Model Evaluation https://medium.com/low-code-for-advanced-data-science/supervised-machine-learning-for-car-model-evaluation-with-knime-a25938f13def

  5. Xiyang Hu, C. Rudin, M. Seltzer. (2019) Optimal Sparse Decision Trees https://www.semanticscholar.org/reader/95ed088f614cd1eb0033c2bd4373080a695a65e0