Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here i send some codings for apriori...this coding is used for only 3 candidate generation. if n items is given as a input how to write the coding?
VB
Imports System.Data
Imports System.Data.SqlClient

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim i As Integer
        Dim minsup = 20
        Dim minconfid = 40
        Dim mycon As SqlConnection
        Dim mycommand As SqlCommand
        Dim dr As SqlDataReader
        Dim da As New SqlDataAdapter


        Dim q(50) As Integer
        Dim q1(50), bn(50), bn1(50) As Integer

        mycon = New SqlConnection("Data Source=CSESAP04\SQLEXPRESS;Initial Catalog=novel;Integrated Security=True")
        mycon.Open()
        mycommand = New SqlCommand("select * from apriori", mycon)
        '
dr = mycommand.ExecuteReader


        Dim itemcount As Integer = 9


        'for item count....

        For i = 1 To itemcount
            cal1(i)
        Next

        Dim j, h, n As Integer
        Dim m(8) As Integer
        Dim totrans As Integer = 15



        'for single item support

        For j = 0 To ListBox1.Items.Count - 1
            h = (ListBox1.Items(j) / totrans) * 100
            m(j) = h
        Next

        For i = 0 To m.Length - 1
            If m(i) > minsup Then
                ListBox2.Items.Add(i + 1)
            End If
        Next



        'for 2 candidate generation
        Dim v, firstvar, nextvar As Integer
        Dim w As Integer
        Dim h1(50) As Integer
        For v = 0 To ListBox2.Items.Count - 1
            For w = 0 To ListBox2.Items.Count - 1
                firstvar = ListBox2.Items(v)
                nextvar = ListBox2.Items(w)
                ListBox3.Items.Add(firstvar & " ," & nextvar)
                cndsup(firstvar, nextvar)
                'q(v) = firstvar
                'q1(w) = nextvar
                'ListBox3.Items.Add(q(v) & "," & q1(w))
            Next
        Next




        Dim c, t, k, g(100) As Integer
        For c = 0 To ListBox4.Items.Count - 1
            k = (ListBox4.Items(c) / totrans) * 100
            g(c) = k
        Next
        For t = 0 To g.Length - 1
            If g(t) > minsup Then
                'MessageBox.Show("pos is" & t)
                ListBox5.Items.Add(ListBox3.Items(t))
                'tcand(t)
            End If
        Next
        'MessageBox.Show("count is" & ListBox7.Items.Count)


        'for  3 itemset generation

        Dim kf As Integer
        Dim kf1(1000) As Integer
        For kf = 0 To ListBox7.Items.Count - 1
            n = (ListBox7.Items(kf) / totrans) * 100
            kf1(kf) = n
        Next


        For t = 0 To kf1.Length - 1
            If kf1(t) > minsup Then
                'MessageBox.Show("pos is" & t)
                ListBox8.Items.Add(ListBox6.Items(t))
                'tcand(t)
            End If
        Next

    End Sub
Posted
Updated 1-Jul-10 23:25pm
v2
Comments
Sandeep Mewara 2-Jul-10 5:26am    
Subject line should be brief and specific. 'Help code' is not suggestible. Changed it.
tiggerc 2-Jul-10 7:19am    
I don't understand why you query the database and then don't appear to use it, and it would be most helpful if you could explain a little better what you want to acheive.

1 solution

I can';t read this code, it is horrible. To do anything an arbitrary number of times, create a loop that can be called the number of times required.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900