Metadata-Version: 2.4
Name: qqtools
Version: 1.1.25
Summary: A small tool package for qq
Author-email: qq <qq@x1q.cc>
License-Expression: MIT
Project-URL: Homepage, https://github.com/kzhoa/qqtools
Project-URL: Repository, https://github.com/kzhoa/qqtools.git
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch
Requires-Dist: PyYAML
Requires-Dist: scikit-learn
Requires-Dist: rich
Requires-Dist: matplotlib
Requires-Dist: numpy
Requires-Dist: pandas
Dynamic: license-file



![qqtools-banner](static/banner_1920.png)



# qqtools
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/qqtools?period=total&units=ABBREVIATION&left_color=GREY&right_color=BRIGHTGREEN&left_text=PyPI+Downloads)](https://pepy.tech/projects/qqtools)  ![Python version](https://img.shields.io/badge/python->=3.11-blue)  


A small tool package for qq

# Requirements

- torch>=2.0 for full functionality 
  - Some components maintain backward compatibility with torch==1.x
  - Recommended: torch>=2.4
- pyyaml>=6.0
  - We recommend using YAML format for all configuration files.
This provides a unified approach to drive and manage all workflow operations.

# Data Format Support

Non-torch formats:
```bash
qDict : Enhanced of basic Dict.
qScalaDict : Dict[str, num]. A dict that maps str to scala;
qListData : List[dict]. A list of dicts.
```

Torch-related data formats
```bash
qData
qBatchList
```



# Simple Training Loop

For jupyter users

```python
import qqtools as qt
qt.import_common(globals())

x = np.random.rand(100, 5)
y = np.random.rand(100)

# dataset wrap
xs = [ x[i] for i in range(len(x))]
ys = [ y[i] for i in range(len(y))]
data_list = [ qt.qData({'x': x[i], 'y':y[i]})  for i in range(len(x))] 
dataset = qt.qDictDataset(data_list=data_list)
dataloader = qt.qDictDataloader()

# model
model = qt.nn.qMLP([5,5,1], activation="relu")
loss_fn = torch.nn.MSELoss()
optimizer = torch.optim.AdamW(model.parameters(), lr=1.0e-4, weight_decay=0.01)

# device
device = torch.device("cuda")
model.to(device)

# loop
for epoch in range(100):
    for batch in dataloader:
        batch.to(device)
        out = model(batch.x)
        loss = loss_fn(out, batch.y)
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
    print(f"{epoch} {loss.item():4.6f}")
```


# Individual Modules

The following modules are consumers of the core functionality provided by this package. Each is designed to be independent, allowing for sole import.

- chem
- pipeline
