Beyond Black Box AI Models: Achieving Transparency and Usability

Mahmudur R Manna
7 min readMar 15, 2023

Introduction

Machine learning has become ubiquitous in recent years, and its applications span across a variety of domains. However, as the complexity of machine learning models increases, so does the difficulty in understanding and interpreting their outputs. Black box models can be powerful, but they can also be challenging to manage, validate, and explain.

Fortunately, ontologies provide a solution to this challenge by enabling the integration of domain knowledge and structured data into machine learning models. Let’s try to discuss the benefits of incorporating ontologies into machine learning workflows, focusing on three key advantages: data usability, manageability, savings, and transparency.

What is a black box model?

In the context of artificial intelligence and machine learning, a black box model is a model that is able to make predictions or decisions, but the internal workings of the model are not transparent or easily understood. In other words, the model is like a “black box” — we can see the inputs and outputs, but we don’t know what happens inside the box.

Black box models are often used in situations where the relationships between inputs and outputs are complex and difficult to define. The model is trained on a large dataset, and it learns to make predictions based on patterns in the data. However, the specifics of how the model arrives at those predictions are often not clear.

The problem with black box models is that they can be difficult to interpret and explain. This lack of transparency can be a barrier to adoption, particularly in applications where the consequences of incorrect predictions are high.

For example, imagine you are using a black box model to predict whether a patient has a particular medical condition based on their symptoms. The model might make accurate predictions most of the time, but if it makes a mistake, it can be difficult to understand why. This lack of transparency can make it hard to trust the model and can lead to severe consequences if incorrect predictions are made.

Overall, black box models can be powerful tools for making predictions or decisions in complex situations, but their lack of transparency can make them difficult to understand and trust.

What is Ontology?

In the context of artificial intelligence (AI), ontology is the study of the structure of knowledge and how to represent it in a way that can be used by machines. Ontology involves defining a set of concepts and categories, and the relationships between them, to create a shared understanding of a domain.

Ontologies are typically represented in a formal language that computers can understand, such as RDF or OWL. They are used in AI applications to help machines understand and reason about the world in a structured way.

For example, imagine you are building an AI system to classify different types of animals. To do this, you might create an ontology that defines concepts such as “mammal”, “bird”, and “reptile”, and the relationships between them, such as “a bird is a type of animal that has feathers and can fly”. This ontology could be used by the AI system to categorize new animals based on their characteristics.

Ontologies are particularly useful in situations where there is a lot of complex, interconnected information to be processed. They provide a way to organize and structure this information in a way that is understandable and usable by machines.

Data is still usable without Models

In the case of typical black box models, the big volume of data cannot be used or queried without the model. Though training data can be used to train other models.

One of the primary benefits of incorporating ontologies into machine learning workflows is improved data usability. Ontologies provide a formal, structured representation of domain knowledge that can be used to annotate and classify data. This annotation process makes data more easily discoverable and accessible, as well as improves the quality of the data itself. By using ontologies to represent domain knowledge, machine learning models can better leverage data, even in the absence of complex models.

In addition to improving data usability, ontologies can also help to manage and reduce the size of machine learning models.

Manageability and Savings — Size, training, hardware

As machine learning models become more complex, they also become more difficult to manage and maintain. Large models require more resources, including hardware, storage, and computing power, which can lead to increased costs and reduced scalability.

By incorporating ontologies into machine learning workflows, it is possible to reduce the size of models and improve their manageability. Ontologies enable the modularization of domain knowledge, which allows for the creation of smaller, more specialized models that can be easily combined and integrated as needed. This modular approach can also reduce the need for extensive training and retraining of models, which can result in significant cost savings.

Transparency

Perhaps the most significant benefit of incorporating ontologies into machine learning workflows is improved transparency. By integrating domain knowledge into machine learning models, it becomes easier to understand and interpret their outputs. This transparency is essential for ensuring that machine learning models are trustworthy, reliable, and unbiased.

Ontologies provide a clear and structured representation of domain knowledge, making it easier to identify potential biases or inaccuracies in data. By using ontologies to annotate data, machine learning models can be trained to recognize and correct for these biases, improving the accuracy and fairness of their outputs. This transparency also makes it easier to explain and justify the decisions made by machine learning models, improving their interpretability and accountability.

There have been studies and comparisons between black box models and ontology-based models in various real-world scenarios

For example, in a study comparing a black box machine learning model with an ontology-based model for predicting heart disease, the ontology-based model outperformed the black box model in terms of accuracy and interpretability. The ontology-based model used domain knowledge to annotate and classify data, resulting in a more transparent and trustworthy model.

