473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

how to make auto-add field in a table for apriori?

i have a problem for aplication of apriori algorithm in datamining..my problem is how to make an additional field in database?
for example: I have some data like shown below:
-------------------------------------
id_session | id_hyperlink|
------------------------------------
1 | 1
1 | 2
1 | 3
1 | 4
1 | 5
2 | 1
2 | 2
2 | 3
2 | 4
2 | 5
3 | 1
3 | 2
3 | 3
3 | 4
3 | 5
-----------------------------
first, we must count the number for each id_hyperlink as new candidat for next tabel with a condition that the id_hyperlink which filled minimum support can be a new candidat....and after that we must loop the new candidates of id_hyperlink which have minimum suport to find a new candidates again....but here, i just can find untill the second iteration...
so, how to add new field (automatically by using database or php code by looping the data) of the tabel that save the value of the next new candidate?

here's the source code i've write for this time
//THE DATABASE:
CREATE TABLE `session` (
`id` int(11) NOT NULL auto_increment,
`id_session` int(11) NOT NULL,
`id_hyperlink` int(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=76
//--------------------------------------------------------------------------------------------------
CREATE TABLE `apriori` (
`id` int(11) NOT NULL auto_increment,
`id_link1` int(11) NOT NULL,
`supp` int(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=10 ;
//-------------------------------------------------------------------------------
CREATE TABLE `temp` (
`id` int(11) NOT NULL auto_increment,
`id_link1` int(11) NOT NULL,
`id_link2` int(10) NOT NULL,
`num` int(10) NOT NULL,
`supp` float default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=25 ;

================================================== =
//THE PHP CODE//
$sql= 'SELECT MAX(id_session) as id_session FROM session';
$hasil = mysql_query ($sql);
$row = mysql_fetch_array($hasil);
$id = $row['id_session'];
$supp = 0.5;
$jumlah = $supp * $id;
//----------------------------------------------------------------------
//iterasi 1
$sql1 = "insert into apriori (id_link1, supp)
SELECT id_hyperlink as id_hyp, count(*) as banyak
FROM `session` group by id_hyperlink having banyak >= $supp";
$hasil1 = mysql_query ($sql1);
//------------------------------------------------------------------------
//iterasi2
$sql2 ="
INSERT INTO temp(id_link1, id_link2, num, supp)
SELECT a1.id_link1 AS id1, a2.id_link1 AS id2, count(*) AS jumlah, (count(*) / $id) AS support
FROM apriori a1, apriori a2, session s1, session s2
WHERE
a1.id_link1 < a2.id_link1
AND (a1.id_link1, a2.id_link1)
IN (
SELECT s1.id_hyperlink, s2.id_hyperlink
FROM session s1, session s2
WHERE s1.id_session = s2.id_session AND s1.id_hyperlink <> s2.id_hyperlink
GROUP BY s1.id_hyperlink, s2.id_hyperlink
)
AND s1.id_hyperlink = a1.id_link1
AND s2.id_hyperlink = a2.id_link1
AND s1.id_session = s2.id_session
GROUP BY id1, id2
HAVING jumlah >= $jumlah
";
$hasil2 = mysql_query($sql2);
$num = 1;
?>
//-------------------------------------------------------------------------------------------------------

/*how can I add-automatically the field of table temp above because there will be still new candidates? for example adding 'id_link3' in the table 'temp' cz for the second iteration still there are a couple candidates....but for the 3rd iteration there will b 3 candidates */
Jul 30 '07 #1
0 1678

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: pptran | last post by:
Hi, I am pretty new to building and installing Perl. Can someone help explain the severity of the following Perl 5.8.4 build error message? ==================================================...
0
by: Madhu Nair | last post by:
I am getting errors while compiling DBD-mysql 2.9002 on HP-UX 11.00 I have perl 5.8 downloaded from HP depot installed at /opt/perl Mysql 4.0.13 compiled myself with gcc with Mysql recommended...
37
by: ajay | last post by:
How to make a web page getting refreshed after a given time interval automatically. HTML Code plz. Tx Ajay
2
by: joey.powell | last post by:
Make Firefox Center Content in a div Or td Tag By Using CSS? Does anyone know how to do this. IE works great with text-align:center; but Firefox just always left-aligns...
20
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
2
by: Jake Barnes | last post by:
Imagine I've this block of HTML: <p>Alex Schein Mailing List <input type="checkbox" name="newslettersToUse" value="133156"> (<a href="mcControlPanel.php"...
5
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if...
0
by: Seguros Catatumbo | last post by:
Hi, i have this code on a test site: <html> <head> <style type="text/css"> #main{ border:1px solid #000063; border-width:1px; background:#FFF; width:400px; margin: 0 auto;
5
by: webandwe | last post by:
Hi I just need some code tips or ideas. I need to build a part of DB which has details of certain food providers at shelters. Here is what I need to build extra Once you click a link on...
21
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.