Skip to main content

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:

  1. Create a River model pipeline
  2. Use MovingWindowBatcher to process data in batches
  3. Train the model on each instance in the batch
  4. Make predictions and update metrics
  5. 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

fluvialgen-0.2.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluvialgen-0.2.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file fluvialgen-0.2.0.tar.gz.

File metadata

  • Download URL: fluvialgen-0.2.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for fluvialgen-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7dc5c1cef34e0b8f16a84680e783011c500d48048efca77db82a92edadb313be
MD5 d2869a8c6c51432b3f74fcb0079a9c05
BLAKE2b-256 be712bb58d6bc36b475d314cc4a6f2ca6d7ec57d4274b25a2671bce546e76815

See more details on using hashes here.

File details

Details for the file fluvialgen-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fluvialgen-0.2.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.12.7

File hashes

Hashes for fluvialgen-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61073a5af7a920e0f0fe96ea8eddc8748bb0b91de3440162f8f909ee6ad6612f
MD5 fd68a486b2868b23ade20a65318fb825
BLAKE2b-256 10cc79dd244b9194582e7080228e293763d1434f49fe84c9de15c9ea02b4a1e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page