IBM Watson NLU gives a "training validation failed. Too few samples for label class. Minimum of 5 required" Error - classification

I am trying to train my model in IBM Watson NLU. I have to classify emails into 2 labels. The instance has been created and I am passing the correct Model ID too.
model_id = model['model_id']
model_to_view = nlu.get_classifications_model(model_id=model_id).get_result()
print("Information about the created NLU Classifications model:")
print(json.dumps(model_to_view, indent=2))
The training status shows as 'started' initially, but after that it shows the below mentioned error:
Information about the created NLU Classifications model:
{
"name": "MyClassificationsModel1",
"user_metadata": null,
"language": "en",
"description": null,
"model_version": "1.0.1",
"version": "1.0.1",
"workspace_id": null,
"version_description": null,
"status": "error",
"notices": [
{
"message": "Training data validation failed: Too few examples for label class. Minimum of 5 required"
}
],
"model_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"features": [
"classifications"
],
"created": "2022-04-28T12:03:23Z",
"last_trained": "2022-04-28T12:03:23Z",
"last_deployed": null
}

Your training data needs to provide 5 samples for each classification label. See
https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements
for classifications training data requirements. If you have 2 labels, there should be a minimum of 10 (5 each) samples.

Related

Create Entities and training phrases for values in functions for google action