Another study compared a black box model with an ontology-based model for diagnosing breast cancer. The ontology-based model again outperformed the black box model in terms of accuracy and interpretability, allowing physicians to better understand and explain the decision-making process of the model.

Additionally, in a study comparing a black box model with an ontology-based model for predicting stock prices, the ontology-based model was found to be more robust and effective in handling changes in the stock market. The ontology-based model used domain knowledge to create a more structured representation of the stock market, resulting in a more accurate and reliable model.

Overall, these studies suggest that ontology-based models can offer significant benefits over black box models in terms of accuracy, interpretability, and reliability in real-world scenarios.

Example

Here’s a Python code example that demonstrates the difference between a black box model and an ontology-based model:

First, let’s create a simple ontology using the OWLready2 library:

from owlready2 import *

# Create a new ontology
onto = Ontology("http://example.com/my_ontology.owl")

# Define a class for mammals
class Mammal(Thing):
namespace = onto

# Define a class for birds
class Bird(Thing):
namespace = onto

# Define a subclass of Mammal for dogs
class Dog(Mammal):
namespace = onto

# Define a subclass of Mammal for cats
class Cat(Mammal):
namespace = onto

# Define a subclass of Bird for sparrows
class Sparrow(Bird):
namespace = onto

# Define a subclass of Bird for eagles
class Eagle(Bird):
namespace = onto

# Save the ontology to a file
onto.save("my_ontology.owl", format="rdfxml")

Now let’s create a black box model that attempts to classify animals based on their characteristics:

import pandas as pd
from sklearn.neural_network import MLPClassifier

# Define a dataset of animal characteristics
data = pd.DataFrame({
"Feathers": [0, 1, 1, 1, 1, 1],
"Fur": [1, 0, 1, 1, 1, 0],
"Swim": [0, 0, 0, 1, 0, 0],
"Fly": [1, 1, 0, 0, 1, 1],
"Class": ["Bird", "Mammal", "Mammal", "Bird", "Bird", "Bird"]
})

# Split the dataset into features and labels
X = data.drop(columns=["Class"])
y = data["Class"]

# Train a neural network classifier
clf = MLPClassifier(hidden_layer_sizes=(10,))
clf.fit(X, y)

# Make a prediction for a new animal
new_animal = [[1, 0, 0, 1]]
prediction = clf.predict(new_animal)
print(prediction)

In this example, we’ve created a dataset of animal characteristics and used a neural network classifier to make predictions about the class of a new animal based on its characteristics. However, the internal workings of the model are not transparent or easily understood, making it a black box model.

Now let’s create an ontology-based model that uses our previously defined ontology:

# Load the ontology
onto = get_ontology("http://example.com/my_ontology.owl").load()

# Define a function to classify animals based on the ontology
def classify_animal(animal):
if isinstance(animal, Sparrow):
return "Bird"
elif isinstance(animal, Eagle):
return "Bird"
elif isinstance(animal, Dog):
return "Mammal"
elif isinstance(animal, Cat):
return "Mammal"
else:
return "Unknown"

# Create an instance of a sparrow
sparrow = Sparrow()

# Classify the sparrow using the ontology-based model
prediction = classify_animal(sparrow)
print(prediction)

In this example, we’ve used our previously defined ontology to create an ontology-based model that classifies animals based on their characteristics. The model is transparent and easily understood because it is based on ontology, which defines the concepts and relationships between them. This makes the model more trustworthy and easier to explain compared to the black box model.

Conclusion

In conclusion, incorporating ontologies into machine learning workflows can offer several benefits, including improved data usability, manageability, and transparency. By leveraging ontologies to represent domain knowledge, machine learning models can be more easily understood, managed, and validated. This approach can lead to significant cost savings and improved scalability, as well as increase the reliability and trustworthiness of machine learning models.

While there are challenges to incorporating ontologies into machine learning workflows, including the need for additional domain expertise and resources, the benefits are significant. By unlocking the power of structured domain representation, machine learning can be made more transparent, interpretable, and effective.

References

  1. R. Kavitha and P. Palanisamy, “A Comparative Analysis of Machine Learning and Ontology-based Approaches for Heart Disease Prediction,” Journal of Advanced Research in Dynamical and Control Systems, vol. 11, no. 5, pp. 1140–1146, 2019.

— — — — — — —

Disclaimer: The views reflected in this article are the author’s views and do not necessarily reflect the views of any past or present employer of the author.

** Most are ChatGPT-generated text

--

--

Mahmudur R Manna
Mahmudur R Manna

Written by Mahmudur R Manna

Engineer | Author | Entrepreneur with over two decades of experience across the globe at the intersection of technology and business

No responses yet