Exemplo n.º 1
0
async def serve(q: Q):
    if '#' in q.args:
        hash_ = q.args['#']
        q.page['nav'] = ui.form_card(box='1 1 2 5', items=[
            ui.text(f'#={hash_}'),
            ui.button(name='show_nav', label='Back', primary=True),
        ])
    else:
        q.page['nav'] = ui.nav_card(
            box='1 1 2 5',
            value='#menu/spam',
            items=[
                ui.nav_group('Menu', items=[
                    ui.nav_item(name='#menu/spam', label='Spam'),
                    ui.nav_item(name='#menu/ham', label='Ham'),
                    ui.nav_item(name='#menu/eggs', label='Eggs'),
                    ui.nav_item(name='#menu/toast', label='Toast', disabled=True),
                ]),
                ui.nav_group('Help', items=[
                    ui.nav_item(name='#about', label='About', icon='Info'),
                    ui.nav_item(name='#support', label='Support', icon='Help'),
                ])
            ],
        )
    await q.page.save()
Exemplo n.º 2
0
def init_client(q: Q):
    q.client.initialized = True
    q.page['meta'] = ui.meta_card(
        box='',
        title='Credit Risk',
        layouts=[
            ui.layout(breakpoint='xs',
                      zones=[
                          ui.zone('header'),
                          ui.zone('customer_table'),
                          ui.zone('customer_page',
                                  zones=[
                                      ui.zone('customer_risk_explanation'),
                                      ui.zone('customer_shap_plot'),
                                      ui.zone('button_group'),
                                      ui.zone('customer_features'),
                                  ])
                      ]),
            ui.layout(breakpoint='m',
                      zones=[
                          ui.zone('header'),
                          ui.zone('customer_table'),
                          ui.zone(
                              'customer_page',
                              direction=ui.ZoneDirection.ROW,
                              zones=[
                                  ui.zone(
                                      'content',
                                      zones=[
                                          ui.zone('customer_risk_explanation'),
                                          ui.zone('customer_shap_plot'),
                                          ui.zone('button_group'),
                                      ]),
                                  ui.zone('customer_features', size='300px'),
                              ])
                      ])
        ])
    q.page['header'] = ui.header_card(
        box='header',
        title='Credit Card Risk',
        subtitle='Review customer ability to pay credit card bills',
        icon='PaymentCard',
        nav=[
            ui.nav_group('Navigation',
                         items=[
                             ui.nav_item(name='render_customer_selector',
                                         label='Customers'),
                         ]),
            ui.nav_group('Options',
                         items=[
                             ui.nav_item(name='dark_mode', label='Dark Mode'),
                             ui.nav_item(name='light_mode',
                                         label='Light Mode'),
                         ])
        ])
Exemplo n.º 3
0
def init(q: Q):
    q.client.primary_color = '$blue'
    q.client.secondary_color = '$cyan'
    q.client.tertiary_color = '$azure'
    q.page['meta'] = ui.meta_card(
        box='',
        title='Telco Churn Analytics',
        layouts=[
            ui.layout(breakpoint='xs',
                      zones=[
                          ui.zone('header'),
                          ui.zone('title'),
                          ui.zone('content',
                                  zones=[
                                      ui.zone('code'),
                                      ui.zone('top',
                                              direction=ui.ZoneDirection.ROW,
                                              zones=[
                                                  ui.zone('top-plot',
                                                          size='70%'),
                                                  ui.zone('top-stats')
                                              ]),
                                      ui.zone('middle',
                                              direction=ui.ZoneDirection.ROW),
                                  ])
                      ])
        ])
    q.page['header'] = ui.header_card(
        box='header',
        title='Telecom Churn Analytics',
        subtitle='EDA & Churn Modeling with AutoML & Wave',
        nav=[
            ui.nav_group('Main Menu',
                         items=[
                             ui.nav_item(name='analysis', label='Analysis'),
                             ui.nav_item(name='code',
                                         label='Application Code'),
                         ])
        ])
    q.page['title'] = ui.section_card(
        box='title',
        title='Customer profiles from model predictions',
        subtitle='Customer: No customer chosen',
        items=[
            # TODO: Replace with dropdown after https://github.com/h2oai/wave/pull/303 merged.
            ui.picker(name='customers',
                      label='Customer Phone Number',
                      choices=[
                          ui.choice(name=str(phone), label=str(phone))
                          for phone in df['Phone']
                      ],
                      max_choices=1,
                      trigger=True),
            ui.toggle(name='theme', label='Dark Theme', trigger=True)
        ])
Exemplo n.º 4
0
def card_sidebar() -> ui.NavCard:
    """
    Card for demo.
    """
    item_list = [
        ui.nav_group('Functions',
                     items=[
                         ui.nav_item(name='assign',
                                     label='Assign next action'),
                         ui.nav_item(name='record', label='Record results'),
                         ui.nav_item(name='add_people', label='Add people')
                     ])
    ]
    card = ui.nav_card(box=box_sidebar, items=item_list)

    return card
Exemplo n.º 5
0
async def setup_page(q: Q):
    q.page['meta'] = ui.meta_card(
        box='',
        title=app_title,
        layouts=[
            ui.layout(breakpoint='xs',
                      zones=[
                          ui.zone('header'),
                          ui.zone('blurb'),
                          ui.zone('main',
                                  size='calc(100vh - 130px)',
                                  direction=ui.ZoneDirection.ROW,
                                  zones=[ui.zone('code'),
                                         ui.zone('preview')])
                      ])
        ])

    q.page['header'] = ui.header_card(
        box='header',
        title=app_title,
        subtitle=f'{len(catalog)} Interactive Examples',
        nav=[
            ui.nav_group(label='Examples',
                         items=[
                             ui.nav_item(name=f'#{e.name}', label=e.title)
                             for e in catalog.values()
                         ])
        ],
    )

    q.page['blurb'] = ui.section_card(box='blurb',
                                      title='',
                                      subtitle='',
                                      items=[])
    q.page['code'] = ui.frame_card(box='code', title='', content='')
    q.page['preview'] = ui.frame_card(box='preview',
                                      title='Preview',
                                      path='/demo')

    await q.page.save()
Exemplo n.º 6
0
async def setup_page(q: Q):
    q.page['meta'] = ui.meta_card(
        box='',
        title=app_title
    )

    q.page['header'] = ui.header_card(
        box='1 1 2 1',
        title=app_title,
        subtitle=f'{len(catalog)} Interactive Examples',
    )

    q.page['examples'] = ui.nav_card(
        box='1 2 2 -1',
        items=[
            ui.nav_group(
                label='Examples',
                items=[ui.nav_item(name=f'#{e.name}', label=e.title) for e in catalog.values()]
            ),
        ],
    )

    q.page['blurb'] = ui.form_card(
        box='3 1 5 3',
        items=[],
    )

    q.page['code'] = ui.frame_card(
        box='3 4 5 -1',
        title='',
        content='',
    )
    q.page['preview'] = ui.frame_card(
        box='8 1 5 -1',
        title='Preview',
        path='/demo',
    )
    await q.page.save()
Exemplo n.º 7
0
                ]),
            ]),
            ui.zone('footer', size='0'),
        ]
    )
])

page['header'] = ui.header_card(
    # Place card in the header zone, regardless of viewport size.
    box='header',
    title='Lorem Ipsum',
    subtitle='Excepteur sint occaecat cupidatat',
    nav=[
        ui.nav_group('Menu', items=[
            ui.nav_item(name='#menu/spam', label='Spam'),
            ui.nav_item(name='#menu/ham', label='Ham'),
            ui.nav_item(name='#menu/eggs', label='Eggs'),
        ]),
        ui.nav_group('Help', items=[
            ui.nav_item(name='#about', label='About'),
            ui.nav_item(name='#support', label='Support'),
        ])
    ],
)
page['controls'] = ui.markdown_card(
    # If the viewport width >= 0, place in content zone.
    # If the viewport width >= 768, place in sidebar zone.
    # If the viewport width >= 1200, place in sidebar zone.
    box=ui.boxes('content', 'sidebar', 'sidebar'),
    title='Controls',
    content=content,
Exemplo n.º 8
0
from h2o_wave import ui

global_nav = [
    ui.nav_group('Dashboards',
                 items=[
                     ui.nav_item(name='#dashboards/red', label='Red'),
                     ui.nav_item(name='#dashboards/blue', label='Blue'),
                     ui.nav_item(name='#dashboards/orange', label='Orange'),
                     ui.nav_item(name='#dashboards/cyan', label='Cyan'),
                     ui.nav_item(name='#dashboards/grey', label='Grey'),
                     ui.nav_item(name='#dashboards/mint', label='Mint'),
                     ui.nav_item(name='#dashboards/purple', label='Purple'),
                 ]),
]
Exemplo n.º 9
0
    def __init__(self):
        self.color = "#00A8E0"
        self.total_gauge_color = "#FF0102"
        self.image_path = "static/churn.png"

        self.training_path = "data/churnTrain.csv"
        self.testing_path = "data/churnTest.csv"
        self.default_model = "telco_churn_model"

        self.y_col = "Churn"
        self.x_cols = [
            "Account_Length",
            "No_Vmail_Messages",
            "Total_Day_minutes",
            "Total_Day_Calls",
            "Total_Day_charge",
            "Total_Eve_Minutes",
            "Total_Eve_Calls",
            "Total_Eve_Charge",
            "Total_Night_Minutes",
            "Total_Night_Calls",
            "Total_Night_Charge",
            "Total_Intl_Minutes",
            "Total_Intl_Calls",
            "Total_Intl_Charge",
            "No_CS_Calls",
            "Area_Code",
            "International_Plan",
            "Voice_Mail_Plan",
            "State",
            "Phone_No",
        ]

        self.id_column = "Phone_No"

        self.title = "Telecom Churn Analytics"
        self.subtitle = "EDA & Churn Modeling with AutoML & Wave"
        self.icon = "AddPhone"

        self.model_loaded = False
        self.working_data = self.training_path
        # self.training_data_url = 'https://h2o-internal-release.s3-us-west-2.amazonaws.com/data/Splunk/churn.csv'
        self.training_data_url = "./data/churnTrain.csv"
        # self.testing_data_url = 'https://h2o-internal-release.s3-us-west-2.amazonaws.com/data/Splunk/churn_test.csv'
        self.testing_data_url = "./data/churnTest.csv"

        self.boxes = {
            "banner": "1 1 -1 1",
            "content": "1 2 -1 -1",
            "logo": "11 1 -1 1",
            "navbar": "4 1 -1 1",
            "search":"1 2 -1 2",
            "empty_profile_page": "1 4 -1 -1",
            "day_stat": "3 4 2 1",
            "eve_stat": "5 4 2 1",
            "night_stat": "3 5 2 1",
            "intl_stat": "5 5 2 1",
            "total_stat": "7 4 1 2",
            "customer": "1 4 2 1",
            "churn_rate": "1 5 2 1",
            "stat_pie": "8 4 -1 2",
            "shap_plot": "1 6 -1 11",
            "top_negative_pd_plot": "1 17 -1 11",
            "top_positive_pd_plot": "1 28 -1 11",
        }

        self.figure_config = {"scrollZoom": False, "displayModeBar": None}

        self.def_column_values = {
            "International_Plan": "no",
            "Voice_Mail_Plan": "no",
            "No_Vmail_Messages": 0,
            "Total_Day_minutes": 0.00,
            "Total_Day_Calls": 0,
            "Total_Day_charge": 0.00,
            "Total_Eve_Minutes": 0.00,
            "Total_Eve_Calls": 0,
            "Total_Eve_Charge": 0,
            "Total_Night_Minutes": 0.00,
            "Total_Night_Calls": 0,
            "Total_Night_Charge": 0.00,
            "Total_Intl_Minutes": 0.00,
            "Total_Intl_Calls": 0,
            "Total_Intl_Charge": 0.00,
            "No_CS_Calls": 0
        }

        self.mandatory_columns = ["State","Account_Length","Area_Code","Phone_No"]

        self.global_nav = [
            ui.nav_group('Main Menu', items=[
                ui.nav_item(name="#profile", label="Customer Profiles"),
                ui.nav_item(name="#tour", label="Application Code"),
            ]),
        ]
Exemplo n.º 10
0
async def serve(q: Q):
    if '#' in q.args and not q.args.show_nav:
        hash_ = q.args['#']
        q.page.drop()
        q.page['redirect'] = ui.form_card(box='1 1 2 5',
                                          items=[
                                              ui.text(f'#={hash_}'),
                                              ui.button(name='show_nav',
                                                        label='Back',
                                                        primary=True),
                                          ])
    else:
        q.page['meta'] = ui.meta_card(box='', redirect='#')
        q.page['nav1'] = ui.nav_card(
            box='1 1 2 -1',
            value='#menu/spam',
            title='H2O Wave',
            subtitle='And now for something completely different!',
            image=
            'https://www.h2o.ai/wp-content/themes/h2o2018/templates/dist/images/h2o_logo.svg',
            items=[
                ui.nav_group('Menu',
                             items=[
                                 ui.nav_item(name='#menu/spam', label='Spam'),
                                 ui.nav_item(name='#menu/ham', label='Ham'),
                                 ui.nav_item(name='#menu/eggs', label='Eggs'),
                                 ui.nav_item(name='#menu/toast',
                                             label='Toast',
                                             disabled=True),
                             ]),
                ui.nav_group('Help',
                             items=[
                                 ui.nav_item(name='#about',
                                             label='About',
                                             icon='Info'),
                                 ui.nav_item(name='#support',
                                             label='Support',
                                             icon='Help'),
                             ])
            ],
            secondary_items=[
                ui.inline(items=[
                    ui.persona(title='John Doe',
                               subtitle='Software developer',
                               size='s',
                               image=persona),
                    ui.menu(items=[
                        ui.command(
                            name='profile', label='Profile', icon='Contact'),
                        ui.command(name='preferences',
                                   label='Preferences',
                                   icon='Settings'),
                        ui.command(
                            name='logout', label='Logout', icon='SignOut'),
                    ])
                ]),
            ],
        )
        q.page['nav2'] = ui.nav_card(
            box='3 1 2 -1',
            value='#menu/ham',
            persona=ui.persona(title='John Doe',
                               subtitle='Data Scientist',
                               caption='Online',
                               size='xl',
                               image=persona),
            items=[
                ui.nav_group('Menu',
                             items=[
                                 ui.nav_item(name='#menu/spam', label='Spam'),
                                 ui.nav_item(name='#menu/ham', label='Ham'),
                                 ui.nav_item(name='#menu/eggs', label='Eggs'),
                                 ui.nav_item(name='#menu/toast',
                                             label='Toast',
                                             disabled=True),
                             ]),
                ui.nav_group('Help',
                             items=[
                                 ui.nav_item(name='#about',
                                             label='About',
                                             icon='Info'),
                                 ui.nav_item(name='#support',
                                             label='Support',
                                             icon='Help'),
                             ])
            ],
            secondary_items=[
                ui.button(name='logout', label='Logout', width='100%')
            ],
            color='primary')
    await q.page.save()