Skip to content

Commit

Permalink
Moved Neighborhood into algo package for public visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tgsmith61591 committed Apr 16, 2016
1 parent 0bdec4c commit e4ca1e1
Show file tree
Hide file tree
Showing 31 changed files with 337 additions and 87 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A Java-based set of __classification__ clustering algorithms. Built under JDK 1.

___
### Installation:
__Clust4j 1.0.0 prerelease is now available under [releases](https://github.com/tgsmith61591/clust4j/releases) (jar included)__. To build the bleeding edge, use the included gradle wrapper:
__Clust4j 1.1.6 prerelease is now available under [releases](https://github.com/tgsmith61591/clust4j/releases). To build the bleeding edge, use the included gradle wrapper:

```bash
git clone https://github.com/tgsmith61591/clust4j.git
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'jacoco'
sourceCompatibility = 1.7
targetCompatibility = 1.7
archivesBaseName = 'clust4j'
version = '1.1.5-SNAPSHOT'
version = '1.1.6-SNAPSHOT'



Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/clust4j/algo/AbstractClusterer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.text.NumberFormat;
Expand Down Expand Up @@ -124,7 +125,7 @@ protected AbstractClusterer(AbstractClusterer caller) {
* @param planner
*/
protected AbstractClusterer(AbstractClusterer caller, BaseClustererParameters planner) {
this.dist_metric= null == planner ? caller.dist_metric : planner.getSep();
this.dist_metric= null == planner ? caller.dist_metric : planner.getMetric();
this.verbose = null == planner ? false : planner.getVerbose(); // if another caller, default to false
this.modelKey = UUID.randomUUID();
this.random_state = null == planner ? caller.random_state : planner.getSeed();
Expand All @@ -138,7 +139,7 @@ protected AbstractClusterer(AbstractClusterer caller, BaseClustererParameters pl

protected AbstractClusterer(AbstractRealMatrix data, BaseClustererParameters planner, boolean as_is) {

this.dist_metric = planner.getSep();
this.dist_metric = planner.getMetric();
this.verbose = planner.getVerbose();
this.modelKey = UUID.randomUUID();
this.random_state = planner.getSeed();
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/clust4j/algo/AbstractDBSCAN.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ abstract public static class AbstractDBSCANPlanner<T extends AbstractDBSCAN>
extends BaseClustererParameters
implements UnsupervisedClassifierParameters<T> {
private static final long serialVersionUID = 765572960123009344L;
protected int minPts = DEF_MIN_PTS;

abstract public AbstractDBSCANPlanner<T> setMinPts(final int minPts);
abstract public int getMinPts();
final public int getMinPts() {
return minPts;
}
}

public int getMinPts() {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/clust4j/algo/AffinityPropagationParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/clust4j/algo/BaseClustererParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand Down Expand Up @@ -36,7 +52,7 @@ abstract public class BaseClustererParameters
abstract public BaseClustererParameters setForceParallel(final boolean b);

final public FeatureNormalization getNormalizer() { return norm; }
final public GeometricallySeparable getSep() { return metric; }
final public GeometricallySeparable getMetric() { return metric; }
final public boolean getParallel() { return parallel; }
final public boolean getScale() { return scale; }
final public Random getSeed() { return seed; }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/clust4j/algo/BaseNeighborsModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.apache.commons.math3.linear.AbstractRealMatrix;

import com.clust4j.GlobalState;
import com.clust4j.algo.NearestNeighborHeapSearch.Neighborhood;
import com.clust4j.algo.Neighborhood;
import com.clust4j.except.ModelNotFitException;
import com.clust4j.metrics.pairwise.DistanceMetric;
import com.clust4j.metrics.pairwise.GeometricallySeparable;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/clust4j/algo/BoruvkaAlgorithm.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.util.FastMath;

import com.clust4j.algo.NearestNeighborHeapSearch.Neighborhood;
import com.clust4j.algo.Neighborhood;
import com.clust4j.algo.NearestNeighborHeapSearch.NodeData;
import com.clust4j.log.LogTimer;
import com.clust4j.log.Loggable;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/clust4j/algo/CentroidClustererParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import org.apache.commons.math3.linear.AbstractRealMatrix;
Expand Down
22 changes: 16 additions & 6 deletions src/main/java/com/clust4j/algo/DBSCANParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand All @@ -17,7 +33,6 @@ final public class DBSCANParameters extends AbstractDBSCANPlanner<DBSCAN> {
private static final long serialVersionUID = -5285244186285768512L;

private double eps = DBSCAN.DEF_EPS;
private int minPts = DBSCAN.DEF_MIN_PTS;


public DBSCANParameters() { }
Expand Down Expand Up @@ -46,11 +61,6 @@ public DBSCANParameters copy() {
public double getEps() {
return eps;
}

@Override
public int getMinPts() {
return minPts;
}

public DBSCANParameters setEps(final double eps) {
this.eps = eps;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/clust4j/algo/HDBSCAN.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import com.clust4j.GlobalState;
import com.clust4j.utils.QuadTup;
import com.clust4j.algo.NearestNeighborHeapSearch.Neighborhood;
import com.clust4j.algo.Neighborhood;
import com.clust4j.except.ModelNotFitException;
import com.clust4j.log.LogTimer;
import com.clust4j.log.Loggable;
Expand Down
22 changes: 16 additions & 6 deletions src/main/java/com/clust4j/algo/HDBSCANParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand All @@ -17,7 +33,6 @@
final public class HDBSCANParameters extends AbstractDBSCANPlanner<HDBSCAN> {
private static final long serialVersionUID = 7197585563308908685L;

private int minPts = HDBSCAN.DEF_MIN_PTS;
private HDBSCAN_Algorithm algo = HDBSCAN.DEF_ALGO;
private double alpha = HDBSCAN.DEF_ALPHA;
private boolean approxMinSpanTree = HDBSCAN.DEF_APPROX_MIN_SPAN;
Expand Down Expand Up @@ -52,11 +67,6 @@ public HDBSCANParameters copy() {
.setNormalizer(norm)
.setForceParallel(parallel);
}

@Override
public int getMinPts() {
return minPts;
}

public HDBSCAN_Algorithm getAlgo() {
return this.algo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/clust4j/algo/KMeansParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/clust4j/algo/KMedoidsParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/clust4j/algo/MeanShift.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.commons.math3.util.FastMath;

import com.clust4j.algo.NearestNeighborsParameters;
import com.clust4j.algo.NearestNeighborHeapSearch.Neighborhood;
import com.clust4j.algo.Neighborhood;
import com.clust4j.algo.RadiusNeighborsParameters;
import com.clust4j.except.IllegalClusterStateException;
import com.clust4j.except.ModelNotFitException;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/clust4j/algo/MeanShiftParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/clust4j/algo/NearestCentroidParameters.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*******************************************************************************
* Copyright 2015, 2016 Taylor G Smith
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.clust4j.algo;

import java.util.Random;
Expand Down
Loading

0 comments on commit e4ca1e1

Please sign in to comment.