Basic Example

This notebook walks you through some of the high level aspects of the Planetoid API

In [2]:
import pandas as pd
import numpy as np
from matplotlib import colors
from sklearn.datasets import make_blobs
import planetoids as pt
np.random.seed(42)

Using scikit-learn, we will generate some random data that we will use to seed a Planetoid

In [3]:
X, y = make_blobs(n_samples=200,
                  n_features=2,
                  centers=3,
                  cluster_std=1.1,
                  center_box=(0,10),
                  random_state=42)
data = pd.DataFrame(X)
data['Cluster'] = y

#plot
data.plot(kind='scatter', x=0, y=1, c='Cluster', cmap='tab10')
Out[3]:
<matplotlib.axes._subplots.AxesSubplot at 0x18729c8c400>

Seed the planet

In [4]:
blob_planet = pt.Planetoid(data, x=0, y=1, cluster_field='Cluster')

Fit & Terraform in a single step

This will generate all of the data needed to terraform and render our blob_planet but calling fit and then terraform.

In [5]:
blob_planet.fit_terraform(planet_name='fit_terraform demo')