How to do warm start and use vowpal wabbit for contextual bandits - vowpalwabbit

I wanted to implement contextual bandits in vowpal wabbit. I wanted to use it for an email campaign (new) which have 5 different variants of emails.
I have historical data of the past email campaigns (1 AB test with 2 email variants and 1 email variant with 100% rollout campaign).
The email variants in the historical data are different to the ones in the new campaign that I wanted to use contextual bandits on.
Also, I am using some 2 to 3 basic features as context (like 'user tenure' etc.).
Also, there are no email dependent features that can be used.
Given the above set up is there a way (new campaign email variants different to the variants in historical data) to warm start the vowpal wabbit model with the historical data or will warm starting with the historical data in this case even help ?
Can I use cb_explore_adf for this usecase, even though I don't have any action dependent features.
What would be best option of cb type and cb explore (vowapl wabbit algorithms for model and exploration) to use for this case

Hi #tjt there are some contextual bandit related tutorials on the vowpal wabbit website here

Related

How to identify multiple entities in RASA

I want to extract multiple entities from a user input.
Example- "Service httpd is not responding because of high CPU usage and DNS Error"
So here I want to identify below:
Httpd
High CPU usage
DNS Error
And I will be using this keywords to get a response from a Database.
Just annotate them accordingly, e.g.
## intent: query_error
- Service [httpd](keyword) is not responding because of [high CPU usage](keyword) and [DNS Error](keyword)
Having the sentence from above, Rasa NLU would extract 3 entities of type keyword. You can then access these entities in a custom action and query your database.
Regarding the number of examples which are required: this depends on
the NLU pipeline which you are using. Typically tensorflow_embedding requires more training examples than spacy_sklearn since it does not use pretrained language models.
the number of different values your entities can have. If it is only httpd, high CPU usage, and DNS error then you don't need a lot of examples. However, if you have a thousand different values for your entity, then you need more training examples
One intent is enough if you always want to trigger the same custom action. However, if you want to classify different type of problems, e.g. server problems and client problems, and trigger different databases depending on the type of problems, you might consider having multiple intents.
Sorry for the vague answers, but in machine learning most things are highly dependent on the use case and the dataset.

Validate Command in CQRS that related to other domain

I am learning to develop microservices using DDD, CQRS, and ES. It is HTTP RESTful service. The microservices is about online shop. There are several domains like products, orders, suppliers, customers, and so on. The domains built in separate services. How to do the validation if the command payload relates to other domains?
For example, here is the addOrderItemCommand payload in the order service (command-side).
{
"customerId": "CUST111",
"productId": "SKU222",
"orderId":"SO333"
}
How to validate the command above? How to know that the customer is really exists in database (query-side customer service) and still active? How to know that the product is exists in database and the status of the product is published? How to know whether the customer eligible to get the promo price from the related product?
Is it ok to call API directly (like point-to-point / ajax / request promise) to validate this payload in order command-side service? But I think, the performance will get worse if the API called directly just for validation. Because, we have developed an event processor outside the command-service that listen from the event and apply the event to the materalized view.
Thank you.
As there are more than one bounded contexts that need to be queried for the validation to pass you need to consider eventual consistency. That being said, there is always a chance that the process as a whole can be in an invalid state for a "small" amount of time. For example, the user could be deactivated after the command is accepted and before the order is shipped. An online shop is a complex system and exceptions could appear in any of its subsystems. However, being implemented as an event-driven system helps; every time the ordering process enters an invalid state you can take compensatory actions/commands. For example, if the user is deactivated in the meantime you can cancel all its standing orders, release the reserved products, announce the potential customers that have those products in the wishlist that they are not available and so on.
There are many kinds of validation in DDD but I follow the general rule that the validation should be done as early as possible but without compromising data consistency. So, in order to be early you could query the readmodel to reject the commands that couldn't possible be valid and in order for the system to be consistent you need to make another check just before the order is shipped.
Now let's talk about your specific questions:
How to know that the customer is really exists in database (query-side customer service) and still active?
You can query the readmodel to verify that the user exists and it is still active. You should do this as a command that comes from an invalid user is a strong indication of some kind of attack and you don't want those kind of commands passing through your system. However, even if a command passes this check, it does not necessarily mean that the order will be shipped as other exceptions could be raised in between.
How to know that the product is exists in database and the status of the product is published?
Again, you can query the readmodel in order to notify the user that the product is not available at the moment. Or, depending on your business, you could allow the command to pass if you know that those products will be available in less than 24 hours based on some previous statistics (for example you know that TV sets arrive daily in your stock). Or you could let the customer choose whether it waits or not. In this case, if the products are not in stock at the final phase of the ordering (the shipping) you notify the customer that the products are not in stock anymore.
How to know whether the customer eligible to get the promo price from the related product?
You will probably have to query another bounded context like Promotions BC to check this. This depends on how promotions are validated/used.
Is it ok to call API directly (like point-to-point / ajax / request promise) to validate this payload in order command-side service? But I think, the performance will get worse if the API called directly just for validation.
This depends on how resilient you want your system to be and how fast you want to reject invalid commands.
Synchronous call are simpler to implement but they lead to a less resilient system (you should be aware of cascade failures and use technics like circuit breaker to stop them).
Asynchronous (i.e. using events) calls are harder to implement but make you system more resilient. In order to have async calls, the ordering system can subscribe to other systems for events and maintain a private state that can be queried for validation purposes as the commands arrive. In this way, the ordering system continues to work even of the link to inventory or customer management systems are down.
In any case, it really depends on your business and none of us can tell you exaclty what to do.
As always everything depends on the specifics of the domain but as a general principle cross domain validation should be done via the read model.
In this case, I would maintain a read model within each microservice for use in validation. Of course, that brings with it the question of eventual consistency.
How you handle that should come from your understanding of the domain. Factors such as the length of the eventual consistency compared to the frequency of updates should be considered. The cost of getting it wrong for the business compared to the cost of development to minimise the problem. In many cases, just recording the fact there has been a problem is more than adequate for the business.
I have a blog post dedicated to validation which you can find here: How To Validate Commands in a CQRS Application

