Vega Edge bundling (directed) - vary thickness of each edge to show strength of connection - data-visualization

I am looking to use an edge bundle visualisation as per:
https://vega.github.io/editor/#/examples/vega/edge-bundling
However, in this example, all the directed edges are of uniform thickness.
Instead, I need to generate edges of varying thickness to illustrate the strength of the relationship between nodes.
I envisaged passing that thickness into the model such that the edges defined by the JSON at
https://github.com/vega/vega-datasets/blob/master/data/flare-dependencies.json
would be adjusted so an edge currently defined as:
{
"source": 190,
"target": 4
},
would instead be defined as say:
{
"source": 190,
"target": 4,
"edgeWeight": 23
},
Is this possible? I did try experimenting by passing two simplified JSON datasets using value but couldn't figure out how to feed in that "edgeWeight" variable to the line definition in 'marks'.
Do you know how I might do that?
Regards,
Simon

I was provided an answer to this as follows:
First add a formula to append the size value from the flare.json dataset as a field 'strokeWidth' by writing this at line 90 in the example:
{
"type": "formula",
"expr": datum.size/10000",
"as": "strokeWidth"
},
Next, in the marks, set the strokeWidth value for each edge in the edgebundle to the associated 'strokeWidth' in the column now created by writing this at what becomes line 176 after the above change:
"strokeWidth": {"field": "strokeWidth"}
After this, the diagram should render with edges of a thickness defined by that 'size' variable.
Note that in this example, I had to scale the 'size' value in the original dataset by 10,000 to set the lines at a reasonable thickness.
In practice, I would scale the data prior to presenting it to Vega.

Related

Are the values for "rotation" and "translation" the values for extrinsic camera parameters in .gltf files?

I have exported a 3D scene in Blender as .gltf and I am reading the data in my program.
For the camera I have the following values in the .gltf File:
{
"camera" : 0,
"name" : "Camera",
"rotation" : [
0.331510511487034,
-0.018635762442412376,
0.0052512469701468945,
0.9450923238951721
],
"translation" : [
0.25607955169677734,
1.6810789010681152,
0.129119189865864
]
},
I think the values here for "rotation" and "translation" are the extrinsic camera parameters. The translation vector (x,y,z) makes sense to me, but I don't understand why there are only 4 floats for the camera rotation. In this case, there should be more values for the matrix, or am I missing something here? Thanks in advance!
When rotation is specified by itself, it's a quaternion, not a matrix. That's why you're seeing only 4 values there.
For reference, see: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#transformations
The glTF camera object looks along -Z in local (node transformed) space, with +Y up.
See: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#cameras

BigQuery Point Geometry display in Superset

I have a table with latitude and longitude and I want to be able to display it on the Deck.gl chart that accepts geojson
I have a view in BigQuery that returns a geojson object (in a single column) that looks like this -
{ "type": "Point", "coordinates": [122.80112, 10.004489] }
That is valid geojson. I created it in BigQuery by using this function.
ST_AsGeoJSON(ST_GeogPoint(longitude, latitude)) as geojson
Any ideas on how to make my data display in the Deck.gl 3D Hexagon or Deck.gl Grid charts?

Re-using created dataset for different task (object detection - image classification)

I have created a large dataset in Amazon sagemaker and labeled it using bounding boxes. I used this dataset for object detection and everything worked fine.
Later, I wanted to use this dataset for simple image classification. But every time, I try to run it, I get an error: Customer Error: Label was not a float.
I think that the problem are probably bounding boxes as the image classification algorithm does not expect them, but is there any way, how to change it?? My goal is to use the parts of image that are in bounding boxes for image classification training. Is there any way, how to set parameters, so that the algorithm could accept as input the information in bounding boxes?
Bellow is a snippet from a log file that was generated, when I tried to run image classification on dataset with bounding boxes.
[14:42:27] /opt/brazil-pkg-cache/packages/AIApplicationsPipeIterators/AIApplicationsPipeIterators-1.0.1145.0/AL2012/generic-flavor/src/data_iter/src/ease_image_iter.cpp:452: JSON Logic Error while parsing
{
"annotations": [
{
"class_id": 0,
"height": 194,
"left": 34,
"top": 16,
"width": 150
}
],
"image_size": [
{
"depth": 3,
"height": 256,
"width": 185
}
]
}
: Value is not convertible to float.
PS: The dataset is an augmented manifest file.
I would be very grateful for any help.
Thank you for reaching out to us. SageMaker algorithms for Training expect a specific format for the labels for each algorithms. For example, https://docs.aws.amazon.com/sagemaker/latest/dg/image-classification.html. Hence, you cannot feed the bounding boxes to Image classification Training algorithm.

How to define a custom split in tensorflow datasets?

I am walking through the docs of the new Tensorflow datasets library, trying to add a new dataset. I want to specify custom dataset splits for my own dataset and in the docs they say:
If the dataset comes with pre-defined splits (for example, MNIST has
train and test splits), keep those splits in the DatasetBuilder. If
this is your own data and you can decide your own splits, we suggest
using a split of (TRAIN:80%, VALIDATION: 10%, TEST: 10%). Users can
always get subsplits through tfds.Split.subsplit.
I am using GeneratorBasedBuilder, which is a subclass of tfds.core.DatasetBuilder that simplifies defining a dataset. Thus, I have to implement the method _split_generators, which is show below:
def _split_generators(self, dl_manager):
# Download source data
extracted_path = dl_manager.download_and_extract(...)
# Specify the splits
return [
tfds.core.SplitGenerator(
name="train",
num_shards=10,
gen_kwargs={
"images_dir_path": os.path.join(extracted_path, "train"),
"labels": os.path.join(extracted_path, "train_labels.csv"),
},
),
tfds.core.SplitGenerator(
name="test",
num_shards=1,
gen_kwargs={
"images_dir_path": os.path.join(extracted_path, "test"),
"labels": os.path.join(extracted_path, "test_labels.csv"),
},
),
]
Is there a way to specify custom splits this way or I should inherit from the lower level DatasetBuilder class?

How to deal with overlapping X-axis labels in DOJO chart?

I have recently starting using the dojo library, and I am currently having some formatting problems with my x-axis labels. A few of the labels have longer names, and thus there is some overlap going on. Is there some way to have the labels automatically space themselves, or for longer labels to appear below the others so that they do not overlap the other labels?
I have tried using the rotation property, bu I was not satisfied with the result. While it did prevent overlapping, it also significantly reduced the area taken up by the actual chart.
You can also rotate the labels but using the "rotation" attribute.
e.g.
YourChartDefinition.addAxis("x",
{vertical : false,
minorTicks : true,
includeZero: false,
font: "normal normal bold 8pt Arial",
rotation: -30,
labels: labels_for_axis
}
);
The label shortening rules can be specified by parameters as follows:
http://dojotoolkit.org/reference-guide/dojox/charting.html#axis-label-shortening