示例#1
0
def get_instructions():
    return html.Ul(children=[
        html.Li("An App that provides suggestions for relocation in Finland"),
        html.Li("Fill the form below and click 'Recommend'"),
        html.Li("Alternatively, click on one area")
    ],
                   className="instructions_sidebar")
示例#2
0
def getHeader(active):
    header_logo = html.Div([html.A(className="header__logo", href='/')])
    header_items = [
        html.Li(dcc.Link("Team", href="/team", className="header__link"),
                className="header__item {0}".format("is-active" if active ==
                                                    "team" else "")),
        html.Li(dcc.Link("Players", href="/players", className="header__link"),
                className="header__item {0}".format("is-active" if active ==
                                                    "players" else "")),
    ]
    header_list = html.Ul(header_items, className="header__list")

    return html.Div([
        header_logo,
        header_list,
    ], className="header t-sans")
示例#3
0
def characteristics_list(
        model_characteristics: dict,
        testing_performances: [ValidationPerformance]) -> html.Div:
    """
    Create and return an HTML Div which contains a list of natural language characteristic
    relative to a prediction model.

    Parameters
    ----------
    model_characteristics : dict
        key-value for each characteristic to write in natural language.

    testing_performances : [ValidationPerformance]
        Useful to write also information about the testing performances.

    Returns
    -------
    html.Div()
    """
    def get_text_char(key: str, value: any) -> str:
        value = str(value)
        switcher = {
            "name":
            _("Model type: ") + value,
            "test_values":
            _('Values used for testing: last ') + value + _(' values'),
            "delta_training_percentage":
            _('The length of the training windows is the ') + value + "%" +
            _(' of the length of the time series.'),
            "delta_training_values":
            _('Training windows are composed of ') + value + _(' values.'),
            "extra_regressors":
            _("The model has used ") + value +
            _(" as extra-regressor(s) to improve the training."),
            "transformation":
            _('The model has used a ') + value +
            _(' transformation on the input data.') if value != "none " else
            _('The model has not used any pre/post transformation on input data.'
              )
        }
        return switcher.get(key, "Invalid choice!")

    elems = [
        html.Div(_('Model characteristics:')),
        html.Ul([
            html.Li(get_text_char(key, model_characteristics[key]))
            for key in model_characteristics
        ]),
        html.Div(
            _("This model, using the best training window, reaches these performances:"
              )),
        show_errors(testing_performances[0])
    ]

    return html.Div(elems)
示例#4
0
 def get_references():
     return html.Div([
         html.Br(),
         html.Br(),
         html.H2("References "),
         html.Ul([
             html.Li(
                 html.A(
                     "Energy Usage Reports: Environmental awareness as part of algorithmic accountability",
                     href="https://arxiv.org/pdf/1911.08354.pdf",
                 )),
             html.Li(
                 html.A(
                     "Quantifying the Carbon Emissions of Machine Learning",
                     href="https://arxiv.org/pdf/1910.09700.pdf",
                 )),
         ]),
         html.Br(),
         html.Br(),
     ])
示例#5
0
def get_breadcrumb(parts):

    if not parts:
        return html.Div()

    breadcrumbs = html.Nav(
        html.Ul([
            html.Li(
                dcc.Link(name, href=link),
                className=(None if idx != len(parts) - 1 else "is-active"),
            ) for idx, (name, link) in enumerate(parts.items())
        ]),
        className="breadcrumb",
    )

    return breadcrumbs
def update_entity_div(active_cell):
    if len(filtered_df.columns) == 0:
        return 'Click on a tweet to find the entities'
    else:
        txt = filtered_df['tweet_text'][active_cell['row']]
        txt = txt.replace('@', '')
        txt = txt.replace('#', '')
        txt = re.sub('https\S+', '', txt)
        nlp = spacy.load('en_core_web_sm')
        doc = nlp(txt)
        entlist = []
        for ent in doc.ents:
            entity = ''
            entity = entity + ent.text + '-' + ent.label_
            entlist.append(entity)
        if len(entlist) == 0:
            return 'No Entities present'
        else:
            return html.Ul([html.Li(i) for i in entlist])
示例#7
0
def show_errors(testing_performances: ValidationPerformance) -> html.Ul:
    """
    Create an HTML list with each error-metric in `testing_performances`.

    Parameters
    ----------
    testing_performances : ValidationPerformance
        Error metrics to show.

    Returns
    -------
    html.Ul
        HTML list with all the error-metrics.
    """
    import math

    def round_n(n: float):
        dec_part, int_part = math.modf(n)

        if abs(int_part) > 1:
            return str(round(n, 3))
        else:
            return format(n, '.3g')

    def get_text_perf(key: str, value: any) -> str:
        switcher = {
            "MAE": "MAE: " + round_n(value),
            "RMSE": "RMSE: " + round_n(value),
            "MSE": "MSE: " + round_n(value),
            "AM": _('Arithmetic mean of errors:') + round_n(value),
            "SD": _('Standard deviation of errors: ') + round_n(value)
        }
        return switcher.get(key, "Invalid choice!")

    testing_performances = testing_performances.get_dict()
    del testing_performances["first_used_index"]

    return html.Ul([
        html.Li(get_text_perf(key, testing_performances[key]))
        for key in testing_performances
    ])
示例#8
0
    "left": 0,
    "bottom": 0,
    "width": "16rem",
    "padding": "2rem 1rem",
    "background-color": "#f8f9fa",
}
sidebar = html.Div(
    [
        html.H2("GINAN", className="display-4"),
        html.P("EDA (MongoDB) ", className="lead"),
        html.Hr(),
        html.P(f"{db.MONGO_URL} / {db.MONGO_DB}", className="lead", id="db-info-side"),
        # dcc.NavLink("Change it", href="/dbselect", id="page-dbselect-link"),
        # html.P(f"{PEA_DB_NAME}", className="lead"),
        html.Hr(),
        html.Ul(children=[html.Li(dcc.Link("Db Info",           href="/dbinfo", id="page-dbinfo-link")),
                          html.Li(dcc.Link("States",           href="/states", id="page-states-link")),
                          html.Li(dcc.Link("Measurements",     href="/measurements", id="page-measurements-link")),
                          html.Li(dcc.Link("Measurements Polar",     href="/measurements-polar", id="page-measurements-polar-link"))
                          ]),
    ],
    style=SIDEBAR_STYLE,
)
content = html.Div(id='page-content', children=[], style=CONTENT_STYLE)

app.layout = html.Div([dcc.Location(id='url', refresh=False), sidebar, content ])

@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == '/measurements':
# add some padding.
CONTENT_STYLE = {
    "margin-left": "18rem",
    "margin-right": "2rem",
    "padding": "2rem 1rem",
}