How to detect relationships using Microsoft Cognitive services?

Microsoft Cognitive Services offers a wide variety of capabilities to extract information from natural language. However I am not able to find how to use them in order to detect "relationships" where e.g. two (or more) specific "entities" are involved.
For example, detecting company acquisitions / merging.
These could be expressed in News articles as
"Company 1" has announced to acquire "Company2".
Certainly, there are several approaches to address that need, some that include entity detection first (e.g. Company1 and Company2 being companies) and then the relation (e.g. acquire ...).
Other approaches involve identifying first the "action" ( acquire ) and then through grammatical analysis find which is the "actor" and which the "object" of the action.
Machine learning approaches for semantic relation extraction has also been developed, in order to avoid humans to craft formal relation rules.
I would like to know if / how this use case can be performed with the Microsoft Cognitive Services.
Thankyou
Depends on tech used to examine response from the API https://dev.projectoxford.ai/docs/services
I use JQuery to parse the json response (webclient in asp.net code behind) from Luis/Cognitive Services API (I am not using the Bot Framework). I have a rules engine that I can configure for clients and save it, so that when the page loads, they fire functions based on the parsed json response. The rules engine includes various condition functions like contains, begins with, is, etc so I can test the users query for specific entities or virtually anything in the users query. It really comes down to a && or || javascript functions...
For example if intent=product in the json response, I then show a shopping cart widget. Or if entity=coffee black OR entity=double double then it triggers a widget to inject into the chat window (SHOW Shopping Cart). In short you either handle the AND/OR via the Bot Framework or via your tech of choice.

PredictionIO customization Universal Recommender

I want to implement a Universal Recommender for our site.
I've successfully set up the base configuration customized by the tutorial.
The service we provide is a e-commerce, where users can buy, like, rate from 0 to 5 and save a product among the other actions.
I'm a little confused about how to set up these:
Like / unlike;
Save / remove;
Rate.
I know I can attach properties on the events, but I don't get how set a negative weight to the unlike and remove events.
Also I don't know how the rating could be weighted by the algorithm, if I didn't set anywhere a range in which evaluate a product.
Hope you can enlighten me.
Bests
The Universal Recommender is build on the Correlated Cross-Occurrence algorithm, which measures the correlation of any number of indicators with the action to be recommended. In your case you want a user to "buy" so you should include that as the primary event—the one by which all others are compared.
The primary event is
buy
So that makes the secondary events:
like
unlike
save (to shopping cart?)
remove (from shopping cart? if so not much of an indicator probably)
rate (is there a range?)
You could make some guesses about low rating means "hate" and high ratings mean "love", toss out middle/ambiguous ratings and replace rate with these 2 new events.
If you don't have "buy" you could substitute something like "love" or "like" in it's place as the primary event.
The point of separating the events into 2 types is that the Universal Recommender will test to see which of the secondary events correlate with "buy" and will automatically weight them so that all of them can be used for recommendations.

Access and scheduling of FHIR Questionnaire resource

I am trying to understand how to use the FHIR Questionnaire resource, and have a specific question regarding this.
My project is specifically regarding how a citizen in our country could be responding to Questionnaires via a web app, which are then submitted to the FHIR server as QuestionnaireAnswers, to be read/analyzed by a health professional.
A FHIR-based system could have lots of Questionnaires (Qs), groups of Qs or even specific Qs would be targeted towards certain users or groups of users. The display of the questionnare to the citizen could also be based on a Care-plan of a sort, for example certain Questionnaires needing filling-in in the weeks after surgery. The Questionnaires could also be regular ones that need to be filled in every day or week permanently, to support data collection on the state of a chronic disease.
What I'm wondering is if FHIR has a resource which fits into organizing the 'logistics' of displaying the right form to the right person. I can see CarePlan, which seems to partly fit. Or is this something that would typically be handled out-of-FHIR-scope by specific server implementations?
So, to summarize:
Which resource or mechanism would a health professional use to set up that a patient should answer certain Questionnaires, either regularly or as part of for example a follow-up after a surgery. So this would include setting up the schedule for the form(s) to be filled in, and possibly configure what would happen if the form wasn't filled in as required.
Which resource (possibly the same) or mechanism would be used for the patient's web app to retrieve the relevant Questionnaire(s) at a given point in time?
At the moment, the best resource for saying "please capture data of type X on schedule Y" would be DiagnosticOrder, though the description probably doesn't make that clear. (If you'd be willing to click the "Propose a change" link and submit a change request for us to clarify, that'd be great.) If you wanted to order multiple questionnaires, then CarePlan would be a way to group that.
The process of taking a complex schedule (or set of schedules) and turning that into a simple list of "do this now" requests that might be more suitable for a mobile application to deal with is scheduled for DSTU 2.1. Until then, you have a few options for the mobile app:
- have it look at the CarePlan and complex DiagnosticOrder schedule and figure things out itself
- have a server generate a List of mini 1-time DiagnosticOrders and/or Orders identifying the specific "answer" times
- roll your own mechanism using the Other/Basic resource
Depending on your timelines, you might want to stay tuned to discussions by the Patient Care and Orders and Observations work groups as they start dealing with the issues around workflow management starting next month in Atlanta.

Resources