Skip to main content

The Green Magic library of the Green-Machine

Project description

Green Magic is a library containing class models allowing users to train machine learning models as well as visualize cannabis strain data. It has functionality for encoding raw cannabis strain data into features usefull for visualization and cluster analysis. It contains implementations for model evaluation and methods for data exploration.

Key features of the Library:

  • Data cleaning
  • Seemless dataset creation
  • Extendable feature extraction system
  • Usage of the Somoclu library [1] as the backend, which allows for ‘fast execution of Self-Organizing Maps by parallelization: OpenMP and CUDA are supported’.
  • Visualization of maps
  • Kmeans and Affinity-propagation based clustering
  • Formatted print of statistics and distributions


A simple example is below.

from green_magic import WeedMaster
from green_magic.clustering import ClusteringFactory, DistroReporter, get_model_quality_reporter
all_vars = ['type', 'effects', 'medical', 'negatives', 'flavors']
active_vars = ['type', 'effects', 'medical', 'negatives', 'flavors']
wd = 'pd'
wm = WeedMaster()
dt = wm.create_weedataset(dt_path, wd)
vectors = wm.get_feature_vectors(dt)
som = wm.map_manager.get_som('toroid.rectangular.30.30.pca')
clf = ClusteringFactory(wm)
cls = clf.create_clusters(som, 'kmeans', nb_clusters=10, vars=all_vars, ngrams=1)
r = DistroReporter()
r.print_distros(cls0, 'type', prec=3)
qr = get_model_quality_reporter(wm, wd)
print(qr.measure(cls, metric='silhouette'))
print(qr.measure(cls, metric='cali-hara'))


The code is available on PyPI, hence it can be installed by

$ pip install green_magic


  1. Peter Wittek, Shi Chao Gao, Ik Soo Lim, Li Zhao (2017). Somoclu: An Efficient Parallel Library for Self-Organizing Maps. Journal of Statistical Software, 78(9), pp.1–21. DOI:10.18637/jss.v078.i09. arXiv:1305.1422.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for green-magic, version 0.5.6
Filename, size File type Python version Upload date Hashes
Filename, size green_magic-0.5.6.tar.gz (28.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page