Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Python Package for Adaptive Spatio-Temporal Exploratory Model (AdaSTEM)

License

NotificationsYou must be signed in to change notification settings

chenyangkang/stemflow

stemflow logo

A Python Package for Adaptive Spatio-Temporal Exploratory Model (AdaSTEM)

GitHubPyPI versionPyPI downloadsAnaconda versionAnaconda downloadsGitHub last commitcodecovstatus


Documentation 📖

stemflow Documentation

JOSS paper


Installation 🔧

pipinstallstemflow

To install the latest beta version from github:

pipinstallstemflow@git+https://github.com/chenyangkang/stemflow.git

Or using conda:

condainstall-cconda-forgestemflow

Brief introduction ℹ️

stemflow is a toolkit for Adaptive Spatio-Temporal Exploratory Model (AdaSTEM [1,2]) in Python. Typical usage is daily abundance estimation usingeBird citizen science data (survey data).

stemflow adopts"split-apply-combine" philosophy. It

  1. Splits input data usingQuadtree orSphere Quadtree.
  2. Trains each spatiotemporal split (called stixel) separately.
  3. Aggregates the ensemble to make the prediction.

The framework leverages the "adjacency" information of surroundings in space and time to model/predict the values of target spatiotemporal points. This framework ameliorates thelong-distance/long-range prediction problem [3], and has a good spatiotemporal smoothing effect.

For more information, please seean introduction to stemflow andlearning curve analysis


Model and data 🎰

Main functionality ofstemflowSupported indexingSupported tasks
✅ Spatiotemporal modeling & prediction
✅ User-defined 2D spatial indexing (CRS)
✅ Binary classification task
✅ Calculate overall feature importances
✅ 3D spherical indexing
✅ Regression task
✅ Plot spatiotemporal dynamics
✅ User-defined temporal indexing
✅ Hurdle task (two step regression – classify then regress the non-zero part)
✅ Spatial-only modeling
For details seeAdaSTEM DemoFor details and tips seeTips for spatiotemporal indexingFor details and tips seeTips for different tasks
Supported data typesSupported base models
✅ Both continuous and categorical features (prefer one-hot encoding)
✅ sklearn styleBaseEstimator classes (you can make your own base model), for examplehere
✅ Both static (e.g., yearly mean temperature) and dynamic features (e.g., daily temperature)
✅ sklearn style Maxent model.Example here.
For details and tips seeTips for data typesFor details seeBase model choices

Usage ⭐

Use Hurdle model as the base model of AdaSTEMRegressor:

fromstemflow.model.AdaSTEMimportAdaSTEM,AdaSTEMClassifier,AdaSTEMRegressorfromstemflow.model.HurdleimportHurdlefromxgboostimportXGBClassifier,XGBRegressor## "hurdle in Ada"model=AdaSTEMRegressor(base_model=Hurdle(classifier=XGBClassifier(tree_method='hist',random_state=42,verbosity=0,n_jobs=1),regressor=XGBRegressor(tree_method='hist',random_state=42,verbosity=0,n_jobs=1)    ),# hurdel model for zero-inflated problem (e.g., count)save_gridding_plot=True,ensemble_fold=50,# data are modeled 50 times, each time with jitter and rotation in Quadtree algomin_ensemble_required=30,# Only points covered by > 30 ensembles will be predictedgrid_len_upper_threshold=25,# force splitting if the grid length exceeds 25grid_len_lower_threshold=5,# stop splitting if the grid length fall short 5temporal_start=1,# The next 4 params define the temporal sliding windowtemporal_end=366,temporal_step=20,# The window takes steps of 20 DOY (see AdaSTEM demo for details)temporal_bin_interval=50,# Each window will contain data of 50 DOYpoints_lower_threshold=50,# Only stixels with more than 50 samples are trained and used for predictionSpatio1='longitude',# The next three params define the name ofSpatio2='latitude',# spatial coordinates shown in the dataframeTemporal1='DOY',use_temporal_to_train=True,# In each stixel, whether 'DOY' should be a predictorn_jobs=1,random_state=42)

Fitting and prediction methods follow the style of sklearnBaseEstimator class:

## fitmodel=model.fit(X_train.reset_index(drop=True),y_train)## predictpred=model.predict(X_test)pred=np.where(pred<0,0,pred)eval_metrics=AdaSTEM.eval_STEM_res('hurdle',y_test,pred_mean)print(eval_metrics)

Where thepred is the mean of the predicted values across ensembles.

SeeAdaSTEM demo for further functionality.
Besides,stemflow also supportlazy loading anddatabase query to reduce memory load during parallel computing.


Plot QuadTree ensembles 🌲

model.gridding_plot# Here, the model is a AdaSTEM class, not a hurdle class

QuadTree example

Here, each color shows an ensemble generated during model fitting. In each of the 10 ensembles, regions (in terms of space and time) with more training samples were gridded into finer resolution, while the sparse one remained coarse. Prediction results were aggregated across the ensembles (that is, in this example, data were modeled 10 times).

If you useSphereAdaSTEM module, the gridding plot is aplotly generated interactive object by default:

SeeSphereAdaSTEM demo andInteractive spherical gridding plot.


Example of visualization 🗺️

Daily Abundance Map of Barn Swallow

GIF visualization

See sectionAdaSTEM demo for how to generate this GIF.


Citation

Chen et al., (2024). stemflow: A Python Package for Adaptive Spatio-Temporal Exploratory Model. Journal of Open Source Software, 9(94), 6158,https://doi.org/10.21105/joss.06158

@article{Chen2024,doi ={10.21105/joss.06158},url ={https://doi.org/10.21105/joss.06158},year ={2024},publisher ={The Open Journal},volume ={9},number ={94},pages ={6158},author ={Yangkang Chen and Zhongru Gu and Xiangjiang Zhan},title ={stemflow: A Python Package for Adaptive Spatio-Temporal Exploratory Model},journal ={Journal of Open Source Software} }

Contribute to stemflow 💜

We welcome pull requests. Contributors should followcontributor guidelines.

Application-level cooperation is also welcomed. We recognized that stemflow may consume large computational resources especially as data volume boosts in the future. We always welcome research collaboration of all kinds.


References:

  1. Fink, D., Damoulas, T., & Dave, J. (2013, June). Adaptive Spatio-Temporal Exploratory Models: Hemisphere-wide species distributions from massively crowdsourced eBird data. In Proceedings of the AAAI Conference on Artificial Intelligence (Vol. 27, No. 1, pp. 1284-1290).

  2. Fink, D., Auer, T., Johnston, A., Ruiz‐Gutierrez, V., Hochachka, W. M., & Kelling, S. (2020). Modeling avian full annual cycle distribution and population trends with citizen science data. Ecological Applications, 30(3), e02056.

  3. Fink, D., Hochachka, W. M., Zuckerberg, B., Winkler, D. W., Shaby, B., Munson, M. A., ... & Kelling, S. (2010). Spatiotemporal exploratory models for broad‐scale survey data. Ecological Applications, 20(8), 2131-2147.

  4. Johnston, A., Fink, D., Reynolds, M. D., Hochachka, W. M., Sullivan, B. L., Bruns, N. E., ... & Kelling, S. (2015). Abundance models improve spatial and temporal prioritization of conservation resources. Ecological Applications, 25(7), 1749-1756.

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp