Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧬 AI Heredity

A probabilistic artificial intelligence project that predicts the likelihood of individuals carrying a specific gene and exhibiting a related trait.

The program uses family relationships, known traits, genetic inheritance rules, and Bayesian probability to calculate probability distributions for every person in a family dataset.


✨ Features

  • Predicts the probability of having 0, 1, or 2 copies of a gene
  • Predicts the probability of exhibiting a genetic trait
  • Supports parent-child inheritance relationships
  • Handles known and unknown trait information
  • Calculates joint probabilities across all possible family configurations
  • Normalizes probability distributions
  • Processes multiple CSV family datasets
  • Uses only Python’s standard library

🧠 AI Concepts Used

  • Bayesian Inference
  • Conditional Probability
  • Joint Probability
  • Probability Distributions
  • Probabilistic Reasoning
  • Genetic Inheritance Modeling
  • Enumeration-Based Inference

🛠 Technologies

  • Python 3
  • CSV data processing
  • Standard Python Library

📂 Project Structure

.
├── data/
│   ├── family0.csv
│   ├── family1.csv
│   └── family2.csv
├── heredity.py
├── requirements.txt
├── .gitignore
├── LICENSE
└── README.md

📊 Dataset Format

Each CSV file contains the following fields:

name,mother,father,trait

Example:

name,mother,father,trait
Harry,Lily,James,
James,,,1
Lily,,,0

The trait value can be:

  • 1 — the person has the trait
  • 0 — the person does not have the trait
  • Empty — the trait is unknown

🚀 Installation

Clone the repository:

git clone https://github.com/ambertiwary27/ai-heredity.git

Move into the project directory:

cd ai-heredity

No external libraries are required.


▶️ Run the Project

Run the program with any provided family dataset:

python3 heredity.py data/family0.csv
python3 heredity.py data/family1.csv
python3 heredity.py data/family2.csv

📈 Example Output

Harry:
  Gene:
    2: 0.0092
    1: 0.4557
    0: 0.5351
  Trait:
    True: 0.2665
    False: 0.7335

James:
  Gene:
    2: 0.1976
    1: 0.5106
    0: 0.2918
  Trait:
    True: 1.0000
    False: 0.0000

Lily:
  Gene:
    2: 0.0036
    1: 0.0136
    0: 0.9827
  Trait:
    True: 0.0000
    False: 1.0000

⚙️ How It Works

The program evaluates every possible combination of:

  • Individuals who may have one copy of the gene
  • Individuals who may have two copies of the gene
  • Individuals who may exhibit the trait

For every valid configuration, it calculates the joint probability based on:

  • Unconditional gene probabilities
  • Parent-to-child gene transmission
  • Mutation probability
  • Conditional trait probability

The resulting probabilities are accumulated and normalized so that each distribution sums to 1.


🧬 Genetic Inheritance Model

A child receives one gene copy from each parent.

The probability of passing the gene depends on how many copies the parent has:

Gene Copies Probability of Passing Gene
2 0.99
1 0.50
0 0.01

The small probability for a parent with zero copies represents genetic mutation.


📚 Learning Outcomes

This project demonstrates:

  • Modeling uncertainty using probability
  • Applying Bayesian reasoning
  • Calculating joint probabilities
  • Using conditional probabilities
  • Performing exhaustive probabilistic inference
  • Normalizing probability distributions
  • Modeling real-world inheritance relationships

🌍 Possible Applications

The concepts demonstrated in this project are relevant to:

  • Genetic risk analysis
  • Medical decision-support systems
  • Bayesian networks
  • Diagnostic systems
  • Family inheritance modeling
  • Probabilistic expert systems

This project is educational and should not be used for real medical diagnosis.


🙏 Acknowledgements

This project was developed as part of Harvard University’s CS50’s Introduction to Artificial Intelligence with Python.


👨‍💻 Author

Amber Kumar Tiwary


⭐ Support

If you found this project useful, consider giving the repository a star.

About

AI-based genetic inheritance prediction using Bayesian inference, joint probability, and probabilistic reasoning in Python.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages