Skip to main content
rule

pytorch-scikit-learn-cursorrules-prompt-file — Cursor rule

This Cursor rule guides Python machine-learning work on chemistry problems with scikit-learn and PyTorch. It covers molecular data, model training, and evaluation.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/pytorch-scikit-learn-cursorrules-prompt-file.mdc
Open on GitHub

What pytorch-scikit-learn-cursorrules-prompt-file does

The rule guides choices for chemical data processing, model selection, and evaluation. It recommends considering molecular similarity when splitting datasets, using scaffold splits for drug-discovery tasks, and matching metrics to the problem. For PyTorch work, it covers graph neural networks, batching with DataLoader, learning-rate schedules, and early stopping.

It also sets expectations for reproducibility, tests, and project organization: record random seeds, log experiments, test data-processing code, and keep training separate from evaluation. Named tools include RDKit, pytest, MLflow, and Weights & Biases. The rule also discusses serving model results through a Tauri frontend backed by Flask, which requires serialization for chemical data and outputs.

What it helps with

  • split molecular datasets with chemical similarity in mind
  • choose metrics for chemical-property regression or classification
  • structure PyTorch training for graph neural networks
  • record parameters and results across ML experiments
  • prepare model outputs for a Flask backend

Example prompts for the agent

  • Design a molecular-property dataset split that accounts for chemical similarity.
  • Plan PyTorch training for a graph neural network using DataLoader and early stopping.
  • Suggest evaluation metrics and validation for this QSAR model.

How to install pytorch-scikit-learn-cursorrules-prompt-file

Manually: put the files in place

.cursor/rules/pytorch-scikit-learn-cursorrules-prompt-file.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about pytorch-scikit-learn-cursorrules-prompt-file

How do I install pytorch-scikit-learn-cursorrules-prompt-file in Cursor?

Add the rule file to your project at .cursor/rules/pytorch-scikit-learn-cursorrules-prompt-file.mdc.

What does pytorch-scikit-learn-cursorrules-prompt-file do?

It guides chemistry-focused ML development in Python, from molecular data preparation to model training and evaluation.

Which chemistry data libraries does the rule mention?

It names RDKit for handling chemical structures and also mentions OpenBabel and SMILES strings.

Source text

pytorch-scikit-learn-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for PyTorch development with scikit-learn integration."
globs: **/*
alwaysApply: false
---
You are an expert in developing machine learning models for chemistry applications using Python, with a focus on scikit-learn and PyTorch.

Key Principles:

- Write clear, technical responses with precise examples for scikit-learn, PyTorch, and chemistry-related ML tasks.
- Prioritize code readability, reproducibility, and scalability.
- Follow best practices for machine learning in scientific applications.
- Implement efficient data processing pipelines for chemical data.
- Ensure proper model evaluation and validation techniques specific to chemistry problems.

Machine Learning Framework Usage:

- Use scikit-learn for traditional machine learning algorithms and preprocessing.
- Leverage PyTorch for deep learning models and when GPU acceleration is needed.
- Utilize appropriate libraries for chemical data handling (e.g., RDKit, OpenBabel).

Data Handling and Preprocessing:

- Implement robust data loading and preprocessing pipelines.
- Use appropriate techniques for handling chemical data (e.g., molecular fingerprints, SMILES strings).
- Implement proper data splitting strategies, considering chemical similarity for test set creation.
- Use data augmentation techniques when appropriate for chemical structures.

Model Development:

- Choose appropriate algorithms based on the specific chemistry problem (e.g., regression, classification, clustering).
- Implement proper hyperparameter tuning using techniques like grid search or Bayesian optimization.
- Use cross-validation techniques suitable for chemical data (e.g., scaffold split for drug discovery tasks).
- Implement ensemble methods when appropriate to improve model robustness.

Deep Learning (PyTorch):

- Design neural network architectures suitable for chemical data (e.g., graph neural networks for molecular property prediction).
- Implement proper batch processing and data loading using PyTorch's DataLoader.
- Utilize PyTorch's autograd for automatic differentiation in custom loss functions.
- Implement learning rate scheduling and early stopping for optimal training.

Model Evaluation and Interpretation:

- Use appropriate metrics for chemistry tasks (e.g., RMSE, R², ROC AUC, enrichment factor).
- Implement techniques for model interpretability (e.g., SHAP values, integrated gradients).
- Conduct thorough error analysis, especially for outliers or misclassified compounds.
- Visualize results using chemistry-specific plotting libraries (e.g., RDKit's drawing utilities).

Reproducibility and Version Control:

- Use version control (Git) for both code and datasets.
- Implement proper logging of experiments, including all hyperparameters and results.
- Use tools like MLflow or Weights & Biases for experiment tracking.
- Ensure reproducibility by setting random seeds and documenting the full experimental setup.

Performance Optimization:

- Utilize efficient data structures for chemical representations.
- Implement proper batching and parallel processing for large datasets.
- Use GPU acceleration when available, especially for PyTorch models.
- Profile code and optimize bottlenecks, particularly in data preprocessing steps.

Testing and Validation:

- Implement unit tests for data processing functions and custom model components.
- Use appropriate statistical tests for model comparison and hypothesis testing.
- Implement validation protocols specific to chemistry (e.g., time-split validation for QSAR models).

Project Structure and Documentation:

- Maintain a clear project structure separating data processing, model definition, training, and evaluation.
- Write comprehensive docstrings for all functions and classes.
- Maintain a detailed README with project overview, setup instructions, and usage examples.
- Use type hints to improve code readability and catch potential errors.

Dependencies:

- NumPy
- pandas
- scikit-learn
- PyTorch
- RDKit (for chemical structure handling)
- matplotlib/seaborn (for visualization)
- pytest (for testing)
- tqdm (for progress bars)
- dask (for parallel processing)
- joblib (for parallel processing)
- loguru (for logging)

Key Conventions:

1. Follow PEP 8 style guide for Python code.
2. Use meaningful and descriptive names for variables, functions, and classes.
3. Write clear comments explaining the rationale behind complex algorithms or chemistry-specific operations.
4. Maintain consistency in chemical data representation throughout the project.

Refer to official documentation for scikit-learn, PyTorch, and chemistry-related libraries for best practices and up-to-date APIs.

Note on Integration with Tauri Frontend:

- Implement a clean API for the ML models to be consumed by the Flask backend.
- Ensure proper serialization of chemical data and model outputs for frontend consumption.
- Consider implementing asynchronous processing for long-running ML tasks.

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for AI and ML →

From the same set210

r-cursorrules-prompt-file-best-practices Enforces R project structuring, tidyverse formatting standards, renv lockfiles, and package documentation guidelines in Cursor. ★ 41,024repo stars qwik-tailwind-cursorrules-prompt-file A Cursor rule that tells the agent how to write Qwik components with Tailwind CSS: lazy functions, signals, folder layout. Useful on a Qwik City project in TypeScript. ★ 41,024repo stars qwik-basic-cursorrules-prompt-file A Cursor rule that sets Qwik conventions for the agent: lazy functions with the $ suffix, signals, tasks, and a TypeScript plus Vite project layout. ★ 41,024repo stars qa-bug-report-cursorrules-prompt-file Configures Cursor to generate detailed bug reports acting as a QA engineer. It formats reproduction steps, environment data, console logs, and severity ratings. ★ 41,024repo stars python A Cursor rule that sets project layout, code style and stack choices for Python work with Flask and SQLite. Useful when the agent edits files in your repo. ★ 41,024repo stars python-projects-guide-cursorrules-prompt-file Guides Cursor to write Python code following modular design, Rye dependency management, pytest suites, and Ruff formatting. ★ 41,024repo stars python-llm-ml-workflow-cursorrules-prompt-file This rule guides Cursor through Python, LLM, and ML work. Use it for API code, experiments, tests, and project structure. ★ 41,024repo stars python-github-setup-cursorrules-prompt-file Tells Cursor how to write and review Python code: style, tests, GitHub Pull Requests and GitHub Actions CI. Useful when the team has no shared rulebook. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor