I am trying to invert the data I receive from my elastic search query.
The data I have is from a neural network driven car on a track.
I have track locations in X and Z, and the performance.. :
data: {
url: {
%context%: true
// %timefield%: #timestamp
index: performance.capture.August.*
body: {
size: 10000,
_source: ["var_Track_X", "var_Track_Z", "var_Performance"]
}
}
}
I've also tried to use calculate instead of tyle and expr, but no luck,
I tried to add _source. infront of my property name, but no luck either..
kibana would allow me to create scripted fields, but since vega can't
use these I need to make my own.
so I am trying:
transform: [
{type: "formula", expr: "-1 * datum.var_Track_X", as: "var_Playercar_X_Flipped"}
]
and plugging it in the axis like:
encoding: {
x: {
// Draw the time field on the x-axis in temporal mode (i.e. as a time axis)
field: var_Playercar_X_Flipped
type: quantitative
// Hide the axis label for the x-axis
axis: { title: false }
}
anyone know why it's not finding my property?
Related
Here's a minimal example:
import weaviate
CLASS = "Superhero"
PROP = "superhero_name"
client = weaviate.Client("http://localhost:8080")
class_obj = {
"class": CLASS,
"properties": [
{
"name": PROP,
"dataType": ["string"],
"moduleConfig": {
"text2vec-transformers": {
"vectorizePropertyName": False,
}
},
}
],
"moduleConfig": {
"text2vec-transformers": {
"vectorizeClassName": False
}
}
}
client.schema.delete_all()
client.schema.create_class(class_obj)
batman_id = client.data_object.create({PROP: "Batman"}, CLASS)
by_text = (
client.query.get(CLASS, [PROP])
.with_additional(["distance", "id"])
.with_near_text({"concepts": ["Batman"]})
.do()
)
print(by_text)
batman_vector = client.data_object.get(
uuid=batman_id, with_vector=True, class_name=CLASS
)["vector"]
by_vector = (
client.query.get(CLASS, [PROP])
.with_additional(["distance", "id"])
.with_near_vector({"vector": batman_vector})
.do()
)
print(by_vector)
Please note that I specified both "vectorizePropertyName": False and "vectorizeClassName": False
The code above returns:
{'data': {'Get': {'Superhero': [{'_additional': {'distance': 0.08034378, 'id': '05fbd0cb-e79c-4ff2-850d-80c861cd1509'}, 'superhero_name': 'Batman'}]}}}
{'data': {'Get': {'Superhero': [{'_additional': {'distance': 1.1920929e-07, 'id': '05fbd0cb-e79c-4ff2-850d-80c861cd1509'}, 'superhero_name': 'Batman'}]}}}
If I look up the exact vector I get 'distance': 1.1920929e-07, which I guess is actually 0 (for some floating point evil magic), as expected.
But if I use near_text to search for the exact property, I get a distance > 0.
This is leading me to believe that, when using near_text, the embedding is somehow different.
My question is:
Why does this happen?
With two corollaries:
Is 1.1920929e-07 actually 0 or do I need to read something deeper into that?
Is there a way to check the embedding created during the near_text search?
here is some information that may help:
Is 1.1920929e-07 actually 0 or do I need to read something deeper into that?
Yes, this value 1.1920929e-07 should be interpreted as 0. I think there are some unfortunate float32/64 conversions going on that need to be rooted out.
Is there a way to check the embedding created during the near_text search?
The embeddings are either imported or generated during object creation, not at search-time. So performing multiple queries on an unchanged object will utilize the same search vector.
We are looking into both of these issues.
I've been trying to scrape a specific highchart, using console commands, something in the line off:
data = $('div#graphCont2').highcharts().series[0].data; { console.log(data)}
This code works on the following site, I retrieve all data.
test-hichart1
However, when I rework the code for the graph I intend to scrape (chart, Its the uppermost chart, APX-PSE for all X and Y entries), I miss data. It varies somehow (based on the timestamps, it seems to vary by the selected period), but I only get data from around timestamp 1562284800000 and onwards when the period is set to "all" (thus missing 2/3 of all entries).
I use this code:
data = $('div#stockchart_apx').highcharts().series[0].data; { console.log(data) }
My idea was to use a console.table to get the info I need, though I'm unsure if the table is usable past 999 entries anyway.
Does anyone have an idea of why the readout fluctuates and how I can retrieve all the information?
Thanks!
EDIT~ so, after a couple more hours, I managed to get all data by opening the graph in full-window mode. I'm unsure to where the differences originate from, but it worked. I scraped the data with:
data = $('div#stockchart_apx').highcharts().series[0].data;
const getCircularReplacer1 = () => {
const seen = new WeakSet();
return (key, value) => {
if (typeof value === "object" && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};
JSON.stringify(data, getCircularReplacer1());
How can I make my own x-axis with a specific dates array and particular label for each one?
Something like this...
These are every three weeks, but my necesity is a mark every blue group (colored are events), each group has a start and end dates
You can customize the x-axis labels using a format function. E.g.,
options: {
showMinorLabels: false,
timeAxis: { scale: 'day', step: 1 },
format: {
majorLabels: function (date, scale, step) {
// return a custom label or "" depending on the date
}
}
}
I am using Chart.js 2.0 version to draw graphs, i want to define minimum step size in bar graph
var myNewChart = new Chart(grapharea, {
type: 'bar',
data: barData,
options: {
responsive: true,
scales: {
yAxes: [
{
ticks: {
min: 0, // it is for ignoring negative step.
beginAtZero: true,
stepSize: 1 // if i use this it always set it '1', which look very awkward if it have high value e.g. '100'.
}
}
]
}
}
});
this time i am using
stepSize: 1
i am using this step size to ignore the point value e.g. '0.5', it shows when the max graph values id less e.g '2'.
if i use this it always set the step it '1', which look very awkward if it have high value e.g. '100'.
I am looking for such thing:
suggestedMin = 1
Is there any thing to define thie minimum step size which should not be fixed in higher value cases.
If you don't want to show point value (e.g. 0.5) labels you could write a callback function to filter the point value labels instead of using stepSize.
Like this:
ticks: {
min: 0, // it is for ignoring negative step.
beginAtZero: true,
callback: function(value, index, values) {
if (Math.floor(value) === value) {
return value;
}
}
}
Working fiddle here: https://jsfiddle.net/ma7h611L/
Update:
As noted by Atta H. and Lekoaf below, Chart.js added the precision property to ticks. It is available since version 2.7.3. See Lekoaf's answer how to use this.
ticks: {
precision: 0
}
This worked equally well as the callback function above and is much cleaner.
precision, if defined and stepSize is not specified, the step size will be rounded to this many decimal places.
https://www.chartjs.org/docs/latest/axes/cartesian/linear.html
I am trying to style just the decimals to look just like this:
Didn't had success, I guess that I need to make my own filter, tried but didn't had success either, I guess it is because I am using it inside a state.
Here the code I am using for the number:
<h2><sup>$</sup>{{salary | number:0}}<sub>.00</sub></h2>
Inside the .app iam using this scope:
$scope.salary = 9000;
Thing is, number can be whatever the user salary is, it get the number from an input, in other places I have more numbers with decimals too.
Possible solutions:
Extract only the decimals from value and print them inside de
tag.
Use a filter to do this?
Use a directive that will split the amount and generate the proper HTML. For example:
app.directive('salary', function(){
return {
restrict: 'E'
, scope: {
salary: '#'
}
, controller: controller
, controllerAs: 'dvm'
, bindToController: true
, template: '<h2><sup>$</sup>{{ dvm.dollar }}<sub>.{{ dvm.cents }}</sub></h2>'
};
function controller(){
var parts = parseFloat(this.salary).toFixed(2).split(/\./);
this.dollar = parts[0];
this.cents = parts[1];
}
});
The easiest solution would be to split out the number into it's decimal portion and the whole number portion:
var number = 90000.99111;
console.log(number % 1);
Use this in your controller, and split your scope variable into an object:
$scope.salary = {
whole: salary,
decimal: salary % 1
}
Protip: Using an object like this is better than using two scope variables for performance