I have created a trivia game using the SDK, it takes user input and then compares it to a value in my DB to see if its correct.
At the moment, I am just passing a raw input variable through my conversation, this means that it regularly fails when it mishears the user since the exact string which was picked up is rarely == to the value in the DB.
Specifically I would like it to only pick up numbers, and for example realise that it must extract '10' , from a speech input of 'my answer is 10'.
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "welcome"
},
"intent": {
"name": "actions.intent.MAIN"
}
},
{
"description": "response",
"name": "Raw input",
"fulfillment": {
"conversationName": "rawInput"
},
"intent": {
"name": "raw.input",
"parameters": [{
"name": "number",
"type": "org.schema.type.Number"
}],
"trigger": {
"queryPatterns":[
"$org.schema.type.Number:number is the answer",
"$org.schema.type.Number:number",
"My answer is $org.schema.type.Number:number"
]
}
}
}
],
"conversations": {
"welcome": {
"name": "welcome",
"url": "https://us-central1-triviagame",
"fulfillmentApiVersion": 2
},
"rawInput": {
"name": "rawInput",
"url": "https://us-central1-triviagame",
"fulfillmentApiVersion": 2
}
}
}
app.intent('actions.intent.MAIN', (conv) => {
conv.data.answers = answersArr;
conv.data.questions = questionsArr;
conv.data.counter = answersArr.length;
var thisQuestion = conv.data.questions;
conv.ask((conv.data.answers)[0]));
});
app.intent('raw.input', (conv, input) => {
if(input == ((conv.data.answers)[0])){
conv.ask(nextQuestion());
}
app.intent('actions.intent.TEXT', (conv,input) => {
//verifying if input and db value are equal
// at the moment input is equal to 'my number is 10' (for example) instead of '10'
//therefore the string verification never works
conv.ask(nextQuestion());
});
In a previous project i used the dialogflow UI and I used this #system.entities number parameter along with creating some training phrases so it understands different speech patterns.
This input parameter I am passing through my conv , is only a raw string where I'd like it to be filtered using some sort of entity schema.
How do I create the same effect of training phrases/entities using the JSON file?
You can't do this using just the Action SDK. You need a Natural Language Processing system (such as Dialogflow) to handle this as well. The Action SDK, by itself, will do speech-to-text, and will use the actions.json configuration to help shape how to interpret the text. But it will only return the entire text from the user - it will not try to determine how it might match an Intent, nor what parameters may exist in it.
To do that, you need an NLP/NLU system. You don't need to use Dialogflow, but you will need something that does the parsing. Trying to do it with simple pattern matching or regular expressions will lead to nightmares - find a good system to do it.
If you want to stick to things you can edit yourself, Dialogflow does allow you to download its configuration files (they're just JSON), edit them, and update or replace the configuration through the UI or an API.

Multiple response in action on google dialogflow

How can i get multiple response on action on google console using dialogflow ?
i simulated on Action on google console but only two responses are showing on it
where as third response are not showing
here is my json response
{
"source": "webhook",
"data": {
"google": {
"is_ssml": true,
"permissions_request": null,
"expect_user_response": true
}
},
"messages": [
{
"type": 0,
"speech": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1"
},
{
"textToSpeech": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1",
"platform": "google",
"displayText": "peter Got around 28 marks in maths. which is ranked 1 among 3 candidate in class 1",
"type": "simple_response"
},
{
"textToSpeech": "Working",
"platform": "google",
"displayText": "Working",
"type": "simple_response"
},
{
"textToSpeech": "Working 2",
"platform": "google",
"displayText": "Working 2",
"type": "simple_response"
}
]
}
Here is my console output
any help regarding this is much appreciated
Thank you
Regards Saif
Only two simple responses will be accepted as a response. If you want more content you will need to consolidate your text into one of the two responses.
As you can see on the AoG Responses docs, it is specified as a requirement :
At most 2 chat bubbles per turn
So your third bubble won't display, as intended by Google.
As suggested in the previous answer from Nick, you need to consolidate your text and wrap everything in your 2 bubbles. In a simple response, you can line break by adding a \n where needed.
In a Basic Card however, you can access a limited subset of markdown, as stated in the docs link I provided, like that :
New line with a double space
**bold**
*italics*
Rich responses have the following requirements and optional properties that you can configure:
Supported on surfaces with the actions.capability.SCREEN_OUTPUT
capability.
The first item in a rich response must be a simple response.
At most two simple responses.
At most one basic card or StructuredResponse.
At most 8 suggestion chips. (you can add more than 8 also but you will get a warning not an error.)
Suggestion chips are not allowed in a FinalResponse
Linking out to the web from smart displays is currently not
supported.

IBM Watson Discovery API query

I am trying to use watson discovery api and makes request like this:
https://gateway.watsonplatform.net/discovery/api/v1
/environments/6da44f3d-678f-476a-ae8b-cf69327fcf93
/collections/f9c98c9e-be05-4a00-bc93-7159f5441251/query
?version=2016-11-07
&query=text:Ukraine,taxonomy:(label:technology,score>0.8)
&count=10
&offset=
&aggregation=
&filter=
&return=
First item in response has taxonomy like this:
"taxonomy": [
{
"score": "0.976715",
"label": "/law, govt and politics/armed forces/army"
},
{
"confident": "no",
"score": "0.499065",
"label": "/technology and computing/computer certification"
},
{
"confident": "no",
"score": "0.496026",
"label": "/law, govt and politics/legal issues/human rights"
}
]`
Taxonomy's item labeled "technology" has score 0.499065 but I need items which has label with word "technology" AND score >0.8 (not OR).
How do I change my request to get what I want? Thanks.
Lets step back first. The goal of this query is to find documets where the text references 'Ukraine' and then filter all results so that they taxonomy technology is there and has a score over 0.8
I can't test this myself without access to your environment but it should be
https://gateway.watsonplatform.net/discovery/api/v1
/environments/6da44f3d-678f-476a-ae8b-cf69327fcf93
/collections/f9c98c9e-be05-4a00-bc93-7159f5441251/query
?version=2016-11-07
&query=text:Ukraine
&count=10
&offset=
&aggregation=
&filter=taxonomy:(label:technology,score>0.8)
&return=

Can I access ReimburseCharge objects in the IPP QBO v3 API?

I queried an Invoice that contains a billable expense charge. The response includes (and I'm showing just the relevant portions of it):
....
"Line": [
{
"LineNum": 1,
"DescriptionLineDetail": {
"ServiceDate": "2015-11-15"
},
"Id": "3",
"DetailType": "DescriptionOnly",
"Description": "Test Billable Transaction 1"
},
{
"LineNum": 2,
"DescriptionLineDetail": {
"ServiceDate": "2015-11-15"
},
"Id": "4",
"DetailType": "DescriptionOnly",
"Description": "Test Billable Expense Transaction 3"
},
{
"DetailType": "SubTotalLineDetail",
"Amount": 8.01,
"SubTotalLineDetail": {}
}
],
"LinkedTxn": [
{
"TxnId": "1938",
"TxnType": "ReimburseCharge"
},
{
"TxnId": "1932",
"TxnType": "ReimburseCharge"
}
],
...
I tried querying the API for ReimburseCharge and got only errors back. Is this business object on the roadmap?
On a related note, I observe that a billable line (at least in Purchase objects) can have its BillableStatus attribute set to "HasBeenBilled" with an Update call. It cannot be set back to "Billable" without first setting it to "NotBillable", but this does seem to work more than once so that it's not a one-way effect. If the line has actually been billed though, I get a validation fault when I try to change the BillableStatus from "HasBeenBilled" to "NotBillable", which I suppose makes sense.
Here's what's decidedly problematic though: I cannot use the API to either link a billable expense to an invoice or figure out where an already-linked expense is invoiced. Also, I cannot see the amount of the individual lines contained in these "DescriptionOnly" lines, so all I get is the total. Does Intuit have plans to change this and, if so, when?
This decision for supporting Reimb Charge is still pending.
Regarding DescriptionOnly- This was meant to support only total and sub totals.
So, if you have to use lines then you should use SalesItemLineDetail

Difficulty using `populate` with `groupBy` and `sum` with Waterline query in Sails.js

I have run into a strange problem with the groupBy and sum methods when used with populate. I have a set of associated models: User, Source (books, etc), Recommendation, and Discipline (i.e. academic discipline).
I attempted the following waterline query:
Recommendation.find({
where: {discipline: '5559ea07dfa9bd0499f9f799'},
groupBy: ['source'], sum: ['rating']
}).exec(console.log);
This worked well, returning:
[
{
"source": "5571e72ab50f0c3c49fe19f6",
"rating": 4
},
{
"source": "5571b88c51861950360fac1c",
"rating": 12
}
]
I then tried it with populate on the source because I wanted to have the full source data linked to the each recommendation. So I tried:
Recommendation.find({
where: {discipline: '5559ea07dfa9bd0499f9f799'},
groupBy: ['source'], sum: ['rating']
}).populate('source').exec(console.log);
This yielded something strange:
[
{
"source": {
"type": "book",
"identifiers": [
{
"type": "ISBN_10",
"identifier": "1400823226"
},
{
"type": "ISBN_13",
"identifier": "9781400823222"
}
],
"title": "Patterns for America",
"subtitle": "Modernism and the Concept of Culture",
"publisher": "Princeton University Press",
"year": 1999,
"language": "en",
"categories": [
"Literary Criticism"
],
"abstract": "In recent decades, historians and social theorists have given much thought to the concept of \"culture,\" its origins in Western thought, and its usefulness for social analysis. In this book, Susan Hegeman focuses on the term's history in the United States in the first half of the twentieth century. She shows how, during this period, the term \"culture\" changed from being a technical term associated primarily with anthropology into a term of popular usage. She shows the connections between this movement of \"culture\" into the mainstream and the emergence of a distinctive \"American culture,\" with its own patterns, values, and beliefs. Hegeman points to the significant similarities between the conceptions of culture produced by anthropologists Franz Boas, Edward Sapir, Ruth Benedict, and Margaret Mead, and a diversity of other intellectuals, including Randolph Bourne, Van Wyck Brooks, Waldo Frank, and Dwight Macdonald. Hegeman reveals how relativist anthropological ideas of human culture--which stressed the distance between modern centers and \"primitive\" peripheries--came into alliance with the evaluating judgments of artists and critics. This anthropological conception provided a spatial awareness that helped develop the notion of a specifically American \"culture.\" She also shows the connections between this new view of \"culture\" and the artistic work of the period by, among others, Sherwood Anderson, Jean Toomer, Thomas Hart Benton, Nathanael West, and James Agee and depicts in a new way the richness and complexity of the modernist milieu in the United States.",
"imageLinks": {
"smallThumbnail": "http://bks3.books.google.de/books/content?id=OwYWU2H3me4C&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api",
"thumbnail": "http://bks3.books.google.de/books/content?id=OwYWU2H3me4C&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api"
},
"createdAt": "2015-06-05T14:56:12.714Z",
"updatedAt": "2015-06-05T14:56:12.724Z",
"id": "5571b88c51861950360fac1c"
},
"rating": 4
},
{
"source": {
"_bsontype": "ObjectID",
"id": "Uq¸Q\u0019P6\u000f¬\u001c"
},
"rating": 12
}
]
As you can see rather than replacing the source id with the full source properties, it added the source as an object in the returned array, and then added another object with a new source id reference, and the summed rating amount. Strangely, it also attached just one of the rating values to the source object it appended to the results.
Is this what should be happening. I can't follow the logic and it feels a bit buggy. In any case, what I would like is to have the source within each returned row, alongside the summed total. Can anyone explain what's going on here, and if I made an error perhaps?