This is what is on my x axis on Flot. The below are not typos, it's duplicates dates in proper format, but just plain wrong.
E.g. 1262188800.0 == 12/31/2009
Why is Flot doing this?
1970/01/15 1970/01/15 1970/01/16 1970/01/16 1970/01/16 1970/01/16 1970/01/16
tsPlot(data_ts){
let dataset = [
{
label: "Mean",
data: data_ts["mean_1"],
points: { fillColor: "#FF0000", show: true },
lines: { show: true }
},
{
label: "Var",
data: data_ts["var_1"],
points: { fillColor: "#FF0000", show: true },
lines: { show: true }
}
];
let options = {
grid: { hoverable: true, clickable: true },
xaxis: { mode: "time",
timeformat: "%Y/%m/%d"
}
};
this.plot = $.plot($("#placeholder_ts"),dataset,options);
this.plot.setupGrid();
this.plot.draw();
}
data_ts = { "mean_1": [
[1262188800.0, 500],
[1264867200.0, 500],
[1267286400.0, 500],
[1269964800.0, 492],
[1272556800.0, 484],
[1275235200.0, 484],
[1277827200.0, 477],
[1280505600.0, 477],
[1283184000.0, 470],
[1285776000.0, 475],
[1288454400.0, 471],
[1291046400.0, 480],
[1293724800.0, 480],
[1296403200.0, 489],
[1298822400.0, 489],
[1301500800.0, 489],
[1304092800.0, 490],
[1306771200.0, 500],
[1309363200.0, 500],
[1312041600.0, 500],
[1314720000.0, 500],
[1317312000.0, 490],
[1319990400.0, 484],
[1322582400.0, 492],
[1325260800.0, 492],
[1327939200.0, 488],
[1330444800.0, 498],
[1333123200.0, 498],
[1335715200.0, 499],
[1338393600.0, 493],
[1340985600.0, 485],
[1343664000.0, 493],
[1346342400.0, 493],
[1348934400.0, 493],
[1351612800.0, 498],
[1354204800.0, 498],
[1356883200.0, 506],
[1359561600.0, 510],
[1361980800.0, 510],
[1364659200.0, 510],
[1367251200.0, 514],
[1369929600.0, 516],
[1372521600.0, 516],
[1375200000.0, 513],
[1377878400.0, 513],
[1380470400.0, 517],
[1383148800.0, 517]
],
"var_1": [
[1262188800.0, 300],
[1264867200.0, 300],
[1267286400.0, 300],
[1269964800.0, 292],
[1272556800.0, 284],
[1275235200.0, 284],
[1277827200.0, 277],
[1280505600.0, 277],
[1283184000.0, 270],
[1285776000.0, 275],
[1288454400.0, 271],
[1291046400.0, 280],
[1293724800.0, 280],
[1296403200.0, 289],
[1298822400.0, 289],
[1301500800.0, 289],
[1304092800.0, 290],
[1306771200.0, 300],
[1309363200.0, 300],
[1312041600.0, 300],
[1314720000.0, 300],
[1317312000.0, 290],
[1319990400.0, 284],
[1322582400.0, 292],
[1325260800.0, 292],
[1327939200.0, 288],
[1330444800.0, 298],
[1333123200.0, 298],
[1335715200.0, 299],
[1338393600.0, 293],
[1340985600.0, 285],
[1343664000.0, 293],
[1346342400.0, 293],
[1348934400.0, 293],
[1351612800.0, 298],
[1354204800.0, 298],
[1356883200.0, 306],
[1359561600.0, 310],
[1361980800.0, 310],
[1364659200.0, 310],
[1367251200.0, 314],
[1369929600.0, 316],
[1372521600.0, 316],
[1375200000.0, 313],
[1377878400.0, 313],
[1380470400.0, 317],
[1383148800.0, 317]
]
}
Flot is correct, your timestamps are wrong, see the documentation:
The time series support in Flot is based on Javascript timestamps, i.e. everywhere a time value is expected or handed over, a Javascript timestamp number is used. This is a number, not a Date object. A Javascript timestamp is the number of milliseconds since January 1, 1970 00:00:00 UTC. This is almost the same as Unix timestamps, except it's in milliseconds, so remember to multiply by 1000!
Related
Here is the config file of the paraphrase mpnet transformer model and I would like to understand the meaning with examples of the hidden_size and num_hidden_layers parameters.
{
"_name_or_path": "old_models/paraphrase-mpnet-base-v2/0_Transformer",
"architectures": [
"MPNetModel"
],
"attention_probs_dropout_prob": 0.1,
"bos_token_id": 0,
"eos_token_id": 2,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"hidden_size": 768,
"initializer_range": 0.02,
"intermediate_size": 3072,
"layer_norm_eps": 1e-05,
"max_position_embeddings": 514,
"model_type": "mpnet",
"num_attention_heads": 12,
"num_hidden_layers": 12,
"pad_token_id": 1,
"relative_attention_num_buckets": 32,
"transformers_version": "4.7.0",
"vocab_size": 30527
}
I'm developing a solution that integrates with LUIS using API calls.
I can't find the API to get information from the Dashboard as for example incorrect predictions and unclear predictions. So far I found just this API:
{ENDPOINT}/luis/webapi/v2.0/apps/{APP_ID}/versions/{VERSION}/statsmetadata
but this is not enough, since I would get more detailed information like the one displayed in the dashboard:
The statsmetadata endpoint is the right operation for displaying the figures for the pie chart.
Sample
Here is an example in one of my LUIS apps
Dashboard display
The dashboard gives the following details:
Data origin
StatsMetadata endpoint gives all the details. Here is the call that is made: https://westeurope.api.cognitive.microsoft.com//luis/webApi/v2.0/apps/*MyAppId*/versions/*MyAppVersion*/statsmetadata
JSON Result:
{
"appVersionUtterancesCount": 8505,
"modelsMetadata": [{
"modelId": "IdOfModel1,
"modelName": "modelName1",
"utterancesCount": 85,
"misclassifiedUtterancesCount": 7,
"ambiguousUtterancesCount": 19,
"misclassifiedAmbiguousUtterancesCount": 7
}, {
"modelId": "IdOfModel2",
"modelName": "modelName2",
"utterancesCount": 402,
"misclassifiedUtterancesCount": 11,
"ambiguousUtterancesCount": 32,
"misclassifiedAmbiguousUtterancesCount": 11
}, {
"modelId": "IdOfModel3",
"modelName": "modelName3",
"utterancesCount": 293,
"misclassifiedUtterancesCount": 9,
"ambiguousUtterancesCount": 42,
"misclassifiedAmbiguousUtterancesCount": 9
}, {
"modelId": "IdOfModel4",
"modelName": "modelName4",
"utterancesCount": 58,
"misclassifiedUtterancesCount": 3,
"ambiguousUtterancesCount": 5,
"misclassifiedAmbiguousUtterancesCount": 3
}, {
"modelId": "IdOfModel5",
"modelName": "modelName5",
"utterancesCount": 943,
"misclassifiedUtterancesCount": 7,
"ambiguousUtterancesCount": 103,
"misclassifiedAmbiguousUtterancesCount": 7
}, {
"modelId": "IdOfModel6",
"modelName": "modelName6",
"utterancesCount": 266,
"misclassifiedUtterancesCount": 9,
"ambiguousUtterancesCount": 70,
"misclassifiedAmbiguousUtterancesCount": 9
}, {
"modelId": "IdOfModel7",
"modelName": "modelName7",
"utterancesCount": 2441,
"misclassifiedUtterancesCount": 68,
"ambiguousUtterancesCount": 180,
"misclassifiedAmbiguousUtterancesCount": 67
}, {
"modelId": "IdOfModel8",
"modelName": "modelName8",
"utterancesCount": 704,
"misclassifiedUtterancesCount": 40,
"ambiguousUtterancesCount": 154,
"misclassifiedAmbiguousUtterancesCount": 40
}, {
"modelId": "IdOfModel9",
"modelName": "modelName9",
"utterancesCount": 288,
"misclassifiedUtterancesCount": 9,
"ambiguousUtterancesCount": 65,
"misclassifiedAmbiguousUtterancesCount": 9
}, {
"modelId": "IdOfModel10",
"modelName": "modelName10",
"utterancesCount": 18,
"misclassifiedUtterancesCount": 1,
"ambiguousUtterancesCount": 1,
"misclassifiedAmbiguousUtterancesCount": 1
}, {
"modelId": "IdOfModel11",
"modelName": "modelName11",
"utterancesCount": 444,
"misclassifiedUtterancesCount": 12,
"ambiguousUtterancesCount": 50,
"misclassifiedAmbiguousUtterancesCount": 12
}, {
"modelId": "IdOfModel12",
"modelName": "modelName12",
"utterancesCount": 10,
"misclassifiedUtterancesCount": 8,
"ambiguousUtterancesCount": 8,
"misclassifiedAmbiguousUtterancesCount": 8
}, {
"modelId": "IdOfModel13",
"modelName": "modelName13",
"utterancesCount": 58,
"misclassifiedUtterancesCount": 9,
"ambiguousUtterancesCount": 21,
"misclassifiedAmbiguousUtterancesCount": 9
}, {
"modelId": "IdOfModel14",
"modelName": "None",
"utterancesCount": 2495,
"misclassifiedUtterancesCount": 194,
"ambiguousUtterancesCount": 428,
"misclassifiedAmbiguousUtterancesCount": 178
}],
"intentsCount": 14,
"entitiesCount": 7,
"phraseListsCount": 7,
"patternsCount": 0,
"trainingTime": "00:00:53.2732860",
"lastTrainDate": "2019-10-22T13:25:03Z",
"misclassifiedUtterancesCount": 387,
"ambiguousUtterancesCount": 1178,
"misclassifiedAmbiguousUtterancesCount": 370
}
Calculation on API data - Pie Chart
Incorrect predictions
Here it is the number of misclassified utterances divided by the total number of utterances
Formula: misclassifiedUtterancesCount / appVersionUtterancesCount
Check: 387 / 8505 = 0.04550 = 4.6%
Unclear predictions
Here it is the number of ambiguous (but not misclassified ambiguous as they are already counted in incorrect predictions) utterances divided by the total number of utterances
Formula: (ambiguousUtterancesCount - misclassifiedAmbiguousUtterancesCount) / appVersionUtterancesCount
Check: (1178 - 370) / 8505 = 808 / 8505 = 0.09500 = 9.5%
Correct predictions
It is... what remains! So:
Formula: (appVersionUtterancesCount - misclassifiedUtterancesCount - (ambiguousUtterancesCount - misclassifiedAmbiguousUtterancesCount)) / appVersionUtterancesCount
Check: (8505 - 387 - (1178 - 370)) / 8505 = (8505 - 387 - 808) / 8505 = 7310 / 8505 = 0.8594 = 85.9%
Calculation on API data - Right panel details
Data Imbalance
It is the models that have the biggest number of utterancesCount, but I don't know if there is a threshold ratio used to keep only the top N models
Incorrect predictions
By model, check the following ratio: misclassifiedUtterancesCount / utterancesCount and keep the ones having the highest ratio.
Unclear predictions
By model, check the following ratio: (ambiguousUtterancesCount - misclassifiedAmbiguousUtterancesCount) / utterancesCount and keep the ones having the highest ratio.
Details
You can directly check in your navigator developer tools that LUIS portal is calling this endpoint before displaying the dashboard.
function createData(collegeName, registrarName, phoneNumber, emailAddress, action) {
return {collegeName , registrarName, phoneNumber, emailAddress, action };
}
var rows = [
createData("data", 305, 3.7, 67, 4.3),
createData('Donut', 452, 25.0, 51, 4.9),
createData('Eclair', 262, 16.0, 24, 6.0),
createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
createData('Gingerbread', 356, 16.0, 49, 3.9),
createData('Honeycomb', 408, 3.2, 87, 6.5),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
createData('Jelly Bean', 375, 0.0, 94, 0.0),
createData('KitKat', 518, 26.0, 65, 7.0),
createData('Lollipop', 392, 0.2, 98, 0.0),
createData('Marshmallow', 318, 0, 81, 2.0),
createData('Nougat', 360, 19.0, 9, 37.0),
createData('Oreo', 437, 18.0, 63, 4.0),
];
this is static data (you can check using full code for table ) but i want to feed rows by dynamic data :this is the response of database
You shoul use a Map to generate an input for your table rows property:
let list = (data && data.profiles != null) ? data.profiles.map((value, index, array) => {
return {
id: value.id,
key: value.id,
name: value.name,
})
Above code is an example, change variables to your owns.
Working on a Node App with Express as the web framework and Mongo as the backend. Currently, I have a Mongoose data schema with players and associated statistics. Here's an anonymized example of the structure:
name: 'Player Name',
image: 'image-location',
position: 'Guard',
description: 'Player Detail',
__v: 6,
weight: 200,
dob: 1993-08-03T05:00:00.000Z,
hometown: 'town-name',
country: 'country-name',
height_feet: 6,
height_inches: 4,
season: [
{
year: '2012-2013',
grade: 'Freshman',
gp: 18,
gs: 0,
mpg: 6.9,
fg: 0.348,
tp: 0.278,
ft: 1,
rpg: 0.8,
apg: 1,
spg: 0.3,
bpg: 0,
ppg: 1.4
},
{
year: '2013-2014',
grade: 'Sophomore',
gp: 36,
gs: 7,
mpg: 20.3,
fg: 0.432,
tp: 0.4,
ft: 0.643,
rpg: 1.6,
apg: 1.1,
spg: 0.2,
bpg: 0.1,
ppg: 7.1
},
{
year: '2014-2015',
grade: 'Junior',
gp: 34,
gs: 33,
mpg: 27.5,
fg: 0.449,
tp: 0.391,
ft: 0.755,
rpg: 2.9,
apg: 2,
spg: 0.8,
bpg: 0.1,
ppg: 10.1
},
{
year: '2015-2016',
grade: 'R. Senior',
gp: 8,
gs: 8,
mpg: 31.6,
fg: 0.425,
tp: 0.291,
ft: 0.6,
rpg: 2.9,
apg: 1.9,
spg: 0.6,
bpg: 0.3,
ppg: 12
},
{
year: '2016-2017',
grade: 'Senior',
gp: 35,
gs: 35,
mpg: 33.3,
fg: 0.473,
tp: 0.384,
ft: 0.795,
rpg: 4.6,
apg: 2.7,
spg: 1.2,
bpg: 0,
ppg: 15.1
}
]
}
I'm still fairly new to Mongo and Node as a whole, so pardon the elementary question. How would I be able to calculate the average of a particular statistic for the total number of seasons (e.g. 4 year average of points per game)?
The goal here is to calculate the value and have it available and passed on the GET route for the player page. Here's the route I have for the player page:
router.get("/:id", function(req, res){
Player.findById(req.params.id).populate("comments").exec(function(err, foundPlayer){
if(err){
console.log(err);
} else {
console.log(foundPlayer)
res.render("players/show", {player: foundPlayer});
}
});
});
What can I do to both calculate this value and have it available for use on the player page?
You have to iterate over seasons array and find the average. For example:
const { season } = <.........your MongoDB response>
let average = 0;
if(season.length){
let total = 0
season.map(({ gp }) => (total += gp))
average = total / season.length
}
The variable average will give you the answer. I've shown an example to calculate average of gp
we can use aggregate pipeline to calculate the average directly within the query
db.collection.aggregate([
{
$match: {
_id: "playerId1" // this needs to be of type ObjectId, it should be something like mongoose.Types.ObjectId(req.params.id) in your case
}
},
{
$unwind: "$season" // unwind the season array to get a stream of documents, and to be able to calculate the average of ppg
},
{
$group: { // then group them again
_id: "$_id",
averagePointsPerGame: {
$avg: "$season.ppg"
},
season: {
$push: "$season"
}
}
}
])
you can test it here Mongo Playground
hope it helps
I'm working on a vue.js application which uses Vuetify 1.5.2. I'm having trouble setting the items-per-page attribute of the v-data-iterator:
<v-data-iterator
:items="facilities"
:items-per-page.sync="facilitiesPerPage"
content-tag="v-layout"
rows-per-page-text="Facilities per page"
row
wrap
>
<v-flex slot="item" slot-scope="props" xs12 sm6 md4 lg3 x12>
<facility :facility="props.item"></facility>
</v-flex>
</v-data-iterator>
data: () => ({
facilitiesPerPage: 4,
facilities: [],
...
})
According to this, I would think the data-iterator would display 4 items per page. But that's not what's happening. It seems to be defaulting to the number of items per page set in the footer by default. Since we don't set the rows-per-page-items explicitely, it default to [5, 10, 25, 'All'], and 5 is selected by default:
This seems to be overriding the items-per-page value.
What we want to do is make the items-per-page value dynamic, changing based on the screen width. We lay our items out horizontally, wrapping to multiple rows if necessary, so we want as many items per row as can fit within the screen width. Then facilitiesPerPage is to be calculated based on this number multiplied by the number of rows.
We want something like this:
https://www.codeply.com/p/bFrSEsnq4L
But this only works in Vuetify 2.0, and we have to deal with Vuetify 1.5.2. So we're trying to customize our own design.
What's blocking us now is that the default number of items per page seems to be overriding what we set for items-per-page. Is there any way to prevent this in Vuetify 1.5.2?
Thanks.
It is possible to change the items-per page dynamically in Vuetify 1.5.2 version.
Here is the working codepen:
https://codepen.io/chansv/pen/oNjqNoG?editors=1010
You have to use the following props to achieve this:
In the version 1.5.2 it is not items-per-page instead it should be :rows-per-page-items
To set the rows per page text, you can use this props :rows-per-page-text="'Facilities per page'"
Dynamically select the value for rows-per-page, you can use this props :pagination.sync="paginationSync" and set the value in object as {rowsPerPage: 30} // 10, 20, or any
<div id="app">
<v-app id="inspire">
<v-data-table
:headers="headers"
:items="desserts"
class="elevation-1"
:rows-per-page-items="rowsPerPage"
:rows-per-page-text="'Facilities per page'"
:pagination.sync="paginationSync"
>
<template v-slot:items="props">
<td>{{ props.item.name }}</td>
<td class="text-xs-right">{{ props.item.calories }}</td>
<td class="text-xs-right">{{ props.item.fat }}</td>
<td class="text-xs-right">{{ props.item.carbs }}</td>
<td class="text-xs-right">{{ props.item.protein }}</td>
<td class="text-xs-right">{{ props.item.iron }}</td>
</template>
</v-data-table>
</v-app>
</div>
new Vue({
el: '#app',
data () {
return {
paginationSync: {rowsPerPage: 30},
rowsPerPage: [10, 20, 30, 40, 50],
headers: [
{
text: 'Dessert (100g serving)',
align: 'left',
sortable: false,
value: 'name'
},
{ text: 'Calories', value: 'calories' },
{ text: 'Fat (g)', value: 'fat' },
{ text: 'Carbs (g)', value: 'carbs' },
{ text: 'Protein (g)', value: 'protein' },
{ text: 'Iron (%)', value: 'iron' }
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
iron: '1%'
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
iron: '1%'
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
iron: '7%'
},
{
name: 'Cupcake',
calories: 305,
fat: 3.7,
carbs: 67,
protein: 4.3,
iron: '8%'
},
{
name: 'Gingerbread',
calories: 356,
fat: 16.0,
carbs: 49,
protein: 3.9,
iron: '16%'
},
{
name: 'Jelly bean',
calories: 375,
fat: 0.0,
carbs: 94,
protein: 0.0,
iron: '0%'
},
{
name: 'Lollipop',
calories: 392,
fat: 0.2,
carbs: 98,
protein: 0,
iron: '2%'
},
{
name: 'Honeycomb',
calories: 408,
fat: 3.2,
carbs: 87,
protein: 6.5,
iron: '45%'
},
{
name: 'Donut',
calories: 452,
fat: 25.0,
carbs: 51,
protein: 4.9,
iron: '22%'
},
{
name: 'KitKat',
calories: 518,
fat: 26.0,
carbs: 65,
protein: 7,
iron: '6%'
}
]
}
}
})