DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: continue

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    11

    continue

    public static void main(String[] args) {

    int[][] documents = { {1, 4, 3, 2, 3, 1, 4, 3, 2, 3, 1, 4, 3, 2, 3, 6},
    {2, 2, 4, 2, 4, 2, 2, 2, 2, 4, 2, 2},
    {1, 6, 5, 6, 0, 1, 6, 5, 6, 0, 1, 6, 5, 6, 0, 0},
    {5, 6, 6, 2, 3, 3, 6, 5, 6, 2, 2, 6, 5, 6, 6, 6, 0},
    {2, 2, 4, 4, 4, 4, 1, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 0},
    {5, 4, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2}};
    // vocabulary
    int V = 7;
    int M = documents.length;
    // # topics
    int K = 2;
    // good values alpha = 2, beta = .5
    double alpha = 2;
    double beta = .5;

    System.out.println("Latent Dirichlet Allocation using Gibbs Sampling.");

    LdaGibbsSampler lda = new LdaGibbsSampler(documents, V);
    lda.configure(10000, 2000, 100, 10);
    lda.gibbs(K, alpha, beta);

    double[][] theta = lda.getTheta();
    double[][] phi = lda.getPhi();

    System.out.println();
    System.out.println();
    System.out.println("Document--Topic Associations, Theta[d][k] (alpha="
    + alpha + ")");
    System.out.print("d\\k\t");
    for (int m = 0; m < theta[0].length; m++) {
    System.out.print(" " + m % 10 + " ");
    }
    System.out.println();
    for (int m = 0; m < theta.length; m++) {
    System.out.print(m + "\t");
    for (int k = 0; k < theta[m].length; k++) {
    // System.out.print(theta[m][k] + " ");
    System.out.print(shadeDouble(theta[m][k], 1) + " ");
    }
    System.out.println();
    }
    System.out.println();
    System.out.println("Topic--Term Associations, Phi[k][w] (beta=" + beta
    + ")");

    System.out.print("k\\w\t");
    for (int w = 0; w < phi[0].length; w++) {
    System.out.print(" " + w % 10 + " ");
    }
    System.out.println();
    for (int k = 0; k < phi.length; k++) {
    System.out.print(k + "\t");
    for (int w = 0; w < phi[k].length; w++) {
    // System.out.print(phi[k][w] + " ");
    System.out.print(shadeDouble(phi[k][w], 1) + " ");
    }
    System.out.println();
    }
    }

    static String[] shades = {" ", ". ", ": ", ":. ", ":: ",
    "::. ", "::: ", ":::. ", ":::: ", "::::.", ":::::"};

    static NumberFormat lnf = new DecimalFormat("00E0");

    public static String shadeDouble(double d, double max) {
    int a = (int) Math.floor(d * 10 / max + 0.5);
    if (a > 10 || a < 0) {
    String x = lnf.format(d);
    a = 5 - x.length();
    for (int i = 0; i < a; i++) {
    x += " ";
    }
    return "<" + x + ">";
    }
    return "[" + shades[a] + "]";
    }
    }

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    And, what does, or doesn't, happen when you do something with this code?

Similar Threads

  1. continue on finally
    By loveme in forum Java
    Replies: 1
    Last Post: 11-13-2006, 08:53 AM
  2. Replies: 6
    Last Post: 01-22-2002, 10:59 PM
  3. TECH TIP: Break - Edit - Continue alternatives
    By Larry Serflaten in forum .NET
    Replies: 19
    Last Post: 12-10-2001, 10:19 AM
  4. Replies: 0
    Last Post: 09-05-2001, 09:31 AM
  5. edit and continue, immediate window
    By Alex Tsukernik in forum .NET
    Replies: 12
    Last Post: 06-26-2001, 06:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links