Build a Collection in PyRasgo

When working in Python, you don’t need to click the Rasgo app to create a collection or add features to it. You can easily do this work from within your Python environment.

Let’s assume that you have created a list of features you want in your collection. You can get the list of all features available to you with a call to get.features()

features = rasgo.get.features()

By selecting the features you want from this list, you can create a feature list that you will add to the collection. In this case, we have tagged a number of features with the tag β€œfor_collection_test” and will select those features with that tag.

featurelist = [feature for feature in features if 'for_collection_test' in feature.tags]

Next, we can create a collection with a call to create.collection(). We will need to provide the name, collection type (in this case timeseries) and a granularity (in this case day).

# How to create a collection
collection = rasgo.create.collection(name="My SDK Collection", type='Timeseries', granularity='day', is_shared=True)
print(collection)

We can easily add our feature list to this collection with add_features

collection.add_features(featurelist)

To search for any additional features compatible with your existing collection, you can use get_compatible_features()

# How to check compatible features for a collection
compat_features = collection.get_compatible_features()
print(compat_features)

Remember, before you can download the collection it needs to be generated. You can check if the data is ready to be downloaded with is_data_ready.

collection.is_data_ready()

And you can generate the data with generate_training_data.

collection.generate_training_data()

And once the data is generated, you can download it with rasgo.read_collection_data.

Last updated