random.transactions.html
来自「本程序是基于linux系统下c++代码」· HTML 代码 · 共 175 行
HTML
175 行
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Simulate a Random Transaction Data Set</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>
<table width="100%" summary="page for random.transactions {arules}"><tr><td>random.transactions {arules}</td><td align="right">R Documentation</td></tr></table>
<h2>Simulate a Random Transaction Data Set</h2>
<h3>Description</h3>
<p>
Simulates a random <code><a href="transactions-class.html">transactions</a></code> object using different
methods.
</p>
<h3>Usage</h3>
<pre>
random.transactions(nItems, nTrans, method = "independent", ...,
verbose = FALSE)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>nItems</code></td>
<td>
an integer. Number of items.</td></tr>
<tr valign="top"><td><code>nTrans</code></td>
<td>
an integer. Number of transactions.</td></tr>
<tr valign="top"><td><code>method</code></td>
<td>
name of the simulation method used (default:
all items occur independently).</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
further arguments used for the specific simulation
method (see details).</td></tr>
<tr valign="top"><td><code>verbose</code></td>
<td>
report progress.</td></tr>
</table>
<h3>Details</h3>
<p>
The function generates a <code>nitems</code> times <code>ntrans</code>
transaction database.
</p>
<p>
Currently two simulation methods are implemented:
<dl>
<dt>method <code>"independent"</code> (see Hahsler et al., 2005)</dt><dd>All items are treated as independent.
Each transaction is the result of <code>nItems</code> independent
Bernoulli trials, one for each item with success
probabilities given by the numeric
vector <code>iProb</code> of length <code>nItems</code>
(default: 0.01 for each item).
</dd>
<dt>method <code>"agrawal"</code> (see Agrawal and Srikant, 1994)</dt><dd>This method creates transactions with correlated items
uses the following additional parameters:
<dl>
<dt>lTrans</dt><dd>average length of transactions.</dd>
<dt>nPats</dt><dd>number of patterns (potential maximal frequent itemsets)
used.</dd>
<dt>lPats</dt><dd>average length of patterns.</dd>
<dt>corr</dt><dd>correlation between consecutive patterns.</dd>
<dt>cmean</dt><dd>mean of the corruption level (normal distr.).</dd>
<dt>cvar</dt><dd>variance of the corruption level.</dd>
</dl>
</p>
<p>
The simulation is a two-stage process. First, a set of
<code>nPats</code> patterns
(potential maximal frequent itemsets) is generated.
The length of the patterns is Poisson distributed with mean
<code>lPats</code> and consecutive patterns share some items controlled by
the correlation parameter <code>corr</code>.
For later use, for each pattern a pattern weight is
generated by drawing
from an exponential distribution with a mean of 1 and
a corruption level is chosen from a normal distribution
with mean <code>cmean</code> and variance <code>cvar</code>.
</p>
<p>
The patterns are created using the following function:
</p>
<p>
<code>random.patterns(nItems, nPats = 2000, method = "agrawal", lPats = 4, corr = 0.5, cmean = 0.5, cvar = 0.1, iWeight = NULL, verbose = FALSE)</code>
</p>
<p>
The function returns the patterns as an <code>itemsets</code> objects which can
be supplied to <code>random.transactions</code> as the argument <code>patterns</code>.
If no argument <code>patterns</code> is supplied, the default values given above
are used.
</p>
<p>
In the second step, the transactions are generated using the patterns.
The length the transactions follows a Poisson
distribution with mean <code>lPats</code>. For each transaction, patterns are
randomly chosen using the pattern weights till the transaction length
is reached. For each chosen
pattern, the associated corruption level is used to drop some
items before adding the pattern to the transaction.
</dd>
</dl>
<h3>Value</h3>
<p>
Returns an object of class
<code><a href="transactions-class.html">transactions</a></code>.</p>
<h3>References</h3>
<p>
Michael Hahsler, Kurt Hornik, and Thomas Reutterer (2006). Implications of
probabilistic data modeling for mining association rules. In M. Spiliopoulou,
R. Kruse, C. Borgelt, A. Nuernberger, and W. Gaul, editors, <EM>From Data and
Information Analysis to Knowledge Engineering, Studies in Classification, Data
Analysis, and Knowledge Organization</EM>, pages 598–605. Springer-Verlag.
</p>
<p>
Rakesh Agrawal and Ramakrishnan Srikant (1994). Fast algorithms for mining
association rules in large databases. In Jorge B. Bocca, Matthias Jarke, and
Carlo Zaniolo, editors, <EM>Proceedings of the 20th International Conference
on Very Large Data Bases, VLDB</EM>, pages 487–499, Santiago, Chile.
</p>
<h3>See Also</h3>
<p>
<code><a href="transactions-class.html">transactions-class</a></code>.
</p>
<h3>Examples</h3>
<pre>
## generate random 1000 transactions for 200 items with
## a success probability decreasing from 0.2 to 0.0001
## using the method described in Hahsler et al. (2006).
trans <- random.transactions(nItems = 200, nTrans = 1000,
iProb = seq(0.2,0.0001, length=200))
## display random data set
image(trans)
## use the method by Agrawal and Srikant (1994) to simulate transactions
## which contains correlated items. This should create data similar to
## T10I4D100K (just only 1000 transactions)
patterns <- random.patterns(nItems = 1000)
summary(patterns)
trans2 <- random.transactions(nItems = 1000, nTrans = 1000,
method = "agrawal", patterns = patterns)
image(trans2)
## plot data with items ordered by item frequency
image(trans2[,order(itemFrequency(trans2), decreasing=TRUE)])
</pre>
<hr><div align="center">[Package <em>arules</em> version 0.6-6 <a href="00Index.html">Index]</a></div>
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?