Showing posts with label processing. Show all posts
Showing posts with label processing. Show all posts

Friday, March 30, 2012

Prediction Query in MS Association Rules

Hi!

I'm building a mining model wiht MS Association Rules. After processing this model, the result includes some rules(example):

E = Existing, C = Existing -> B = Existing
F = Existing -> E = Existing
C = Existing, B = Existing -> E = Existing
F = Existing -> B = Existing
B = Existing, A = Existing -> C = Existing
F = Existing, B = Existing -> E = Existing
F = Existing, E = Existing -> B = Existing
D = Existing -> A = Existing
C = Existing -> A = Existing
E = Existing, A = Existing -> B = Existing

I want to buid a query that has two or more items on the left of the rules, example: E = Existing, C = Existing -> B = Existing
->I want to buid a query to predict that: when a customer buy 'E' and 'C' then he likely buys 'B'


All the rules are used when you use AR for prediction. The first place to look is the prediction query builder. There is a button on the top to switch the mode from batch to singleton. With a singleton prediction you can manually specify the inputs for your query.

The prediction function you need to specify is something like "Predict(<my nested table name>, 5)". To build such a prediction in the query builder, select Prediction Function, then Predict, then type the name of your nested table, comma, then the number of recommendations you want into the parameters box.

To see the query select the SQL mode from the toolbar.

Let me know if this helps or if you were looking for some other type of answer

THanks

-Jamie

|||

Hi!

Thanks for interesting in my question!

My domain has two tables: Customer (Customer_ID, Name, ....) and Purchase (Customer_ID, Product_Name, Quantity,...)

Creating Mining Model:

Create Mining Model ProductPredict{

Customer_ID long key,

Purchase Table Predict {Product_Name text key}

}

So, when i buid a query such as:

Select Predict(Purchase, 3)

From ProductPredict Prediction Join

(Select 'A' As Product_Name

) as customer

On [ProductPredict].[Purchase].Product_Name = customer.Product_Name;

Result as all item in the right side of the rules contain 'A' in the left side.

But I want to buid a query that result as all item in the right side of the rules contain 'A' and 'B' in the left side.?

Summary: I want to buid a query that result as all item in the right side of the rules contain some items in the left side?

|||

You need a query such as

Select Predict(Purchase, 3)

From ProductPredict Prediction Join

(select

(Select 'A' As Product_Name UNION Select 'B' AS Product_Name)

as Products

) as customer

On [ProductPredict].[Purchase].Product_Name = customer.Product_Name;

This will cause rules with A and B to fire. You may still get predictions based on A alone and B alone, though, depending on their probability and lift.

|||

Hi!

Thank you very much! That's interesting, but when i run that query, it has error, so the correct query is:

Select PredictAssociation(Purchase, 3)

From ProductPredict Prediction Join

(

select

( Select 'A' As Product_Name

UNION

Select 'B' AS Product_Name

)as Products

) as customer

On [ProductPredict].[Purchase].Product_Name = [customer].[Products].Product_Name

|||Predict is a polymorphic function - DMX maps it to the appropriate function based on the model that's being queried. In this case, it maps to PredictAssociation so you should get the same results either way. What errors did you see with the earlier query?

Tuesday, March 20, 2012

Post processing data flow destinations

What I am trying to do is move data from a staging table into a live environment and then update the staging table AFTER the row has move (and not errored). There does not seem to be a reliable method for doing this.

Any assistance would be appreciated.

Brett Robson wrote:

What I am trying to do is move data from a staging table into a live environment and then update the staging table AFTER the row has move (and not errored). There does not seem to be a reliable method for doing this.

Any assistance would be appreciated.

What specifically isn't reliable? It sounds to me like you need a data-flow to move the data and an Execute SQL Task to issue the UPDATE. That should work OK.

-Jamie

|||

Jamie,

I don't think your quite following what I am trying to do. I want to update the SOURCE table after the rows have moved. I don't want to update the ones which error. How does the Execute SQL Task get the appropriate row ids? They certainly won't be passed from the data-flow.

Regards,

BRETT ROBSON

|||

Brett Robson wrote:

Jamie,

I don't think your quite following what I am trying to do. I want to update the SOURCE table after the rows have moved. I don't want to update the ones which error. How does the Execute SQL Task get the appropriate row ids? They certainly won't be passed from the data-flow.

Regards,

BRETT ROBSON

Oh OK. I gotcha.

You're right, Execute SQL Task is not an option. You can execute your UPDATE from the data-flow though using an OLE DB Command component.

This will work fine - the only problem with it is that it issues an UPDATE for every row - and ths isn't very performant. Another option is to push all the successful rows into another table and update the source table from this new table. This update can be issued from the Execute SQL Task and will be much more performant because you're only doing it once.

-Jamie

|||

Thanks Jamie - either of those two should work.