machine learning – How do you automatically get the longest line in the dendrogram?

Is there a way to automate the longest vertical line instead of guessing it manually? Or to make it clear on the graphics themselves?

P.S.:
I know the elbow method, but I need this information about the dendrogram.

My code

# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Mall_Customers.csv')
X = dataset.iloc(:, (3, 4)).values

# Using the dendrogram to find the optimal number of clusters
import scipy.cluster.hierarchy as sch
dendrogram = sch.dendrogram(sch.linkage(X, method = 'ward'))
plt.title('Dendrogram')
plt.xlabel('Customers')
plt.ylabel('Euclidean distances')
plt.show()

dendrogram
dendrogram

php – assign a key name based on the line during the loop

There is no discernible difference between your table’s column names and your preferred keys. However, if you want to change the keys, just add that to your SELECT clause.

Suppose you want to capitalize each column name. This could look like this:

$stmt = $conn->prepare("SELECT name AS Name,
                               company AS Company,
                               email AS Email,
                               phone AS Phone,
                               address AS Address
                        FROM tickets_info
                        WHERE ticket = ?");
$stmt->execute(($_POST('ticket')));
$ticket = $stmt->fetch(PDO::FETCH_ASSOC) ?: ();

Note that I'm not using a loop. Your snippet overwrites itself in the loop, so I interpret it that way ticket is a PRIMARY / UNIQUE column.


If you want to extract all the columns from your table and use the column names as keys, you don't need to change your original query.

$stmt = $conn->prepare("SELECT * FROM tickets_info WHERE ticket = ?");
$stmt->execute(($_POST('ticket')));
$ticket = $stmt->fetch(PDO::FETCH_ASSOC) ?: ();

Classical analysis and odes – If a real bivariate function can be integrated on the unit square along each line, can it be integrated on the square?

No, consider the function
$$ g (x, y) = cases {0, & if $ (x, y) = (0.0) $ \
xy ^ 2 / (x ^ 2 + y ^ 6) & otherwise} $$

taken from Exercise 4.7 by Baby Rudin (3ed) about this Math.SE contribution. It is continuous along every line and therefore Riemann can be integrated, but there is no limit along the curve $ x = y ^ 3 $, and an unlimited function cannot be integrated according to Riemann.

python – Creates a line chart with a drop down menu

Hello, I have an Excel file that looks like where there are three different servers (A, B, C).

Enter image description here

I am trying to create a dash app with a drop down menu that allows you to select the server you want and display the CPU usage and memory usage graph for each server.

I tried to change the following code from the official Dash website. The data can be found at https://plotly.github.io/datasets/country_indicators.csv

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

import pandas as pd

external_stylesheets = ('https://codepen.io/chriddyp/pen/bWLwgP.css')

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

df = pd.read_csv('https://plotly.github.io/datasets/country_indicators.csv')

available_indicators = df('Indicator Name').unique()

app.layout = html.Div((
    html.Div((

        html.Div((
            dcc.Dropdown(
                id='xaxis-column',
                options=({'label': i, 'value': i} for i in available_indicators),
                value='Fertility rate, total (births per woman)'
            ),
            dcc.RadioItems(
                id='xaxis-type',
                options=({'label': i, 'value': i} for i in ('Linear', 'Log')),
                value='Linear',
                labelStyle={'display': 'inline-block'}
            )
        ),
        style={'width': '48%', 'display': 'inline-block'}),

        html.Div((
            dcc.Dropdown(
                id='yaxis-column',
                options=({'label': i, 'value': i} for i in available_indicators),
                value='Life expectancy at birth, total (years)'
            ),
            dcc.RadioItems(
                id='yaxis-type',
                options=({'label': i, 'value': i} for i in ('Linear', 'Log')),
                value='Linear',
                labelStyle={'display': 'inline-block'}
            )
        ),style={'width': '48%', 'float': 'right', 'display': 'inline-block'})
    )),

    dcc.Graph(id='indicator-graphic'),

    dcc.Slider(
        id='year--slider',
        min=df('Year').min(),
        max=df('Year').max(),
        value=df('Year').max(),
        marks={str(year): str(year) for year in df('Year').unique()},
        step=None
    )
))

@app.callback(
    Output('indicator-graphic', 'figure'),
    (Input('xaxis-column', 'value'),
     Input('yaxis-column', 'value'),
     Input('xaxis-type', 'value'),
     Input('yaxis-type', 'value'),
     Input('year--slider', 'value')))
def update_graph(xaxis_column_name, yaxis_column_name,
                 xaxis_type, yaxis_type,
                 year_value):
    dff = df(df('Year') == year_value)

    return {
        'data': (dict(
            x=dff(dff('Indicator Name') == xaxis_column_name)('Value'),
            y=dff(dff('Indicator Name') == yaxis_column_name)('Value'),
            text=dff(dff('Indicator Name') == yaxis_column_name)('Country Name'),
            mode='markers',
            marker={
                'size': 15,
                'opacity': 0.5,
                'line': {'width': 0.5, 'color': 'white'}
            }
        )),
        'layout': dict(
            xaxis={
                'title': xaxis_column_name,
                'type': 'linear' if xaxis_type == 'Linear' else 'log'
            },
            yaxis={
                'title': yaxis_column_name,
                'type': 'linear' if yaxis_type == 'Linear' else 'log'
            },
            margin={'l': 40, 'b': 40, 't': 10, 'r': 0},
            hovermode='closest'
        )
    }


if __name__ == '__main__':
    app.run_server(debug=True)

The output of this code produces an output similar to mine, except that the second drop-down menu and the slicer are not needed
Enter image description here
I'm struggling to understand how to change the code to match mine. Any help would be appreciated. Thank you very much.

Web Part – Changing the column width of the list with the script editor does not break the line

I have a web part with a list of columns.

To change the width of these columns, I inserted a script editor and used this code:


The problem is that the width of the "Location" column can no longer be reduced.
I want the content of this column to go to the next row so that I can change the width.

See:

width

Plotting – how to manipulate a scatter plot with a regression line across regions[…]

I have the following code:

ClearAll(regions, country, plf, PoU);

regions = {"Africa", "Africa", "Africa", "Africa", "Africa", "Africa",
"Africa", "Africa", "Africa", "Africa", "Africa", "Africa", 
"Africa", "Africa", "Africa", "Africa", "Africa", "Arab", "Arab", 
"Arab", "Arab", "Arab", "Arab", "Arab", "Arab", "Arab", "Arab", 
"Arab", "Arab", "Arab", "Arab", "Arab", "Asia", "Asia", "Asia", 
"Asia", "Asia", "Asia", "Asia", "Asia", "Asia", "Asia", "Asia", 
"Asia", "Asia", "Asia", "Asia", "Asia", "Asia"};

country = {"Mali", "Cameroon", "Benin", "Gambia", "Gabon", "Senegal", 
"Nigeria", "Togo", "Guinea", "Niger", "CôtedIvoire", 
"Burkina Faso", "Sierra Leone", "Mozambique", "Guinea Bissau", 
"Chad", "Uganda", "UAE", "Kuwait", "Morocco", "Algeria", "Tunisia",
"Egypt", "Oman", "Saudi Arabia", "Mauritania", "Lebanon", 
"Jordan", "Djibouti", "Sudan", "Iraq", "Yemen", "Azerbaijan", 
"Kazakhstan", "Turkey", "Malaysia", "Brunei Darus", "Iran", 
"Turkmenistan", "Albania", "Uzbekistan", "Kyrgyzstan", "Guyana", 
"Indonesia", "Suriname", "Maldives", "Bangladesh", "Pakistan", 
"Afghanistan"};

plf = {30, 26, 35, 30, 4, 48, 35, 52, 35, 13, 26, 74, 100, 43, 17, 26,
74, 9, 26, 26, 22, 13, 9, 9, 9, 26, 17, 22, 13, 13, 9, 13, 26, 52,
30, 13, 17, 26, 9, 26, 52, 52, 4, 30, 30, 48, 74, 13, 52};

PoU = {6, 10, 10, 10, 11, 11, 13, 16, 17, 17, 19, 20, 26, 28, 28, 38, 
41, 3, 3, 3, 4, 4, 5, 7, 7, 10, 11, 12, 19, 20, 29, 39, 1, 1, 1, 3,
3, 5, 5, 6, 6, 7, 8, 8, 9, 10, 15, 20, 30};

ListPlot(Transpose@{plf, PoU} -> regions, 
AxesLabel -> {"Policy and LegalnFramework", "PoU"}, 
PlotStyle -> {Thick, PointSize(Large)}, GridLines -> Automatic)

This creates a scatter plot of countries in 3 regions. Each data point is identified with the region name. Here are 3 tasks that I like to do Manipulate(...),

  1. Create a single scatter plot of all data points in which individual data points within a region are the same color (with a region color label on the right side of the diagram).
  2. Draw a regression line with all data points over the scatterplot and display the regression line with a "black dashed line".
  3. For example, draw a regression line for region A over the scatterplot using only that region's data points while keeping all of the data points in the data set on the graph. Assign the region A regression line the same color as region A so that it can be seen that the regression line is linked to the specific observations. The same process should be repeated for other regions. Finally, I should be able to see all 3 regional regression lines and the global regression line (black dashed line) on a single graph for regional comparison purposes.

Thank you for your help.

Web app – How to deal with extra line height spacing if you want the spacing between elements to be consistent

We want to design our website so that all elements are 24px apart (paragraphs, form groups, headings and content etc.) and "related" elements (caption and form fields) are 8px apart. We do that with Flex Gap, which works well (we developed a polyfill for browsers that don't support it).

This works great for non-text elements. But for paragraphs and headings, a line-height > 1 leads to an additional distance between the element in front and the visual beginning of the text. The pictures below are a div. p, and div With row-gap:24px,

Demonstration of line height 1 Demonstration of line height 1.5 Demonstration of line height 2

This increased spacing between elements contradicts the style (my boss is a real fan of consistent spacing and often opens Photoshop to count the pixels). To avoid this problem, we add Psudo elements with negative borders to each text element to compensate for the top and bottom whitespace. (If CSS is supported a leading This is easier because the actual spacing between the lines of text changes as the height of each line increases.)

Enter image description here Enter image description here

When I look at other websites, I often see a jumble of borders and spaces of all different values. Nothing that makes a lot of sense. Are these developers only playing with the numbers until it looks good compared to some standard components they can work with?

Maybe our design / strategy is flawed in some way? Is it a good thing that a larger font size (and also a larger line height) requires a larger space between the elements?

How do you deal with the extra distance caused by …? line-height > 1?

Command Line – Use sed to convert camelCase to under_score

I have a sed script that can convert camelCase to under_score, which works great for this example:

myvar="camelCase"
converted="$(echo $myvar | sed 's/((A-Z))/_L1/g;s/^_//')"

echo converted
// result: camel_case

However, I have the following case:

myvar="camelCASE"
converted="$(echo $myvar | sed 's/((A-Z))/_L1/g;s/^_//')"

echo converted
// result: camel_c_a_s_e

The result I need in this particular case is: camel_case.

The final sed script should work for "camelCase" as well as for "camelCASE" and "CAMELcase".

myvar must never contain special characters or spaces

Paypal Payments Pro – Transfer Shopping Cart Line Items?

I use Paypal Payments Pro in Magento 2.3.1. I have activated PayPal Express Checkout as an alternative checkout option.

First of all, let me make it clear that both payment options work perfectly – the transactions are carried out and the orders are properly received and created in Magento.

With Express Checkout, however, there is an option in the configuration to enable "Submit Shopping Cart Line Items". If "Yes" is set, this works as expected and the article details (product name and article number) are transferred to PayPal and displayed in the PayPal transaction details.

When ordering by credit card (via Payments Pro), the product details (product name and article number) are not shown in the PayPal transaction details.

Is there a setting for that? I can't find anything about it in the configuration settings.

Any help would be appreciated!

csv file only imports the last line if it is imported into drupal 8 webform

I have a CSV file that contains the Drupal 7 Webform entries. I uploaded the CSV file in Drupal 8 web form. The data is imported, but only the last entry is shown in the results of the Drupal 8 web form.

This is the CSV file:
Columns A-D: add IP, UUID, phone number, email. (Dummy entries).

Enter image description here

When importing the mapping from the CSV file, the following options are displayed:
Enter image description here

I select the matching columns at the destination (submission) and then click on Import.
After the import, Drupal displays the following:

Enter image description here

Only the last line from the CSV file is updated in the web form.