Skip to content

Commit

Permalink
PUB-316: Print model specification in HTML output.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkraljevic committed Feb 25, 2014
1 parent 2cb2ee1 commit 5fca1eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/hex/KMeans2.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public KMeans2() {
domain[i] = "Cluster " + i;
String[] namesResp = Utils.append(names, "response");
String[][] domaiResp = (String[][]) Utils.append((new Frame(names, vecs)).domains(), (Object) domain);
KMeans2Model model = new KMeans2Model(destination_key, sourceKey, namesResp, domaiResp);
KMeans2Model model = new KMeans2Model(this, destination_key, sourceKey, namesResp, domaiResp);
model.delete_and_lock(self());
model.k = k; model.normalized = normalize; model.max_iter = max_iter;

Expand Down Expand Up @@ -199,6 +199,7 @@ public static Response redirect(Request req, Key model) {

@Override public boolean toHTML(StringBuilder sb) {
if( model != null ) {
model._params.makeJsonBox(sb);
DocGen.HTML.section(sb, "Cluster Centers: "); //"Total Within Cluster Sum of Squares: " + model.total_within_SS);
table(sb, "Clusters", model._names, model.centers);
double[][] rows = new double[model.within_cluster_variances.length][1];
Expand Down Expand Up @@ -290,6 +291,8 @@ public static class KMeans2Model extends Model implements Progress {
static final int API_WEAVER = 1;
static public DocGen.FieldDoc[] DOC_FIELDS;

private transient final KMeans2 _params; // This is used purely for printing values out.

@API(help = "Cluster centers, always denormalized")
public double[][] centers;

Expand Down Expand Up @@ -330,8 +333,9 @@ public static class KMeans2Model extends Model implements Progress {
private transient double[][] _normClust;
private transient double[] _means, _mults;

public KMeans2Model(Key selfKey, Key dataKey, String names[], String domains[][]) {
public KMeans2Model(KMeans2 params, Key selfKey, Key dataKey, String names[], String domains[][]) {
super(selfKey, dataKey, names, domains);
_params = params;
_clustersKey = Key.make(selfKey.toString() + "_clusters");
}

Expand Down

0 comments on commit 5fca1eb

Please sign in to comment.