OLE DB for DM实践 —— 用数据挖掘实现交叉销售
2007-07-25 21:11
489 查看
我们在访问一些销售网站时,常常会碰上这种情况:浏览某商品信息的同时,网页上会打出促销广告,购买此商品加另一商品可以享受折扣,就像下面图片中的那样。
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml" >
6<head runat="server">
7 <title>无标题页</title>
8</head>
9<body>
10 <form id="form1" runat="server">
11 <div>
12 <asp:Label ID="Label1" runat="server" Height="1px" Text="选择您想要的商品"
13 Width="200px" style="z-index: 108; left: 10px; position: absolute; top: 15px"></asp:Label>
14 <asp:Label ID="Label2" runat="server" Height="1px" Style="left: 270px;
15 position: absolute; top: 15px; z-index: 101;" Text="您已选购的商品" Width="270px"></asp:Label><br />
16 <br />
17 <asp:ListBox ID="ListBox1" runat="server" DataSourceID="AdventureWorksDW"
18 DataTextField="Model" DataValueField="Model" Height="353px" Width="200px" style="z-index: 102; left: 10px; position: absolute; top: 53px"></asp:ListBox>
19 <asp:ListBox ID="ListBox2" runat="server" Height="353px" Style="z-index: 103; left: 270px;
20 position: absolute; top: 53px" Width="270px" AutoPostBack="True"></asp:ListBox>
21 <asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Size="16pt" Style="left: 218px;
22 position: absolute; top: 160px; z-index: 104;" Text=">" Width="41px" Height="41px" />
23 <asp:Button ID="Button2" runat="server" Font-Bold="True" Font-Size="16pt" Style="left: 218px;
24 position: absolute; top: 221px; z-index: 105;" Text="<" Width="41px" Height="41px" />
25 <asp:SqlDataSource ID="AdventureWorksDW" runat="server" ConnectionString="Data Source=127.0.0.1;Initial Catalog=AdventureWorksDW;Integrated Security=True"
26 ProviderName="System.Data.SqlClient"
27 SelectCommand="SELECT DISTINCT Model FROM vAssocSeqLineItems"></asp:SqlDataSource>
28
29 </div>
30
31 <asp:Panel ID="Panel1" runat="server" BorderStyle="None" BorderWidth="1px" Enabled="False"
32 Height="182px" Style="z-index: 106; left: 10px; position: absolute; top: 420px"
33 Width="380px">
34 <asp:Label ID="Label3" runat="server" Height="62px" Style="z-index: 100; left: 6px;
35 position: absolute; top: 3px" Text="您可以捆绑购买下面的一种商品,捆绑购买将享受9折优惠" Width="370px"></asp:Label>
36 <asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="71px" RepeatLayout="Flow"
37 Style="z-index: 101; left: 6px; position: absolute; top: 72px" Width="370px">
38 </asp:RadioButtonList>
39 <asp:Button ID="Button3" runat="server" Style="z-index: 103; left: 6px; position: absolute;
40 top: 151px" Text="确定" Width="370px" />
41 </asp:Panel>
42 <asp:Label ID="Label4" runat="server" Height="50px" Style="z-index: 107; left: 10px;
43 position: absolute; top: 610px" Width="380px" Font-Size="12pt"></asp:Label>
44 </form>
45</body>
46</html>
47
向项目中添加Microsoft.AnalysisServices.AdomdClient引用,然后写后台代码:
1Imports Microsoft.AnalysisServices.AdomdClient
2
170'商品可以打包销售,包中有多个商品
171<Serializable()> _
172Class PackageClass Package
173 Public ReadOnly Property name()Property name() As String '包的名称,格式是:“商品型号名 + 商品型号名,折扣”
174 Get
175 Dim v As String = ""
176 For i As Integer = 1 To Me.models.Count
177 If i = 1 Then
178 v += models(i)
179 Else
180 v += " + " + models(i)
181 End If
182 Next
183 If Me.discount <> 10 Then
184 v += " , " + Me.discount.ToString + "折"
185 End If
186 Return v
187 End Get
188 End Property
189 Public discount As Integer '折扣
190 Public removed As Boolean '包从已选商品列表中删除标识
191 Public models As Collection '商品型号集合
192 Public Sub New()Sub New(ByVal firstModel As String)
193 Me.models = New Collection
194 Me.models.Add(firstModel)
195 Me.discount = 10
196 Me.removed = False
197 End Sub
198End Class
总结:从代码中可以看出Adomd与Ado在查询方面的使用方法区别不大,关键是对于OLE DB for DM中嵌套表及DMX的理解。我这里仅仅是简单的实践而已,实际环境中的就不可能这么简单,商务网站一般不会是在客户选择了一件商品后就打折促销,而是等客户选购完他需要的商品后,再将其他商品打折推销给客户;另外对复杂的挖掘模型查询是非常费时的,代码中还需要考虑线程异步的问题。
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml" >
6<head runat="server">
7 <title>无标题页</title>
8</head>
9<body>
10 <form id="form1" runat="server">
11 <div>
12 <asp:Label ID="Label1" runat="server" Height="1px" Text="选择您想要的商品"
13 Width="200px" style="z-index: 108; left: 10px; position: absolute; top: 15px"></asp:Label>
14 <asp:Label ID="Label2" runat="server" Height="1px" Style="left: 270px;
15 position: absolute; top: 15px; z-index: 101;" Text="您已选购的商品" Width="270px"></asp:Label><br />
16 <br />
17 <asp:ListBox ID="ListBox1" runat="server" DataSourceID="AdventureWorksDW"
18 DataTextField="Model" DataValueField="Model" Height="353px" Width="200px" style="z-index: 102; left: 10px; position: absolute; top: 53px"></asp:ListBox>
19 <asp:ListBox ID="ListBox2" runat="server" Height="353px" Style="z-index: 103; left: 270px;
20 position: absolute; top: 53px" Width="270px" AutoPostBack="True"></asp:ListBox>
21 <asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Size="16pt" Style="left: 218px;
22 position: absolute; top: 160px; z-index: 104;" Text=">" Width="41px" Height="41px" />
23 <asp:Button ID="Button2" runat="server" Font-Bold="True" Font-Size="16pt" Style="left: 218px;
24 position: absolute; top: 221px; z-index: 105;" Text="<" Width="41px" Height="41px" />
25 <asp:SqlDataSource ID="AdventureWorksDW" runat="server" ConnectionString="Data Source=127.0.0.1;Initial Catalog=AdventureWorksDW;Integrated Security=True"
26 ProviderName="System.Data.SqlClient"
27 SelectCommand="SELECT DISTINCT Model FROM vAssocSeqLineItems"></asp:SqlDataSource>
28
29 </div>
30
31 <asp:Panel ID="Panel1" runat="server" BorderStyle="None" BorderWidth="1px" Enabled="False"
32 Height="182px" Style="z-index: 106; left: 10px; position: absolute; top: 420px"
33 Width="380px">
34 <asp:Label ID="Label3" runat="server" Height="62px" Style="z-index: 100; left: 6px;
35 position: absolute; top: 3px" Text="您可以捆绑购买下面的一种商品,捆绑购买将享受9折优惠" Width="370px"></asp:Label>
36 <asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="71px" RepeatLayout="Flow"
37 Style="z-index: 101; left: 6px; position: absolute; top: 72px" Width="370px">
38 </asp:RadioButtonList>
39 <asp:Button ID="Button3" runat="server" Style="z-index: 103; left: 6px; position: absolute;
40 top: 151px" Text="确定" Width="370px" />
41 </asp:Panel>
42 <asp:Label ID="Label4" runat="server" Height="50px" Style="z-index: 107; left: 10px;
43 position: absolute; top: 610px" Width="380px" Font-Size="12pt"></asp:Label>
44 </form>
45</body>
46</html>
47
向项目中添加Microsoft.AnalysisServices.AdomdClient引用,然后写后台代码:
1Imports Microsoft.AnalysisServices.AdomdClient
2
170'商品可以打包销售,包中有多个商品
171<Serializable()> _
172Class PackageClass Package
173 Public ReadOnly Property name()Property name() As String '包的名称,格式是:“商品型号名 + 商品型号名,折扣”
174 Get
175 Dim v As String = ""
176 For i As Integer = 1 To Me.models.Count
177 If i = 1 Then
178 v += models(i)
179 Else
180 v += " + " + models(i)
181 End If
182 Next
183 If Me.discount <> 10 Then
184 v += " , " + Me.discount.ToString + "折"
185 End If
186 Return v
187 End Get
188 End Property
189 Public discount As Integer '折扣
190 Public removed As Boolean '包从已选商品列表中删除标识
191 Public models As Collection '商品型号集合
192 Public Sub New()Sub New(ByVal firstModel As String)
193 Me.models = New Collection
194 Me.models.Add(firstModel)
195 Me.discount = 10
196 Me.removed = False
197 End Sub
198End Class
总结:从代码中可以看出Adomd与Ado在查询方面的使用方法区别不大,关键是对于OLE DB for DM中嵌套表及DMX的理解。我这里仅仅是简单的实践而已,实际环境中的就不可能这么简单,商务网站一般不会是在客户选择了一件商品后就打折促销,而是等客户选购完他需要的商品后,再将其他商品打折推销给客户;另外对复杂的挖掘模型查询是非常费时的,代码中还需要考虑线程异步的问题。
相关文章推荐
- OLE DB for DM实践 —— 用数据挖掘实现交叉销售(转)
- HybridDB for MySQL 实现在线与离线数据分离的实践
- CRISP-DM (cross-industry standard process for data mining) 跨行业数据挖掘标准流程
- Greenplum 空间(GIS)数据检索 B-Tree & GiST 索引实践 - 阿里云HybridDB for PostgreSQL最佳实践
- python数据挖掘实践第一章 KNN算法,以及算法的实现
- Greenplum 空间(GIS)数据检索 B-Tree & GiST 索引实践 - 阿里云HybridDB for PostgreSQL最佳实践
- # 数据挖掘算法 ## 18大经典DM算法 18大数据挖掘的经典算法以及代码实现,涉及到了决策分类,聚类,链接挖掘,关联挖掘,模式挖掘等等方面,后面都是相应算法的博文链接,希望能够帮助大家学。 目前
- OLE DB provider "SQLNCLI11" for linked server "10.0.9.137" returned message "事务中的登记已经存在。". 消息 7395,级
- MSSQL · 最佳实践 · 利用文件组实现冷热数据隔离备份方案
- vb.net 利用datagridview显示DB数据(亲自实践)
- 数据挖掘项目之---通过对web日志的挖掘来实现内容推荐系统
- 用SQL SERVER 2005的数据挖掘实现图书馆书目推荐服务
- Python数据挖掘入门与实践(一)——亲和性分析
- 利用数据挖掘实现电信行业客户流失分析
- 数据挖掘中 决策树算法实现——Bash
- 数据挖掘系列(10)——卷积神经网络算法的一个实现
- SuperMap iClient for JavaScript 时空数据动画的实现(二)
- 利用R语言实现支持向量机(SVM)数据挖掘案例
- 数据挖掘-matlab实现基于MovieLens数据集的协同过滤电影推荐系统
- HAWQ + MADlib 玩转数据挖掘之(四)——低秩矩阵分解实现推荐算法