submenu_1 = [
    html.Li(
        # use Row and Col components to position the chevrons
        dbc.Row(
            [
                dbc.Col("Menu 1"),
                dbc.Col(
                    html.I(className="fas fa-chevron-right me-3"),
                    width="auto",
                ),
            ],
            className="my-1",
        ),
        style={"cursor": "pointer"},
        id="submenu-1",
    ),
    # we use the Collapse component to hide and reveal the navigation links
    dbc.Collapse(
        [
            dbc.NavLink("Page 1.1", href="/page-1/1"),
            dbc.NavLink("Page 1.2", href="/page-1/2"),
        ],
        id="submenu-1-collapse",
    ),
示例#10
0
    html.H2('AntdTabPane(children, id, className, style, *args, **kwargs)',
            style={
                'borderLeft': '4px solid grey',
                'padding': '3px 0 3px 10px',
                'backgroundColor': '#f5f5f5'
            }),
    html.Span('主要参数说明:',
              id='主要参数说明',
              style={
                  'borderLeft': '4px solid grey',
                  'padding': '3px 0 3px 10px',
                  'backgroundColor': '#f5f5f5',
                  'fontWeight': 'bold',
                  'fontSize': '1.2rem'
              }),
    fmc.FefferyMarkdown(
        markdownStr=open('documents/AntdTabPane.md', encoding='utf-8').read()),
    html.Ul([
        html.Li(fac.AntdParagraph([
            fac.AntdText('有关'),
            fac.AntdText('AntdTabPane', strong=True),
            fac.AntdText('的使用示例请移步'),
            fac.AntdText('AntdTabs', strong=True),
            fac.AntdText('对应的文档'),
        ],
                                  style={'paddingTop': '20px'}),
                style={'listStyleType': 'circle'})
    ]),
    html.Div(style={'height': '100px'})
])
示例#11
0
 html.Div(
     [
         html.Div(html.H1(app.title), id="maintitle"),
         html.H2("About"),
         html.Img(src="assets/images/logo.png", className="sycologo"),
         html.Img(src="assets/images/schema.png", className="sycoschema"),
         html.Div(about_html + [
             html.P(
                 html.A(html.B("Watch the tutorial on Youtube"),
                        href='https://youtu.be/i8i4HmEEw4Y',
                        target='_blank')),
         ],
                  className="info-container"),
         html.H2("Steps"),
         html.Div(html.Ol([
             html.Li(html.A('Compute diverse set', href='maxdiv/')),
             html.Li(
                 html.A('Genetic Algorithm: compute next generation',
                        href='ga/')),
             html.Li(html.A('Determine importance of variables',
                            href='ml/')),
         ]),
                  className="sycolinks"),
         html.H2("Changelog"),
         html.Ul([
             html.Li([html.B(k + " "), html.Span(v)]) for k, v in changelog
         ], ),
         html.P([
             "Find the code ",
             html.A("on github",
                    href="https://github.com/ltalirz/sycofinder",
示例#12
0
def return_li_files():
    files = list_uploaded_files()
    if len(files) == 0:
        return [html.Li("No event logs loaded yet!")]
    else:
        return [html.Li(show_file_link(filename)) for filename in files]
示例#13
0
def process_fmu(fmu_filename):

    basename, _ = os.path.splitext(fmu_filename)
    pickle_filename = basename + '.p'
    fmu_hash = os.path.basename(basename)

    try:
        model_description = read_model_description(fmu_filename,
                                                   validate=False)
    except Exception as e:
        alert = dbc.Alert([
            html.I(className='fas fa-times me-3'),
            f"Failed to read model description. {e}"
        ],
                          id='alert',
                          color='danger',
                          className='mt-3')
        with open(pickle_filename, 'wb') as f:
            pickle.dump([alert], f)
        return

    platforms = supported_platforms(fmu_filename)

    with zipfile.ZipFile(fmu_filename, 'r') as zf:
        nl = filter(lambda n: not n.endswith('/'), zf.namelist())

    fmi_types = []

    if model_description.modelExchange:
        fmi_types.append('Model Exchange')

    if model_description.coSimulation:
        fmi_types.append('Co-Simulation')

    def na(attr):
        value = getattr(model_description, attr)
        if value:
            return value
        else:
            return html.Span('n/a', className='text-muted')

    rows = [
        dbc.Row([
            dbc.Col(html.Span("FMI Version"), width=4),
            dbc.Col(html.Span(model_description.fmiVersion), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col("FMI Type", width=4),
            dbc.Col(', '.join(fmi_types), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col("Model Name", width=4),
            dbc.Col(model_description.modelName, width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col("Platforms", width=4),
            dbc.Col(', '.join(platforms), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Continuous States"), width=4),
            dbc.Col(html.Span(model_description.numberOfContinuousStates),
                    width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Event Indicators"), width=4),
            dbc.Col(html.Span(model_description.numberOfEventIndicators),
                    width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Model Variables"), width=4),
            dbc.Col(html.Span(len(model_description.modelVariables)), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Generation Date"), width=4),
            dbc.Col(na('generationDateAndTime'), width=8)
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Generation Tool"), width=4),
            dbc.Col(na('generationTool'), width=8)
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("Description"), width=4),
            dbc.Col(na('description'), width=8)
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("SHA256"), width=4),
            dbc.Col(html.Span(fmu_hash), width=8),
        ],
                className='py-1'),
        dbc.Row([
            dbc.Col(html.Span("File Size"), width=4),
            dbc.Col(html.Span(f'{os.path.getsize(fmu_filename)} bytes'),
                    width=8),
        ],
                className='py-1'),
    ]

    try:
        problems = validate_fmu(fmu_filename)
    except Exception as e:
        problems = [str(e)]

    if problems:
        alert = dbc.Alert([
            html.P([
                html.I(className='fas fa-exclamation-circle me-3'),
                f"Validation failed. {len(problems)} {'problem was' if len(problems) == 1 else 'problems were'} found:"
            ]),
            html.Ul([html.Li(problem) for problem in problems])
        ],
                          id='alert',
                          color='danger',
                          className='mt-3')
    else:
        alert = dbc.Alert([
            html.I(className='fas fa-check me-3'),
            "Validation passed. No problems found."
        ],
                          id='alert',
                          color='success',
                          className='mt-3')

    variables = []

    table_header = [
        html.Thead(
            html.Tr([
                html.Th("Type"),
                html.Th("Name"),
                html.Th("Causality"),
                html.Th("Start", className='text-right'),
                html.Th("Unit"),
                html.Th("Description")
            ]))
    ]

    for variable in model_description.modelVariables:

        unit = variable.unit

        if unit is None and variable.declaredType is not None:
            unit = variable.declaredType.unit

        if variable.type == 'Boolean':
            color = '#c900c9'
        elif variable.type == 'Binary':
            color = '#ab0000'
        elif variable.type.startswith(('Int', 'Enum')):
            color = '#c78f00'
        elif variable.type.startswith(('Real', 'Float')):
            color = '#0000bf'
        else:  # String
            color = '#00a608'

        variables.append(
            html.Tr([
                html.Td(
                    html.Small(variable.type,
                               style={
                                   'color': color,
                                   'border': '1px solid ' + color,
                                   'border-radius': '1em',
                                   'padding': '0 0.5em 0 0.5em',
                               })),
                html.Td(variable.name),
                # html.Td(variable.variability),
                html.Td(variable.causality),
                html.Td(variable.start, className='text-right'),
                html.Td(unit),
                html.Td(variable.description, className='text-muted')
            ]))

    table = dbc.Table(table_header + [html.Tbody(variables)],
                      borderless=True,
                      size='sm')

    tabs = dbc.Tabs([
        dbc.Tab(rows, label="Model Info", className='p-4'),
        dbc.Tab(table, label="Variables", className='p-4'),
        dbc.Tab(html.Pre('\n'.join(nl)), label="Files", className='p-4'),
    ],
                    id='tabs')

    with open(pickle_filename, 'wb') as f:
        pickle.dump([alert, tabs], f)
示例#14
0
     html.Img(src=app.get_asset_url('imgs/fac-logo.svg'),
              style={'height': '155px'})
 ],
          style={
              'display': 'flex',
              'justifyContent': 'center',
              'alignItems': 'center'
          }),
 fac.AntdDivider(),
 fac.AntdParagraph([
     fac.AntdText('🤩', style={'fontSize': '26px'}),
     fac.AntdText('特性', strong=True, style={'fontSize': '26px'}),
 ],
                   id='特性'),
 html.Ul([
     html.Li('🎁 功能丰富,在antd的基础上设计出更多增广功能',
             style={'listStyleType': 'circle'}),
     html.Li('😋 使用简单,开发者上手难度低,无需javascript代码即可实现复杂交互',
             style={'listStyleType': 'circle'}),
     html.Li('💎 文档详实,针对每个组件的主要功能及用法予以丰富案例介绍',
             style={'listStyleType': 'circle'})
 ]),
 fac.AntdParagraph([
     fac.AntdText('🛫', style={'fontSize': '26px'}),
     fac.AntdText('版本', strong=True, style={'fontSize': '26px'}),
 ],
                   id='版本'),
 html.Ul([
     html.Li(fac.AntdParagraph([
         fac.AntdText('pypi最新稳定版本:'),
         fac.AntdTag(content=fac.__version__),
         html.Img(
示例#15
0
from dash.dependencies import Input, Output
from ts_app.dash_app import app
from ts_app.file_upload import process_upload

input_layout = html.Div(
    [
        dcc.Upload(
            id="file-upload",
            accept=".csv,.xls,.xlsx",
            className="file-upload",
            children=[
                "Click or Drag and Drop",
                html.P("Expected file properties:"),
                html.Ul(
                    children=[
                        html.Li("At most 7MiB"),
                        html.Li("Dates in first column"),
                        html.Li("Numeric data in right-most column"),
                        html.Li("At least 32 rows"),
                    ]
                ),
            ],
            min_size=32,
            max_size=1024**2 * 7,  # 7MiB
        ),
        html.P(id="file-info"),
    ]
)


@app.callback(
示例#16
0
         "What is being checked?"
     ],
            id="what-is-validated-link",
            style={
                'color': '#007bff',
                'cursor': 'pointer'
            })),
 dbc.Collapse([
     html.
     P("FMU Check performs a static analysis of the FMU that validates the following aspects:"
       ),
     html.Ul([
         html.
         Li("validity of the modelDescription.xml w.r.t. the XML schema"
            ),
         html.Li("uniqueness and validity of the variable names"),
         html.Li("completeness and integrity of the Model Structure"),
         html.Li("availability of the required start values"),
         html.Li("combinations of causality and variability"),
         html.Li("definition of units"),
     ]),
     html.P("It does not check the following aspects:"),
     html.Ul([
         html.Li("validity of the binaries"),
         html.Li("validity of the sources"),
         html.Li("any non-standard files inside the FMU"),
     ])
 ],
              id="what-is-validated-paragraph"),
 dbc.InputGroup([
     dbc.Input(id='fmu-input',