示例#1
0
            className="mb-3",
            color="dark",
            outline=True,
            size="sm",
            block=True),
 dbc.Collapse(
     [
         dbc.FormGroup([
             dbc.Checklist(
                 options=[{
                     "label": "Semi-log Plot",
                     "value": False
                 }],
                 value=False,  #HACK: notice that this is a boolean
                 id="log-scale-toggle",
                 switch=True,
             ),
             dbc.Tooltip(
                 "Plot y-axis using a logarithmic scale (Default: False)",
                 target="log-scale-toggle",
                 placement='right',
                 offset=0,
             ),
         ]),
         dbc.FormGroup([
             dbc.Checklist(
                 options=[{
                     "label": "Plot Actual Deaths and Cases",
                     "value": True
                 }],
                 value=[True],  #HACK: Notice that this is a list
示例#2
0

nterms_base = dbc.FormGroup([
    dbc.Label("Number of base terms"),
    dbc.Input(placeholder="1",
              value=1,
              type="number",
              id='nterms_base',
              debounce=True,
              min=0,
              max=4),
    dbc.Label("Number of band terms"),
    dbc.Input(placeholder="1",
              value=1,
              type="number",
              id='nterms_band',
              debounce=True,
              min=0,
              max=4),
    dbc.Label("Set manually the period (days)"),
    dbc.Input(placeholder="Optional",
              value=None,
              type="number",
              id='manual_period',
              debounce=True)
],
                            style={
                                'width': '100%',
                                'display': 'inline-block'
                            })

submit_varstar_button = dbc.Button('Fit data',
示例#3
0
def get_dcf_current_year_input_overrides():
    return [
        dbc.Form([
            dbc.FormGroup([
                dbc.Label("Revenue (M$)", html_for="year0-revenue"),
                dbc.Input(type="number",
                          id="year0-revenue",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("R&D (M$)", html_for="year0-randd"),
                dbc.Input(type="number",
                          id="year0-randd",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("CapEx (M$)", html_for="year0-capex"),
                dbc.Input(type="number",
                          id="year0-capex",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("EBIT excl. Reinvestment (M$)",
                          html_for="year0-ebit"),
                dbc.Input(type="number",
                          id="year0-ebit",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Past Revenue CAGR (%)", html_for="year0-rgr"),
                dbc.Input(
                    type="number",
                    id="year0-rgr",
                    disabled=True,
                ),
            ]),
            dbc.FormGroup([
                dbc.Label("Cash and Equivalents (M$)", html_for="cash"),
                dbc.Input(type="number",
                          value=0,
                          id="cash",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Common Shares Outstanding (Millions)",
                          html_for="shares-outstanding"),
                dbc.Input(type="number",
                          value=0,
                          id="shares-outstanding",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Minority Interests (M$)",
                          html_for="minority-interests"),
                dbc.Input(type="number",
                          value=0,
                          id="minority-interests",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Nonoperating Assets (M$)",
                          html_for="nonoperating-assets"),
                dbc.Input(type="number",
                          value=0,
                          id="nonoperating-assets",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Employee Options Value (M$)",
                          html_for="options-value"),
                dbc.Input(type="number",
                          value=0,
                          id="options-value",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Book Value of Longterm Debt (M$)",
                          html_for="debt-book-value"),
                dbc.Input(type="number",
                          value=0,
                          id="debt-book-value",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Interest Expense (M$)",
                          html_for="interest-expense"),
                dbc.Input(type="number",
                          value=0,
                          id="interest-expense",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Convertible Debt Book Value (M$)",
                          html_for="convertible-debt-book-value"),
                dbc.Input(type="number",
                          value=0,
                          id="convertible-debt-book-value",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Convertible Market Value (M$)",
                          html_for="convertible-market-value"),
                dbc.Input(type="number",
                          value=0,
                          id="convertible-market-value",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Preferred Equity Number of Shares (Millions)",
                          html_for="preferred-num-shares"),
                dbc.Input(type="number",
                          value=0,
                          id="preferred-num-shares",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Preferred Price per share ($)",
                          html_for="preferred-price-pershare"),
                dbc.Input(type="number",
                          value=70,
                          id="preferred-price-pershare",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Preferred Dividend per share ($)",
                          html_for="preferred-dividend-pershare"),
                dbc.Input(type="number",
                          value=5,
                          min=0.01,
                          step=0.01,
                          id="preferred-dividend-pershare",
                          placeholder="Enter number",
                          debounce=True),
            ]),
            dbc.FormGroup([
                dbc.Label("Debt Value of Operating Leases (M$)",
                          html_for="debt-value-op-leases"),
                dbc.Input(type="number",
                          value=0,
                          id="debt-value-op-leases",
                          placeholder="Enter number",
                          debounce=True),
            ]),
        ],
                 inline=True),
        dbc.Form([
            dbc.FormGroup([
                dbc.Label("Average Maturity Duration (years)",
                          html_for="average-maturity"),
                dcc.Slider(
                    id="average-maturity",
                    min=2,
                    max=10,
                    step=0.25,
                    value=3,
                    marks={v: str(v)
                           for v in range(2, 11)},
                )
            ]),
            dbc.FormGroup([
                dbc.Label("Pretax Cost of Debt (%)",
                          html_for="pretax-cost-debt"),
                dcc.Slider(
                    id="pretax-cost-debt",
                    min=2,
                    max=10,
                    step=0.25,
                    value=4,
                    marks={v: str(v)
                           for v in range(2, 11)},
                )
            ]),
            dbc.FormGroup([
                dbc.Label("Convertible Debt Portion of Market Value (%)",
                          html_for="convertible-debt-portion"),
                dcc.Slider(
                    id="convertible-debt-portion",
                    min=0,
                    max=100,
                    step=5,
                    value=0,
                    marks={v: str(v)
                           for v in range(0, 101, 5)},
                )
            ]),
        ])
    ]
示例#4
0
countries = country()
#end this block

#controls
controls = dbc.Card(
    [
        dbc.Row(
            [
                dbc.Col(
                    dbc.FormGroup([
                        dbc.Label("Choose a Country:"),
                        dcc.Dropdown(
                            id="country-selector",
                            options=[{
                                "label": x,
                                "value": x
                            } for x in countries],
                            value="All"  #, multi = True
                        )
                    ])),
            ],
            align='center')
    ],
    body=True)

# inicialisation Graph
graph = dcc.Graph(id='graph')

#general layout
app.layout = dbc.Container(
示例#5
0
import dash_bootstrap_components as dbc
import dash_html_components as html
import dash_core_components as dcc

search_string_input = dbc.FormGroup(
    [
        dbc.Label("Search String", html_for="search-string-row", width=2),
        dbc.Col(
            dbc.Input(
                type="text", id="search-string", placeholder="Enter title"),
            width=10,
        ),
    ],
    row=True,
)

date_input = dbc.FormGroup(
    [
        dbc.Label("Date", html_for="date-row", width=2),
        dbc.Col(
            dcc.DatePickerRange(id="date-row", display_format="Y"),
            width=10,
        ),
    ],
    row=True,
)

n_input = dbc.FormGroup(
    [
        dbc.Label("Number of results", html_for="n-row", width=2),
        dbc.Col(
示例#6
0
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output, State

from app import app, ADMINS
from flask_login import login_user

username_input = dbc.FormGroup([
    dbc.Label("Entrer votre nom d'administrateur"),
    dbc.Input(placeholder="Nom", type="text", id="uname-box")
])

pwd_input = dbc.FormGroup([
    dbc.Label("Entrer votre mot de passe"),
    dbc.Input(placeholder="Mot de passe", type="password", id="pwd-box")
])
layout = html.Div([
    dcc.Location(id="url_login", refresh=True),
    dbc.Row(
        dbc.Col(
            dbc.Form([
                dbc.Alert(
                    "Nom d'utilisateur ou mot de passe incorrect",
                    id="output-state",
                    color="danger",
                    dismissable=True,
                ),
                username_input,
                pwd_input,
                dbc.Button(children="Login",
def make_item(i, d=False):
    return dbc.Card([
        dbc.CardHeader(
            html.H1(
                dbc.Button(f"Loan #{i}",
                           color="link",
                           id=f"loan-{i}-toggle",
                           disabled=d,
                           style={"font-size": "20px"}))),
        dbc.Collapse(
            html.P([
                html.Br(),
                dbc.FormGroup([
                    dbc.Label("Please Enter the loan amount", size="md"),
                    dbc.InputGroup([
                        dbc.InputGroupAddon("$", addon_type="prepend"),
                        dbc.Input(placeholder="Please Enter the loan amount",
                                  type="number",
                                  min=0,
                                  bs_size="md",
                                  inputMode="numeric",
                                  id=f'loan-input{i}'),
                    ]),
                ],
                              className="mx-2"),
                dbc.FormGroup([
                    dbc.Label("Please Enter the interest rate:", size="md"),
                    dbc.InputGroup([
                        dbc.Input(placeholder="Please Enter the interest rate",
                                  type="number",
                                  min=0,
                                  bs_size="md",
                                  inputMode="numeric",
                                  id=f'rate-input{i}'),
                        dbc.InputGroupAddon("%", addon_type="append")
                    ]),
                ],
                              className="mx-2"),
                dbc.FormGroup([
                    dbc.Label("Please Enter the payment:", size="md"),
                    dbc.InputGroup([
                        dbc.InputGroupAddon("$", addon_type="prepend"),
                        dbc.Input(placeholder="Please Enter the payment",
                                  type="number",
                                  min=0,
                                  bs_size="md",
                                  inputMode="numeric",
                                  id=f'payment-input{i}'),
                    ]),
                ],
                              className="mx-2"),
                dbc.FormGroup([
                    dbc.Label("Please Enter the extra payment:", size="md"),
                    dbc.InputGroup([
                        dbc.InputGroupAddon("$", addon_type="prepend"),
                        dbc.Input(placeholder="Please Enter the extra payment",
                                  type="number",
                                  min=0,
                                  bs_size="md",
                                  inputMode="numeric",
                                  id=f'expayment-input{i}'),
                    ]),
                ],
                              className="mx-2"),
                dbc.ButtonGroup([
                    dbc.Button("Submit",
                               outline=True,
                               id=f"button-submit{i}",
                               color="success",
                               className="mr-1",
                               n_clicks=0),
                    dbc.Button("Clear",
                               outline=True,
                               id=f"button-clear{i}",
                               color="warning",
                               className="mr-1",
                               n_clicks=0)
                ],
                                className="mx-2 mb-2")
            ],
                   className="w-100 mb-3"),
            id=f"collapse-{i}",
        ),
    ])
示例#8
0
drop_down_list = [
    dbc.DropdownMenuItem("First"),
    dbc.DropdownMenuItem(divider=True),
    dbc.DropdownMenuItem("Links", header=True),
    dbc.DropdownMenuItem("Internal link", href="/l/components/alerts"),
    dbc.DropdownMenuItem("External link", href="https://baidu.com"),
    dbc.DropdownMenuItem(divider=True),
    dbc.DropdownMenuItem("Disabled", disabled=True),
    dbc.DropdownMenuItem("Active", active=True)
]


# ---------------------------------------------------------------------------------------
email_input = dbc.FormGroup(children=[
    dbc.Label("Email", html_for="example-email"),
    dbc.Input(type="email", id="example-email", placeholder="Enter email"),
    dbc.FormText("Are you on email? You simply have to be these days", color="secondary"),
])

password_input = dbc.FormGroup(children=[
    dbc.Label("Password", html_for="example-password"),
    dbc.Input(type="password", id="example-password", placeholder="Enter password"),
    dbc.FormText("A password stops mean people taking your stuff", color="secondary"),
])


# ---------------------------------------------------------------------------------------
email_input_row = dbc.FormGroup(children=[
    dbc.Label("Email", html_for="example-email-row", width=2),
    dbc.Col(dbc.Input(type="email", id="example-email-row", placeholder="Enter email"), width=10)
], row=True)
示例#9
0
import dash_bootstrap_components as dbc

text_input = dbc.FormGroup([
    dbc.Label("Text"),
    dbc.Input(placeholder="Input goes here...", type="text"),
    dbc.FormText("Type something in the box above"),
])
def find_virus_columns(virus):
    return [
        x for x in df.columns.tolist()
        if re.compile(r'[SR1|SR2|winter]_P*{virus}V*$'.format(
            virus=virus)).search(x)
    ]


left_column = dbc.Card([
    dbc.FormGroup([
        dbc.Label("Season"),
        dcc.Dropdown(
            id="season_inspection",
            options=[{
                "label": col,
                "value": col
            } for col in ["summer", "winter", "summer and winter"]],
            value="summer",
        ),
    ]),
    dbc.FormGroup([
        dbc.Label("Disease"),
        dcc.Dropdown(
            id="disease_type",
            options=[{
                "label": col,
                "value": col
            } for col in ["MOS", "LR", "MIX", "ST", "BRR"]],
            value="LR",
        ),
示例#11
0
def get_app(server=None):
    if server:
        app = dash.Dash(__name__,
                        server=server,
                        url_base_pathname='/overfitting_class/',
                        external_stylesheets=[dbc.themes.BOOTSTRAP])
    else:
        app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
    app.title = "โมเดลสำหรับจำแนกที่เฉพาะเจาะจง/ง่ายเกินไป"

    ##
    data = load_breast_cancer()

    X = data['data'][:, :2]
    y = data['target']

    fn = ['รัศมีเฉลี่ย', 'ความขรุขระ']
    cn = ['มะเร็ง/เนื้อร้าย', 'เนื้องอก']

    x_train, x_test, y_train, y_test = train_test_split(X,
                                                        y,
                                                        test_size=0.4,
                                                        random_state=42)

    plot_step = 0.1
    x_min, x_max = x_train[:, 0].min() - 1, x_train[:, 0].max() + 1
    y_min, y_max = x_train[:, 1].min() - 1, x_train[:, 1].max() + 1
    xx, yy = np.meshgrid(np.arange(x_min, x_max, plot_step),
                         np.arange(y_min, y_max, plot_step))

    # train_acc = []
    # test_acc = []
    # for i in range(1,16):
    #     clf = tree.DecisionTreeClassifier(max_depth=i)
    #     clf = clf.fit(x_train, y_train)

    #     acc_tr = accuracy_score(y_train, clf.predict(x_train))
    #     acc_te = accuracy_score(y_test, clf.predict(x_test))

    #     train_acc.append(acc_tr)
    #     test_acc.append(acc_te)

    def get_fig(depth=4):
        clf = tree.DecisionTreeClassifier(max_depth=depth)
        clf = clf.fit(x_train, y_train)

        acc_tr = accuracy_score(y_train, clf.predict(x_train))
        acc_te = accuracy_score(y_test, clf.predict(x_test))

        Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
        Z = Z.reshape(xx.shape)

        fig = go.Figure(
            data=go.Heatmap(
                z=Z,
                x=np.arange(x_min, x_max, plot_step),
                y=np.arange(y_min, y_max, plot_step),
                colorscale=[[0, '#ef553b'], [1, '#636efa']],
                opacity=0.2,
                colorbar=dict(),
                showscale=False
                # colorbar=dict(nticks=10, ticks='outside',
                #               ticklen=5, tickwidth=1,
                #               showticklabels=True,
                #               tickangle=0, tickfont_size=12)
            ),
            layout=go.Layout(
                uirevision=True,
                margin=dict(b=0, l=0, r=0, t=40),
                xaxis=dict(range=[x_min, x_max]),
                xaxis_title=fn[0],
                yaxis=dict(range=[y_min, y_max]),
                yaxis_title=fn[1],
            ))

        colors = ['239, 85, 59', '99, 110, 250']
        symbols = ['circle', 'square']
        for i, (color, symbol) in enumerate(zip(colors, symbols)):
            idx = np.where(y_train == i)
            fig.add_trace(
                go.Scatter(
                    x=x_train[idx, 0].squeeze(),
                    y=x_train[idx, 1].squeeze(),
                    mode='markers',
                    name=cn[i] + ' train',
                    marker_color='rgb(' + color + ')',
                ))

        # for i, color in enumerate(colors):
        #     idx = np.where(y_train == i)
        #     fig.add_trace(go.Scatter(x=x_train[idx, 0].squeeze(), y=x_train[idx, 1].squeeze(),
        #                             mode='markers',
        #                             name=data.target_names[i],
        #                             marker_color=color,
        #                             opacity=0.8))
        for i, color in enumerate(colors):
            idx = np.where(y_test == i)
            fig.add_trace(
                go.Scatter(x=x_test[idx, 0].squeeze(),
                           y=x_test[idx, 1].squeeze(),
                           mode='markers',
                           name=cn[i] + ' test',
                           marker_color='rgba(' + color + ', 0.4)',
                           marker_line_color='rgba(' + color + ', 1.0)',
                           marker_line_width=1))

            # fig.add_trace(go.Scatter(x=x_test[idx, 0].squeeze(), y=x_test[idx, 1].squeeze(),
            #                         mode='markers',
            #                         name=data.target_names[i] + ' test',
            #                         marker_color=color,
            #                         opacity=0.3))
        return fig, acc_tr, acc_te

    fig, acc_tr, acc_te = get_fig()

    depth_marks = {i: '' for i in range(1, 11)}
    depth_marks[1] = '1'
    depth_marks[10] = '10'

    controls = dbc.Card(
        [
            dbc.FormGroup([
                html.H5([
                    "Max Depth  ",
                    dbc.Badge("4",
                              className="ml-1",
                              color="primary",
                              id='depth-label')
                ]),
                dcc.Slider(id='depth-slider-id',
                           min=1,
                           max=10,
                           step=None,
                           marks=depth_marks,
                           value=4),
            ]),
            html.Div([
                html.H5([" ความแม่นยำ "]),
                html.H6([
                    " ความแม่นยำ บน training data =  ",
                    dbc.Badge(f'{acc_tr:.3f}',
                              className="ml-1",
                              color="success",
                              id='accuracy-train-id')
                ]),
                html.H6([
                    " ความแม่นยำ บน test data = ",
                    dbc.Badge(f'{acc_te:.3f}',
                              className="ml-1",
                              color="danger",
                              id='accuracy-test-id')
                ]),
            ])
        ],
        body=True,
    )

    ## Main layout
    app.layout = dbc.Container(
        [
            html.
            H1("โมเดลที่เฉพาะเจาะจงเกินไป VS โมเดลที่ง่ายเกินไป (Overfitting/Underfitting in Classification)"
               ),
            html.Div(children='''
                ในแบบฝึกหัดนี้ ให้นักเรียนลองเปลี่ยนค่าตัวแปร depth ของ Decision Tree แล้วดูว่าเมื่อใดก่อให้เกิดโมเดลที่เฉพาะเจาะจงเกินไป 
                (overfitting) และ โมเดลที่ง่ายเกินไป (underfitting) โดยการวาดกราฟเส้นระหว่างความแม่นยำกับค่าตัวแปร depth 
                ของ Decision Tree ของทั้ง training data และ test data
            '''),
            html.Hr(),
            dbc.Row(
                [
                    dbc.Col(controls, md=4),
                    dbc.Col(dcc.Graph(id="graph-id", figure=fig), md=8),
                ],
                align="center",
            ),
        ],
        fluid=True,
    )

    # app.layout = html.Div([
    #     html.H1(children='Overfitting/Underfitting in Classification'),

    #     html.Div(children='''
    #         ในแบบฝึกหัดนี้ ให้นักเรียนลองเปลี่ยนค่า hyperparamter depth ของ Decision Tree แล้วดูว่าเมื่อใดเกิด overfitting/underfitting
    #     '''),
    #     html.Div(children=[
    #         # dcc.Markdown('### ชุดข้อมูล'),
    #         # dcc.Dropdown(
    #         #     options=[
    #         #         {'label': 'มะเร็งเต้านม', 'value': 'breast_cancer'},
    #         #     ],
    #         #     value='breast_cancer'
    #         # ),

    #         dcc.Markdown('### Max Depth'),
    #         dcc.Slider(
    #             id='depth-slider-id',
    #             min=1,
    #             max=16,
    #             marks={i: '{}'.format(i) for i in [1, 4, 7, 10, 13, 16]},
    #             value=4,
    #         ),

    #         dcc.Graph(figure=go.Figure([go.Scatter(x=list(range(1,16)), y=train_acc, mode='markers', name="Train"),
    #                             go.Scatter(x=list(range(1,16)), y=test_acc, mode='lines+markers', name="Test")],
    #                             layout=go.Layout(
    #             title='ข้อมูลที่ใช้ Train โมเดล',
    #             xaxis=dict(range=[0, 17]),
    #             xaxis_title='Depth',
    #             yaxis=dict(range=[0, 1.1]),
    #             yaxis_title='Accuracy',
    #         )))
    #     ],
    #         style={'width': '40%', 'display': 'inline-block', 'vertical-align': 'top'}
    #     ),

    #     html.Div(children=[
    #         dcc.Graph(id='graph-id', figure=fig),
    #         html.Div([
    #             html.Div(id='accuracy-train-id', children=f'Train Accuracy = {acc_tr:.3f}'),
    #             html.Div(id='accuracy-test-id', children=f'Test Accuracy = {acc_te:.3f}')
    #         ],
    #             style={'textAlign': 'center'}
    #         )
    #     ],
    #         style={'width': '50%', 'display': 'inline-block'}
    #     )
    # ])

    @app.callback([
        Output(component_id='depth-label', component_property='children'),
        Output(component_id='graph-id', component_property='figure'),
        Output(component_id='accuracy-train-id',
               component_property='children'),
        Output(component_id='accuracy-test-id', component_property='children')
    ], [Input(component_id='depth-slider-id', component_property='value')])
    def update_under_div(depth):
        fig, acc_tr, acc_te = get_fig(depth)
        return [f'{depth}', fig, f'{acc_tr:.3f}', f'{acc_te:.3f}']

    return app
示例#12
0
app = dash.Dash(__name__,
                external_stylesheets=[dbc.themes.BOOTSTRAP
                                      ])  # https://bootswatch.com/default/

modal = html.Div([
    dbc.Button("Add comment", id="open"),
    dbc.Modal(
        [
            dbc.ModalHeader("All About Berlin"),
            dbc.ModalBody(
                dbc.Form(
                    [
                        dbc.FormGroup(
                            [
                                dbc.Label("Name", className="mr-2"),
                                dbc.Input(type="text",
                                          placeholder="Enter your name"),
                            ],
                            className="mr-3",
                        ),
                        dbc.FormGroup(
                            [
                                dbc.Label("Email", className="mr-2"),
                                dbc.Input(type="email",
                                          placeholder="Enter email"),
                            ],
                            className="mr-3",
                        ),
                        dbc.FormGroup(
                            [
                                dbc.Label("Comment", className="mr-2"),
                                dbc.Input(type="text",
示例#13
0
    'https://codepen.io/chriddyp/pen/bWLwgP.css', {
        'href':
        'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css',
        'rel': 'stylesheet',
        'integrity':
        'sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO',
        'crossorigin': 'anonymous'
    }
]

email_input = html.Div([
    dbc.FormGroup([
        dbc.Label("Email"),
        dbc.Input(id="email-input", type="email", value=""),
        dbc.FormText("We only accept gmail..."),
        dbc.FormFeedback("That looks like a gmail address :-)", valid=True),
        dbc.FormFeedback(
            "Sorry, we only accept gmail for some reason...",
            valid=False,
        ),
    ])
])

form = dbc.Form(
    [
        dbc.FormGroup(
            [
                dbc.Label("Email", className="mr-2"),
                dbc.Input(type="email", placeholder="Enter email"),
            ],
            className="mr-3",
        ),
示例#14
0
controls1 = dbc.FormGroup([
    html.P('Modelos de Regresión', style=CARD_TEXT_STYLE),
    dcc.Dropdown(
        id='dropdown',
        options=[{
            'label': 'Modelo Regresión',
            'value': 'Modelo Regresion'
        }, {
            'label': 'Modelo Ridge',
            'value': 'Modelo Ridge'
        }, {
            'label': 'Modelo Lasso',
            'value': 'Modelo Lasso'
        }, {
            'label': 'Modelo Huber',
            'value': 'Modelo Huber'
        }, {
            'label': 'Resultado Real',
            'value': 'Real'
        }],
        value=['Modelo Regresion', 'Real'],  # default value
        multi=True),
    html.Br(),
    html.P('Cantidad de Cajas Unitarias', style=CARD_TEXT_STYLE),
    dcc.RangeSlider(id='range_slider',
                    min=mincuota,
                    max=maxcuota,
                    step=stepcuota,
                    value=[mincuota, maxcuota],
                    marks={
                        mincuota: str(mincuota),
                        quartil1: str(quartil1),
                        quartil2: str(quartil2),
                        quartil3: str(quartil3),
                        maxcuota: str(maxcuota)
                    }),
    html.Br(),
    html.P('Gastos logísticos', style=CARD_TEXT_STYLE),
    dbc.Input(id="input_gastos",
              placeholder="Gastos Logísticos",
              type="number",
              value=400000),
    html.Br(),
    dbc.Button(id='submit_button',
               n_clicks=0,
               children='Actualizar',
               color='primary',
               block=True)
])
} for i in range(10)])
mdf = pd.DataFrame([{'----': "Upload a Metadata File"}])

upload_file_name = ""
db_engine = None
table_obj = None
entity_names = ['Connect to a db first']
pill_button = {'border-radius': '40px'}

# Defining fields for db connections
hostname_input = dbc.FormGroup(
    [
        dbc.Label("Hostname", width=2),
        dbc.Col(
            dbc.Input(id="db-field-1",
                      type="email",
                      placeholder="Enter host connection information"),
            width=10,
        ),
    ],
    row=True,
)
user_input = dbc.FormGroup(
    [
        dbc.Label("User", html_for="example-email-row", width=2),
        dbc.Col(
            dbc.Input(
                id="db-field-2", type="User", placeholder="Enter User Name"),
            width=10,
        ),
    ],
    row=True,
示例#16
0
table_placeholder = dash_table.DataTable(id='table',
                                         style_as_list_view=True,
                                         page_size=20)

### CREATE POPUP ###
create_button = dbc.Button("Create", id='create-button', color='info')

MODAL_CREATE_BUTTON_STYLE = {'className': "mr-2", 'color': 'primary'}

MODAL_CLOSE_BUTTON_STYLE = {'className': "mr-2", 'color': 'secondary'}

create_account_name_input = dbc.FormGroup([
    dbc.Label("Name"),
    dbc.Input(id='create-account-name-input',
              placeholder='Name',
              type='text',
              debounce=True)
], )

create_account_description_input = dbc.FormGroup([
    dbc.Label("Description"),
    dbc.Input(id='create-account-description-input', placeholder='Description')
])

create_account_label_dropdown = dbc.FormGroup([
    dbc.Label("Label"),
    dcc.Dropdown(id='create-account-label-dropdown',
                 placeholder='Label',
                 options=labels_options)
])
示例#17
0
trust_name = dat_t['Var1'].values
TRUST_OPTIONS = []
for i in range(len(trust_name)):
    d = {
        'label': trust_name[i],
        'value': trust_name[i]
    }
    TRUST_OPTIONS.append(d)
TRUST_VALUES = 'NATIONAL'

trust_select = dbc.FormGroup(
    [
        dbc.Label("Select NHS Trust", html_for='trust'),
        dcc.Dropdown(
            id='trust',
            options=TRUST_OPTIONS,
            value=TRUST_VALUES,
            multi=False,
        )

    ]
)

date_range_picker = dbc.FormGroup(
    [
        dbc.Label("Select Hospital Admission Dates", html_for='date_range'),
        dcc.DatePickerRange(
            id='date_range',
            min_date_allowed=dt(2020, 3, 10),
            max_date_allowed=dt(2020, 12, 31),
            initial_visible_month=dt(2020, 3, 5),
            start_date=dt(2020, 3, 10).date(),
示例#18
0
    ]
)
title = 'COVID Projections Tracker'
app.title = title
server = app.server

#controls - adapted from https://dash-bootstrap-components.opensource.faculty.ai/examples/iris/
controls = dbc.Card(
    [
        html.H4("Filters", className="card-title"),
        dbc.FormGroup(
            [
                dbc.Label("Model"),
                dcc.Dropdown(
                    id="model-dropdown",
                    options=[
                        {"label": col, "value": col} for col in ['IHME']
                    ],
                    value="IHME",
                ),
            ]
        ),
        dbc.FormGroup(
            [
                dbc.Label("Location"),
                dcc.Dropdown(
                    id="location-dropdown",
                    options=[
                        {"label": col, "value": col} for col in df.location_name.unique()
                    ],
                    value="United States of America",
                ),
# Number of maximum loans
loan_num = 3

loanNum = dbc.FormGroup([
    dbc.Label("Please choose the number of loans in your loan portfolio",
              size='lg',
              color='black-50'),
    dbc.RadioItems(
        options=[
            {
                "label": "1",
                "value": 1
            },
            {
                "label": "2",
                "value": 2
            },
            {
                "label": "3",
                "value": 3
            },
        ],
        value=1,
        id="loanNum-input",
        inline=True,
        style={'margin-left': '2px'},
    )
])

# Create loan table
loan_table_df = main.compute_schedule(1.0, 1.0, 1.0, 1.0)
示例#20
0
# Switch to cuda if available
model.to(device)
model.eval()
# Define app
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
server = app.server

controls = dbc.Card(
    [
        dbc.FormGroup([
            dbc.Label("Output Length (# Tokens)"),
            dcc.Slider(
                id="max-length",
                min=10,
                max=50,
                value=30,
                marks={i: str(i)
                       for i in range(10, 51, 10)},
            ),
        ]),
        dbc.FormGroup([
            dbc.Label("Beam Size"),
            dcc.Slider(
                id="num-beams",
                min=2,
                max=6,
                value=4,
                marks={i: str(i)
                       for i in [2, 4, 6]},
            ),
示例#21
0
        'width': '100%',

    }

controls = dbc.FormGroup(
    [
        dcc.Dropdown(
            id='patchSize',
            options=[{
                'label': '99 X 99',
                'value': 99
            }, {
                'label': '49 X 49',
                'value': 49
            }
            ],
            placeholder='Patch size'
        ),
        html.Br(),
        dbc.Button(
            id='submit_button',
            n_clicks=0,
            children='Train',
            color='primary',
            block=True
        ),
    ]
)

# for parameter content
sidebar = html.Div(
    [
示例#22
0
            align="center",
            no_gutters=True,
        ),
    ],
    sticky="top",
)

# left side grouping of selction options
form_card_group = dbc.Card(
    [
        dbc.FormGroup([
            dbc.Label("Choose a Stock Symbol"),
            dcc.Dropdown(
                id="stock-ticker-select",
                options=[{
                    "label": ticker,
                    "value": ticker,
                } for ticker in tickers],
                multi=True,
                value=[tickers[0]],
            ),
        ]),
        dbc.FormGroup([
            dbc.Label("Price"),
            dbc.Col(
                dbc.RadioItems(
                    id="stock-ticker-price",
                    options=[
                        {
                            "label": "Open",
                            "value": "open",
                        },
示例#23
0
文件: app.py 项目: Horoli/TIL
def render_page_content(pathname):
    # 최초경로 출력
    if pathname == '/':
        return [dbc.Jumbotron(['###안녕하세요###'])]
    # 페이지1 출력
    elif pathname == '/page-1':
        return [
            html.H1('카테고리별 평균 목표금액', style={'textAlign': 'center'}),
            multiple_input
        ]

    # 페이지2 출력
    elif pathname == '/page-2':

        return [
            html.H1('Grad School in Iran', style={'textAlign': 'center'}),
            dcc.Graph(year_df,
                      id='bar-graph',
                      x='funding_amounts',
                      y="target_amounts")
        ]

    # 페이지3 출력
    elif pathname == '/page-3':
        return [
            html.Div([
                dcc.Input(id='username', value='Initial Value', type='text'),
                html.Button(id='submit-button',
                            type='submit',
                            children='Submit'),
                html.Div(id='output_div')
            ])
        ]

    # 페이지4 출력
    elif pathname == '/dataframe':

        return [
            html.Div([
                dbc.Button('Download CSV',
                           id='btn_csv',
                           color='primary',
                           style={'margin': '1rem'}),
                dcc.Download(id='download-dataframe-csv'),
                dbc.Table(generate_table(df, 5),
                          bordered=True,
                          dark=True,
                          hover=True,
                          responsive=True,
                          striped=True),
            ])
        ]

    elif pathname == '/system':
        # cate = str(request.form['cateinput'])
        types = ['text']
        return [
            html.Div([
                dbc.FormGroup([
                    dbc.Input(id=f'my_{x}',
                              value='립밤',
                              placeholder='Enter category',
                              type=f'{x}') for x in types
                ]),
                dbc.Table(id='update-dataframe')
            ])
        ]

    # dbc.FormGroup([
    #     dbc.Label('카테고리 입력', html_for='cate-input'),
    #     dbc.Input(id=f'my_{x}', value='립밤', placeholder='Enter category', type=f'{x}') for x in types,
    #     dbc.FormText('카테고리를 입력하세요', color='secondary')
    # ]),

    else:
        # 에러메세지 출력
        return dbc.Jumbotron([
            html.H1('404:not found', className='text-danger'),
            html.Hr(),
            html.P(f'The pathname {pathname} was not recognised..')
        ])
示例#24
0
        dbc.Row(
            dbc.Col(html.H1(children='Your Ideal Zodiac Partner'), width = {'offset': 2})
        ),

        dbc.Row(
            dbc.Col(html.Div(children='''Take this quiz and find out about your ideal life partner.'''),
                width = {'offset': 2})
        ),

        html.Br(),
        html.Br(),

        dbc.Row([dbc.Col([
        dbc.Form([
            dbc.FormGroup([
                dbc.Label('Name?'),
                dbc.Input(id="name", placeholder = 'Type here', type = 'text', style = {'width': '80%'}),
            ]),

            dbc.FormGroup([
                dbc.Label("What's your Zodiac sign?", html_for = 'dropdown'),
                dcc.Dropdown(
                    options=[
                        {'label': 'Aquarius (January 20 - February 18)', 'value': 'Aquarius'},
                        {'label': 'Pisces (February 19 - March 20)', 'value': 'Pisces'},
                        {'label': 'Aries (March 21 - April 19)', 'value': 'Aries'},
                        {'label': 'Taurus (April 20 - May 20)', 'value': 'Taurus'},
                        {'label': 'Gemini (May 21 - June 20)', 'value': 'Gemini'},
                        {'label': 'Cancer (June 21 - July 22)', 'value': 'Cancer'},
                        {'label': 'Leo (July 23 - August 22)', 'value': 'Leo'},
                        {'label': 'Virgo (August 23 - September 22)', 'value': 'Virgo'},
                        {'label': 'Libra (September 23 - October 22)', 'value': 'Libra'},
示例#25
0
server = Flask(__name__)
app = dash.Dash(server=server, external_stylesheets=external_stylesheets)

controls = dbc.Card(
    [
        dbc.FormGroup(
            [
                dbc.Label("Select Stock"),
                dcc.Dropdown(
                    id="my-dropdown",
                    options=[
                        # {'label': 'Google', 'value': 'GOOGL'},
                        # {'label': 'Tata Motors', 'value': 'TATAMOTORS'},
                        {'label': 'Reliance', 'value': 'RELIANCE'},
                        {'label': 'Indigo', 'value': 'INDIGO'},
                        {'label': 'Infosys', 'value': 'INFY'},
                        {'label': 'IRCTC', 'value': 'IRCTC'},
                        {'label': 'Aurobindo Pharma', 'value': 'AUROPHARMA'},
                        # {'label': 'AT&T Inc.', 'value': 'T'}
            
                    ],
                    value='RELIANCE',
                ),
                html.Br(),
                
            ]
        ),
    
        
    ],
    body=True,
)
示例#26
0
dash_app = Dash(
    __name__,
    server=app,
    external_stylesheets=[dbc.themes.DARKLY],
    # routes_pathname_prefix='/dash_app/',
    url_base_pathname='/dash_app/')

covid_df = pd.read_csv('./src/static/owid-covid-data.csv')

data_input = dbc.FormGroup([
    dbc.Label('Select data', html_for='dropdown'),
    dcc.Dropdown(id='data_dropdown',
                 options=[{
                     'label': 'COVID-19 Dataset',
                     'value': 'covid'
                 }, {
                     'label': 'Upload your own',
                     'value': 'upload'
                 }],
                 value='covid',
                 style={'color': 'rgb(230, 230, 230)'})
])

plotly_input = dbc.FormGroup([
    dbc.Label('Plot Type'),
    dcc.Dropdown(id='type_dropdown',
                 options=[{
                     'label': 'line',
                     'value': 'line'
                 }, {
                     'label': 'scatter',
示例#27
0
DF = pd.read_csv('./data/unc.csv')
YEARS_DF = DF['Año'].unique()
TIPOS_DE_DELITO = DF['Tipo de delito'].unique()

with open('./geo/mexico.geojson') as f:
    STATES = json.load(f)


app.layout = html.Div([
   dbc.FormGroup(
       [
           dbc.Label("Tipo de delito"),
           dcc.Dropdown(
               id="in-delito",
               value=TIPOS_DE_DELITO[0],
               options=[
                   {"label": col, "value": col} for col in DF['Tipo de delito'].unique()
               ]
           ),
       ]
   ),

   dcc.Slider(
       id='in-year-slider',
       min=0,
       max=len(YEARS_DF),
       marks={i: str(YEARS_DF[i]) for i in range(len(YEARS_DF))},
       value=0,
   ),
  
   dcc.Graph(id="delito-map")
示例#28
0
# dict with quarters as values used for slider
d = dict(zip(range(0, 9), adj.keys()))
d = {int(k): v for k, v in d.items()}

# list for centrality measures used for dropdown
ls_centrality = ['degree', 'betweenness', 'closeness', 'eigenvector', 'mean']

BS = "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
app = dash.Dash(__name__, external_stylesheets=[BS])

control_centrality = dbc.Card([
    dbc.FormGroup([
        dbc.Label("Node definition:"),
        dcc.Dropdown(id="centrality",
                     options=[{
                         "label": i,
                         "value": i
                     } for i in ls_centrality],
                     value="degree"),
    ]),
])
control_quarter = dbc.Card([
    dbc.Label("Quarter:"),
    dcc.Slider(
        id="quarter",
        min=0,
        max=9,
        step=None,
        marks=d,
        value=0,
    )
示例#29
0
def init_regression(server):
    options = [
        'year', 'ratings_count', 'labels_count', 'reviews_count', 'is_natural',
        'winery_ratings_count', 'winery_ratings_average',
        'winery_labels_count', 'winery_wines_count', 'users_count',
        'regions_count', 'wines_count', 'wineries_count', 'median_price',
        'bold', 'tannic', 'sweet', 'oaky', 'black fruit', 'red fruit',
        'earthy', 'spices', 'ageing', 'yeasty', 'dried fruit', 'citrus',
        'tree fruit', 'vegetal', 'floral', 'tropical', 'beef', 'lamb', 'veal',
        'poultry', 'pork', 'shellfish', 'vegetarian', 'game', 'spicy-food',
        'types'
    ]  #Mangler total flavors

    dict_options = [
        'year', 'ratings_count', 'labels_count', 'reviews_count', 'is_natural',
        'winery_ratings_count', 'winery_ratings_average',
        'winery_labels_count', 'winery_wines_count', 'users_count',
        'regions_count', 'wines_count', 'wineries_count', 'median_price',
        'bold', 'tannic', 'sweet', 'oaky', 'black fruit', 'red fruit',
        'earthy', 'spices', 'ageing', 'yeasty', 'dried fruit', 'citrus',
        'tree fruit', 'vegetal', 'floral', 'types', 'foods'
    ]  #Mangler total flavors

    TASTES = [
        'tropical', 'beef', 'lamb', 'veal', 'poultry', 'pork', 'shellfish',
        'vegetarian', 'game', 'spicy-food'
    ]

    UPPER_WIDTH = 1
    UPPER_TEXT_WIDTH = 6
    SUBSECTION_WIDTHS = '13%'

    predictor_app = Dash(
        server=server,
        title='Beyond The Grape Predictor',
        update_title=None,
        routes_pathname_prefix='/predict/',
        external_stylesheets=[dbc.themes.BOOTSTRAP, 'styles.css'],
        external_scripts=[dbc.themes.BOOTSTRAP, 'styles.css'])

    pipeline = load("app/static/models/xbg_wine_model.joblib")

    foods = dbc.FormGroup(
        [
            dbc.Label("Foods", html_for="food-checklist-row", width=2),
            dbc.Col(
                dcc.Checklist(options=[{
                    'label': 'Beef',
                    'value': 'beef'
                }, {
                    'label': 'Chicken',
                    'value': 'chicken'
                }, {
                    'label': 'Pork',
                    'value': 'pork'
                }, {
                    'label': 'Lamb',
                    'value': 'lamb'
                }, {
                    'label': 'Veal',
                    'value': 'veal'
                }, {
                    'label': 'Poultry',
                    'value': 'poultry'
                }, {
                    'label': 'Shellfish',
                    'value': 'shellfish'
                }, {
                    'label': 'Vegetarian',
                    'value': 'vegetarian'
                }, {
                    'label': 'Game',
                    'value': 'game'
                }, {
                    'label': 'Spicy food',
                    'value': 'spicy-food'
                }, {
                    'label': 'Tropical',
                    'value': 'tropical'
                }],
                              value=['beef', 'chicken', 'pork'],
                              id='food-checklist-row',
                              labelStyle={
                                  'display': 'inline-block',
                                  'margin': '5px'
                              }),
                width=7,
            ),
        ],
        row=True,
    )

    types = dbc.FormGroup(
        [
            dbc.Label("Wine type", html_for="types", width=2),
            dbc.Col(
                dcc.RadioItems(options=[
                    {
                        'label': 'Red',
                        'value': 'red'
                    },
                    {
                        'label': 'White',
                        'value': 'white'
                    },
                ],
                               value='red',
                               id='types',
                               labelStyle={
                                   'display': 'inline-block',
                                   'margin': '5px'
                               }),
                width=7,
            ),
        ],
        row=True,
    )

    # ---------------------------------------------------- Mapping ----------------------------------------------------

    predictor_app.layout = html.Div(
        [
            html.Section([
                html.Div([
                    html.H1('Beyond The Grape rating predictor',
                            className='mx-auto my-0 text-uppercase',
                            style={
                                'text-align': 'center',
                                'color': 'darkslategrey'
                            })
                ],
                         style={'margin': '3%'}),
                html.Div(
                    [

                        # ---------------------------------------------------- Section 1 ----------------------------------------------------
                        dbc.Form([foods, types]),
                        html.Div(
                            [
                                dbc.Form(
                                    [
                                        numeric_form_group(
                                            'year', 'Year', UPPER_TEXT_WIDTH,
                                            UPPER_WIDTH, 2002, 1960, 2020, 1),
                                        numeric_form_group(
                                            'median_price', 'Price',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 550,
                                            50, 6000, 50),
                                        numeric_form_group('ratings_count',
                                                           '# Ratings',
                                                           UPPER_TEXT_WIDTH,
                                                           UPPER_WIDTH,
                                                           2000,
                                                           0,
                                                           step=100),
                                        numeric_form_group('labels_count',
                                                           '# Labels',
                                                           UPPER_TEXT_WIDTH,
                                                           UPPER_WIDTH,
                                                           20,
                                                           1,
                                                           step=1),
                                        numeric_form_group('reviews_count',
                                                           '# Reviews',
                                                           UPPER_TEXT_WIDTH,
                                                           UPPER_WIDTH,
                                                           1000,
                                                           0,
                                                           step=50)
                                    ],
                                    style={
                                        'float': 'left',
                                        'margin': '1%',
                                        'width': SUBSECTION_WIDTHS
                                    }),

                                # ---------------------------------------------------- Section 2 ----------------------------------------------------
                                dbc.Form(
                                    [
                                        numeric_form_group(
                                            'tannic', 'Tannic',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 30,
                                            0, 100, 1),
                                        numeric_form_group(
                                            'sweet', 'Sweet', UPPER_TEXT_WIDTH,
                                            UPPER_WIDTH, 30, 0, 100, 1),
                                        numeric_form_group(
                                            'bold', 'Bold', UPPER_TEXT_WIDTH,
                                            UPPER_WIDTH, 30, 0, 100, 1),
                                        numeric_form_group(
                                            'black fruit', 'Black Fruit',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                        numeric_form_group(
                                            'red fruit', 'Red Fruit',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                    ],
                                    style={
                                        'float': 'left',
                                        'margin': '1%',
                                        'width': SUBSECTION_WIDTHS
                                    }),
                                # ---------------------------------------------------- Section 3 ----------------------------------------------------
                                dbc.Form(
                                    [
                                        numeric_form_group(
                                            'earthy', 'Earthy',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                        numeric_form_group(
                                            'is_natural', 'Is Natural',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0,
                                            0, 1, 1),
                                        numeric_form_group(
                                            'winery_ratings_count',
                                            '# Winery Ratings',
                                            UPPER_TEXT_WIDTH,
                                            UPPER_WIDTH,
                                            1000,
                                            0,
                                            step=100),
                                        numeric_form_group(
                                            'winery_ratings_average',
                                            'winery_ratings_average',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 4,
                                            0, 5, 0.1),
                                        numeric_form_group(
                                            'winery_labels_count',
                                            '# winery Labels',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 20,
                                            0, 10000, 10),
                                    ],
                                    style={
                                        'float': 'left',
                                        'margin': '1%',
                                        'width': SUBSECTION_WIDTHS
                                    }),
                                # ---------------------------------------------------- Section 4 ----------------------------------------------------
                                dbc.Form(
                                    [
                                        numeric_form_group(
                                            'winery_wines_count',
                                            '#Winery Wines', UPPER_TEXT_WIDTH,
                                            UPPER_WIDTH, 20, 0, 10000, 10),
                                        numeric_form_group('users_count',
                                                           '# Users',
                                                           UPPER_TEXT_WIDTH,
                                                           UPPER_WIDTH,
                                                           600,
                                                           0,
                                                           step=100),
                                        numeric_form_group('regions_count',
                                                           '# Regions',
                                                           UPPER_TEXT_WIDTH,
                                                           UPPER_WIDTH,
                                                           7,
                                                           0,
                                                           step=1),
                                        numeric_form_group('wines_count',
                                                           'Wines count',
                                                           UPPER_TEXT_WIDTH,
                                                           UPPER_WIDTH,
                                                           40,
                                                           0,
                                                           step=10),
                                        numeric_form_group('wineries_count',
                                                           'Wineries count',
                                                           UPPER_TEXT_WIDTH,
                                                           UPPER_WIDTH,
                                                           80,
                                                           0,
                                                           step=10)
                                    ],
                                    style={
                                        'float': 'left',
                                        'margin': '1%',
                                        'width': SUBSECTION_WIDTHS
                                    }),
                                # ---------------------------------------------------- Section 5 ----------------------------------------------------
                                dbc.Form(
                                    [
                                        numeric_form_group(
                                            'oaky', 'Oaky', UPPER_TEXT_WIDTH,
                                            UPPER_WIDTH, 0.2, 0, 1, 0.1),
                                        numeric_form_group(
                                            'spices', 'Spices',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                        numeric_form_group(
                                            'ageing', 'Ageing',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                        numeric_form_group(
                                            'yeasty', 'Yeasty',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                        numeric_form_group(
                                            'dried fruit', 'Dried Fruit',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1)
                                    ],
                                    style={
                                        'float': 'left',
                                        'margin': '1%',
                                        'width': SUBSECTION_WIDTHS
                                    }),
                                # ---------------------------------------------------- Section 6 ----------------------------------------------------
                                dbc.Form(
                                    [
                                        numeric_form_group(
                                            'citrus', 'Citrus',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                        numeric_form_group(
                                            'tree fruit', 'Tree Fruit',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                        numeric_form_group(
                                            'vegetal', 'Vegetal',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1),
                                        numeric_form_group(
                                            'floral', 'Floral',
                                            UPPER_TEXT_WIDTH, UPPER_WIDTH, 0.2,
                                            0, 1, 0.1)
                                    ],
                                    style={
                                        'text-align': 'left',
                                        'margin': '1%',
                                        'width': SUBSECTION_WIDTHS
                                    }),
                            ],
                            style={
                                'display': 'flex',
                                'justify-content': 'center'
                            }),
                    ],
                    style={'text-align': 'center'}),
                html.Div([html.P('')], style={'margin': '5%'}),
            ]),
            html.H2('        '),
            html.H2(id="output_pred",
                    className="predictions_container",
                    style={
                        'text-align': 'center',
                        'margin': '150px',
                        'color': 'darkslategrey'
                    }),
        ],
        style={
            'background-image': 'url("assets/background.jpg")',
            'height': '100vh',
            'background-size': 'cover'
        })

    #Init callback of input fields
    @predictor_app.callback(
        dash.dependencies.Output('output_pred', 'children'),
        [  #dash.dependencies.Input('submit_button', 'n_clicks'),
            dash.dependencies.Input('year', 'value'),
            dash.dependencies.Input('ratings_count', 'value'),
            dash.dependencies.Input('labels_count', 'value'),
            dash.dependencies.Input('reviews_count', 'value'),
            dash.dependencies.Input('is_natural', 'value'),
            dash.dependencies.Input('winery_ratings_count', 'value'),
            dash.dependencies.Input('winery_ratings_average', 'value'),
            dash.dependencies.Input('winery_labels_count', 'value'),
            dash.dependencies.Input('winery_wines_count', 'value'),
            dash.dependencies.Input('users_count', 'value'),
            dash.dependencies.Input('regions_count', 'value'),
            dash.dependencies.Input('wines_count', 'value'),
            dash.dependencies.Input('wineries_count', 'value'),
            dash.dependencies.Input('median_price', 'value'),
            dash.dependencies.Input('bold', 'value'),
            dash.dependencies.Input('tannic', 'value'),
            dash.dependencies.Input('sweet', 'value'),
            dash.dependencies.Input('oaky', 'value'),
            dash.dependencies.Input('black fruit', 'value'),
            dash.dependencies.Input('red fruit', 'value'),
            dash.dependencies.Input('earthy', 'value'),
            dash.dependencies.Input('spices', 'value'),
            dash.dependencies.Input('ageing', 'value'),
            dash.dependencies.Input('yeasty', 'value'),
            dash.dependencies.Input('dried fruit', 'value'),
            dash.dependencies.Input('citrus', 'value'),
            dash.dependencies.Input('tree fruit', 'value'),
            dash.dependencies.Input('vegetal', 'value'),
            dash.dependencies.Input('floral', 'value'),
            dash.dependencies.Input('types', 'value'),
            dash.dependencies.Input('food-checklist-row', 'value'),
        ])
    def calculate_rating(*args):
        #Establish dataframe input
        d = pd.DataFrame()
        for o, i in zip(dict_options, args):
            d[o] = [i]

        for taste in TASTES:
            d[taste] = 1 if taste in list(d['foods'][0]) else 0

        d['types'] = 1 if 'red' in list(d['types'][0]) else 0
        del d['foods']

        #Ordring columns to fit XGB model
        d = d[[
            'year', 'ratings_count', 'labels_count', 'reviews_count',
            'is_natural', 'winery_ratings_count', 'winery_ratings_average',
            'winery_labels_count', 'winery_wines_count', 'users_count',
            'regions_count', 'wines_count', 'wineries_count', 'median_price',
            'bold', 'tannic', 'sweet', 'oaky', 'black fruit', 'red fruit',
            'earthy', 'spices', 'ageing', 'yeasty', 'dried fruit', 'citrus',
            'tree fruit', 'vegetal', 'floral', 'tropical', 'beef', 'lamb',
            'veal', 'poultry', 'pork', 'shellfish', 'vegetarian', 'game',
            'spicy-food', 'types'
        ]]

        print(d)  #Used for decomposition and debugging
        predictions = pipeline.predict(d)[0]
        return 'Predicted rating {}'.format(round(float(predictions), 3))

    return predictor_app.server
示例#30
0
             }), ),
 dbc.Row([
     dbc.FormGroup([
         dbc.RadioItems(options=[
             {
                 'label': 'All Departures',
                 'value': 'Total Rate'
             },
             {
                 'label': 'Layoffs',
                 'value': 'Layoff Rate'
             },
             {
                 'label': 'Resignation',
                 'value': 'Resignation Rate'
             },
             {
                 'label': 'Retirement',
                 'value': 'Retirement Rate'
             },
             {
                 'label': 'Voluntary',
                 'value': 'Voluntary Rate'
             },
         ],
                        value='Total Rate',
                        id='departure-input',
                        inline=True),
     ])
 ],
         style={'margin': '0px 0px 0px 0px'})