13

Getting started with Plotapi Pareto Front

 2 years ago
source link: https://datacrayon.com/posts/plotapi/paretofront/getting-started-with-paretofront/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Preamble

from plotapi import ParetoFront

ParetoFront.set_license("your username", "your license key")

Introduction

Our first Plotapi Pareto Front Diagram!

Plotapi Pareto Front is a beautiful and feature rich take on non-dominated sorting over time. As we can see, we have set our license details in the preamble with ParetoFront.set_license().

Dataset

Plotapi Pareto Front expects at minimum a list of dictionary items, these will define bi-objective solutions over time.

samples = [
    {'order': 20200101, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200101, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200101, 'objv_1': 40, 'objv_2': 12},   

    {'order': 20200104, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200104, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200104, 'objv_1': 40, 'objv_2': 14},   

    {'order': 20200109, 'objv_1': 40, 'objv_2': 12},   
    {'order': 20200109, 'objv_1': 45, 'objv_2': 12},   
    {'order': 20200109, 'objv_1': 45, 'objv_2': 10},   

    {'order': 20200112, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200112, 'objv_1': 50, 'objv_2': 11},   
    {'order': 20200112, 'objv_1': 50, 'objv_2': 10},   

    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   

    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   
    {'order': 20200115, 'objv_1': 50, 'objv_2': 12},   

    {'order': 20200120, 'objv_1': 60, 'objv_2': 8},   
    {'order': 20200120, 'objv_1': 60, 'objv_2': 8},   
    {'order': 20200120, 'objv_1': 60, 'objv_2': 8},   

    {'order': 20200123, 'objv_1': 60, 'objv_2': 8},   
    {'order': 20200123, 'objv_1': 60, 'objv_2': 8},   
    {'order': 20200123, 'objv_1': 60, 'objv_2': 8},   

    {'order': 20200123, 'objv_1': 80, 'objv_2': 3},  

    {'order': 20200123, 'objv_1': 30, 'objv_2': 20},  

    {'order': 20200125, 'objv_1': 30, 'objv_2': 20},  
    {'order': 20200125, 'objv_1': 10, 'objv_2': 20}, 

    {'order': 20200129, 'objv_1': 120, 'objv_2': 50},  
    {'order': 20200129, 'objv_1': 50, 'objv_2': 120},   
    {'order': 20200129, 'objv_1': 50, 'objv_2': 120},   
    {'order': 20200129, 'objv_1': 50, 'objv_2': 120},    

    {'order': 20200130, 'objv_1': 100, 'objv_2': 100},      
]

We can see that each dictionary item has three properties:

  • order which determines with time period this item belongs to. This should be numerical, but can be formatted e.g. as dates.
  • objv_1 the first objective value, e.g. "weight".
  • objv_2 the second objective value, e.g. "reps".

We can also populate the events structure to present event text at specific times.

events = [
    {
        "order": 20200101,
        "event": "My first ever gym visit!"
    },
    {
        "order": 20200109,
        "event": "I went a little heavier today!"
    },
    {
        "order": 20200120,
        "event": "Three solid sets of 60 kg!"
    },
    {
        "order": 20200129,
        "event": "Broke some records today!"
    }
]

Visualisation

Creating our first Pareto Front Diagram is as easy as calling Plotapi with our one input.

Here we're using .show() which outputs to a Jupyter Notebook cell, however, we may want to output to an HTML file with .to_html() instead. More on the different output methods later!

Be sure to interact with the visualisation to see what the default settings can do!

ParetoFront(samples, events=events, title="Bench Press",
            objv_1_unit=" kg", objv_2_unit=" reps",
            x_label="Weight(kg)", y_label="Reps").show()

Plotapi - ParetoFront Diagram

131211363738394041424344Weight(kg)RepsBench PressWed Jan 01 2020My first ever gym visit!3

Here we can see the default behaviour of Plotapi Pareto Front.

You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK