Skip to main content

ML-Copilot-Agent

ML-Copilot is an interactive machine learning assistant that streamlines the process of data preprocessing, model training, evaluation, plotting results, and generating documentation—all through a command-line interface powered by OpenAI's GPT 4o.

The framework is build as an llm-agent with llama-index workflow, which is able to execute realtime code through code-intepreter which is present as a tool with the llm-agenmt.

Full Documentation available on Read the Docs

How to use ?: Watch short video

LLM-Agent-Features

  • List Files: View files in the current directory.
  • Data Preprocessing: Preprocess data for binary classification tasks with customizable instructions.
  • Model Training: Train binary classification models using algorithms like Logistic Regression, SVM, or Random Forest.
  • Model Evaluation: Evaluate trained models and obtain metrics such as accuracy, precision, recall, F1-score, and AUC.
  • Plotting: Generate various plots (e.g., bar plots, PCA plots, correlation matrices) from data or evaluation results.
  • Interactive Workflow: Seamlessly navigate through different steps with an intuitive command-line interface.
  • Custom Instruction: Can provide custom instruction to execute code, for example "Perform pca on temp_csv, save the pca results, plot the pca and save plot inside results folder

Please make a conda environment before begin

Direct Installation

pip install ml-copilot-agent

Manual Installation

  1. Clone the repository:
git clone https://github.com/VatsalPatel18/ml-copilot-agent.git
  1. Navigate to the project directory:
cd ml-copilot
  1. Install the required dependencies:
pip install -r requirements.txt

Ensure you have Python 3.7 or higher installed on your system.

Usage

Download the file for test run

wget https://raw.githubusercontent.com/VatsalPatel18/ml-copilot-agent/master/temp_csv1.data
  1. Get Your OpenAI API Key::

To use the OpenAI API, you need to obtain your API key. If you haven't done so yet, follow these steps:

  • Go to the OpenAI API keys page
  • Log in to your OpenAI account (or sign up if you don't have one).
  • Create a new API key and copy it

Remember to delete the key after use.

  1. Run ML-Copilot:
python -m ml_copilot_agent paste-your-openai-api-key

Replace paste-your-openai-api-key with your actual OpenAI API key.

  1. Interact with ML-Copilot:

Once started, ML-Copilot will prompt you for commands. You can enter any of the following commands:

  • show files: Show files in the current directory.
  • preprocess: Preprocess data for a binary classification task.
  • train: Train a binary classification model.
  • evaluate: Evaluate the trained model.
  • plot: Generate plots from data or evaluation results.
  • document: Generate a documentation report. (Under Development)
  • exit: Terminate the workflow.

Example Workflow

Step 1: List Files

list files

View all files in the current directory to ensure your dataset is available.

Step 2: Preprocess Data

preprocess
  • Dataset Path: Provide the path to your dataset (e.g., data/dataset.csv).
  • Target Column Name: Specify the name of the target column in your dataset.
  • Save Path: Choose where to save the preprocessed data (default is data/preprocessed_data.csv).
  • Additional Instructions: (Optional) Add any specific preprocessing instructions (e.g., "use standard scaler").

Step 3: Train Model

train
  • Model Save Path: Specify where to save the trained model (default is models/model.pkl).
  • Additional Instructions: (Optional) Specify model preferences (e.g., "use SVM classifier").

Step 4: Evaluate Model

evaluate
  • Evaluation Save Path: Specify where to save the evaluation results (default is results/evaluation.txt).

Step 5: Plot Results

plot
  • Data File Path: Provide the data file path or press Enter to use default evaluation results or preprocessed data.
  • Additional Plotting Instructions: (Optional) Specify the type of plot (e.g., "make a bar plot of accuracy and precision").

Step 7: Custom Instructions

custom instruction
  • Provide any kind of custom instruction that you would like to execute code.

Step 8: Exit

exit

Terminate the workflow when you are done.

Dependencies

  • Python 3.7 or higher
  • OpenAI GPT Models
  • LlamaIndex
  • Pandas
  • Scikit-learn
  • Matplotlib
  • Seaborn

Install all dependencies using:

pip install -r requirements.txt

Project Structure

  • ml_copilot/
  • __init__.py: Initialization and configuration.
  • __main__.py: Entry point of the application.
  • workflow.py: Defines the MLWorkflow class and all associated steps and events.
  • data/: Directory where preprocessed data is saved.
  • models/: Directory where trained models are saved.
  • results/: Directory where evaluation results and plots are saved.
  • reports/: Directory where documentation reports are saved.
  • requirements.txt: Contains all Python dependencies.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Commit your changes with clear and descriptive messages.
  4. Push to your fork and submit a pull request.

License

This project is licensed under the CC-BY-NC-ND-4.0 License.

Acknowledgments

  • Thanks to the developers of OpenAI and LlamaIndex for providing the foundational tools that make this project possible.

Contact

For any questions or suggestions, feel free to open an issue or contact vatsal1804@gmail.com.

Metadata

Release files for ml-copilot-agent 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ml-copilot-agent 0.1.9
File Size Uploaded
ml_copilot_agent-0.1.9.tar.gz 14.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ml-copilot-agent 0.1.9
File Interpreter ABI Platform
ml_copilot_agent-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 29.1 kB

Release files / ml_copilot_agent-0.1.9.tar.gz

Download URL ml_copilot_agent-0.1.9.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2f33342f8c1de1d9870c33a72ea331cf1f0a253c13f76d4a7607f49deab9eeae
BLAKE2b-256 checksum
How to use checksums
c3d1a8696454702ef73d3d792c80987deff69c2d4e2e46232827f1e7d81e7ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.7 Linux/6.8.0-48-generic

Release files / ml_copilot_agent-0.1.9-py3-none-any.whl

Download URL ml_copilot_agent-0.1.9-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
828417f226f2ec637ab3e3d8a2d634ccb32227c71376f4ea2524b3d8ebc1ce64
BLAKE2b-256 checksum
How to use checksums
6ee6c27580c4eafe339c9c6952ed68a5c09b45a0cd076eac9a849155548097e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.7 Linux/6.8.0-48-generic

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page