A Python package for generating synthetic river networks and datasets
Project description
FluvialGen
A Python package for generating synthetic river networks and datasets.
Installation
You can install FluvialGen using pip:
pip install fluvialgen
Or install from source:
git clone https://github.com/joseenriqueruiznavarro/FluvialGen.git
cd FluvialGen
pip install -e .
Requirements
- Python >= 3.8
- NumPy
- Pandas
- SciPy
- Matplotlib
- GeoPandas
- Shapely
- Rasterio
- tqdm
Integration with River Models
Here's an example of how to use MovingWindowBatcher with a River model:
from river import compose, linear_model, preprocessing, optim, metrics
from generator.movingwindow_generator import MovingWindowBatcher
from river import datasets
# Create a River pipeline
model = compose.Select('clouds', 'humidity', 'pressure', 'temperature', 'wind')
model |= preprocessing.StandardScaler()
model |= linear_model.LinearRegression(optimizer=optim.SGD(0.001))
# Initialize metrics
metric = metrics.MAE()
# Create the dataset and batcher
dataset = datasets.Bikes()
batcher = MovingWindowBatcher(
dataset=dataset,
instance_size=2,
batch_size=2,
n_instances=1000
)
# Train the model
try:
# Process batches and train the model
for X, y in batcher:
# Train on each instance in the batch
for i in range(len(X)):
x = X.iloc[i]
target = y.iloc[i]
model.learn_one(x, target)
# Make predictions and update metrics
for i in range(len(X)):
x = X.iloc[i]
target = y.iloc[i]
y_pred = model.predict_one(x)
metric.update(target, y_pred)
print(f"Final MAE: {metric}")
finally:
# Clean up
batcher.stop()
This example shows how to:
- Create a River model pipeline
- Use MovingWindowBatcher to process data in batches
- Train the model on each instance in the batch
- Make predictions and update metrics
- Handle cleanup properly
The batcher provides a convenient way to process data in overlapping windows while maintaining compatibility with River's streaming learning paradigm.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fluvialgen-0.3.0.tar.gz.
File metadata
- Download URL: fluvialgen-0.3.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
390a266a9f248ea0f6c58204acffa8ea5b1282ea4bf01cb70cef96d90841478e
|
|
| MD5 |
36eee754a0f1f460a649d745945ec871
|
|
| BLAKE2b-256 |
087492bb3fca6a0967923ae5eb8fe6e26e7325ee1e38243f2c1a437b9f5ac77d
|
File details
Details for the file fluvialgen-0.3.0-py3-none-any.whl.
File metadata
- Download URL: fluvialgen-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1b077bc81a2d2655f3a47e4c69bdd45a495d67f61edeba1b3f02b4020910c19
|
|
| MD5 |
7707c13278fa816a7572bcff9e27cac8
|
|
| BLAKE2b-256 |
81556e9a84fe6f9e25b587fe5caa383c554b9c1d9e8a29f2b37503bcbf3d4546
|