Skip to content

A collection of Python AI/ML and algorithm-visualization scripts—covering data cleaning, regression (including manual polynomial), machine learning classifier comparisons, hyperparameter tuning, and a Tkinter GUI for the Knight’s Tour—crafted for coursework and experimentation.

Notifications You must be signed in to change notification settings

omarzeineh/Python_AI_Scripts

Repository files navigation

python_AI_Scripts

This repository contains a collection of Python scripts covering data preprocessing, machine learning, regression, and algorithm visualization.
The scripts were created for coursework and experiments in AI and ML.

⚠️ Note: Some of these scripts rely on datasets (.csv / .xlsx) that are not included in this repository due to availability or licensing restrictions.
If you want to run those scripts, you will need to prepare or substitute similar datasets.


📂 Scripts Overview

1. data_cleaning.py

  • Cleans and merges raw datasets (gas flows, process parameters, and specs).
  • Handles outliers using the Interquartile Range (IQR).
  • Imputes missing values with column means.
  • Normalizes numerical features for machine learning.
  • Saves a cleaned dataset as CSV.
    ⚠️ Requires gas_flows.xlsx, process_parameters.xlsx, and IOP_specs.xlsx, which are not provided:contentReference[oaicite:0]{index=0}.

2. regression_model_fitting.py

  • Loads the cleaned dataset.
  • Fits Random Forest Regressors to predict C and MET.
  • Evaluates model performance using Root Mean Squared Error (RMSE).
    ⚠️ Requires cleaned_merged_data.csv, which is generated by data_cleaning.py:contentReference[oaicite:1]{index=1}.

3. manual_regression_model.py

  • Implements Polynomial Regression (degree = 2) manually using matrix algebra (Normal Equation).
  • Computes weights, predictions, and RMSE.
    ⚠️ Requires an external data.csv file:contentReference[oaicite:2]{index=2}.

4. polynomial_regression_plot.py

  • Fits a Polynomial Regression model with scikit-learn.
  • Splits dataset into train/test.
  • Calculates RMSE, predicts values, and plots fitted curves.
    ⚠️ Depends on data.csv:contentReference[oaicite:3]{index=3}.

5. polynomial_regression_fullfit.py

  • Fits polynomial regression on the entire dataset.
  • Evaluates RMSE across all points.
  • Plots regression curve.
    ⚠️ Requires data.csv:contentReference[oaicite:4]{index=4}.

6. knn_classifier.py

  • Custom implementation of K-Nearest Neighbors (KNN) from scratch.
  • Includes performance metrics (confusion matrix, accuracy, precision, recall, F1).
  • Uses a hardcoded sample dataset, so it can run without external data:contentReference[oaicite:5]{index=5}.

7. ml_classifiers_comparison.py

  • Compares multiple classifiers on the Iris dataset:
    • KNN
    • Decision Trees
    • Random Forests
    • Naive Bayes
    • Linear SVM
    • Kernel SVM
  • Reports classification accuracy for each.
    ✅ Uses scikit-learn’s built-in Iris dataset, no extra files needed:contentReference[oaicite:6]{index=6}.

8. ml_hyperparameter_tuning.py

  • Performs hyperparameter tuning for KNN, Decision Trees, Random Forests, and SVMs.
  • Finds optimal values for k, tree depth, estimator count, kernel, and gamma.
    ⚠️ Requires data.xlsx containing moon, circle, and blob datasets:contentReference[oaicite:7]{index=7}.

9. knights_tour_gui.py

  • Tkinter GUI to visualize the Knight’s Tour problem on chessboards (5x5 → 8x8).
  • Allows setting starting position and animation speed.
  • Animates knight’s path with board highlighting.
    ✅ Runs without datasets.
    ⚠️ Requires a local knight.png image to display the knight piece:contentReference[oaicite:8]{index=8}.

🚀 How to Run

Clone the repository and run any script:

git clone https://github.com/yourusername/python_AI_Scripts.git
cd python_AI_Scripts
python knn_classifier.py

About

A collection of Python AI/ML and algorithm-visualization scripts—covering data cleaning, regression (including manual polynomial), machine learning classifier comparisons, hyperparameter tuning, and a Tkinter GUI for the Knight’s Tour—crafted for coursework and experimentation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages