Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
JCL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lafabregue
JCL
Commits
b8f42088
Commit
b8f42088
authored
Jun 27, 2018
by
lafabregue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add agent constrained samarah
parent
f960b309
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
780 additions
and
171 deletions
+780
-171
JCL_CookBook.pdf
JCL_CookBook.pdf
+0
-0
lib/weka.jar
lib/weka.jar
+0
-0
src/jcl/clustering/Cluster.java
src/jcl/clustering/Cluster.java
+10
-5
src/jcl/clustering/LightCluster.java
src/jcl/clustering/LightCluster.java
+5
-4
src/jcl/clustering/SimpleCluster.java
src/jcl/clustering/SimpleCluster.java
+23
-14
src/jcl/data/attribute/AttributeMultiDimSequence.java
src/jcl/data/attribute/AttributeMultiDimSequence.java
+12
-4
src/jcl/evaluation/clustering/ClusteringEvaluation.java
src/jcl/evaluation/clustering/ClusteringEvaluation.java
+23
-6
src/jcl/examples/Kmeans.java
src/jcl/examples/Kmeans.java
+10
-11
src/jcl/learning/LearningMethod.java
src/jcl/learning/LearningMethod.java
+69
-49
src/jcl/learning/methods/ClassifierUnified.java
src/jcl/learning/methods/ClassifierUnified.java
+8
-0
src/jcl/learning/methods/ClassifierUtils.java
src/jcl/learning/methods/ClassifierUtils.java
+5
-0
src/jcl/learning/methods/monostrategy/SingleClassification.java
...l/learning/methods/monostrategy/SingleClassification.java
+17
-2
src/jcl/learning/methods/monostrategy/ahc/ClassifierAHC.java
src/jcl/learning/methods/monostrategy/ahc/ClassifierAHC.java
+10
-6
src/jcl/learning/methods/monostrategy/cobweb/ClassifierCobweb.java
...earning/methods/monostrategy/cobweb/ClassifierCobweb.java
+8
-0
src/jcl/learning/methods/monostrategy/cure/ClassifierCure.java
...cl/learning/methods/monostrategy/cure/ClassifierCure.java
+7
-0
src/jcl/learning/methods/monostrategy/em/ClassifierEM.java
src/jcl/learning/methods/monostrategy/em/ClassifierEM.java
+7
-0
src/jcl/learning/methods/monostrategy/evidence/ClassifierEvidence.java
...ing/methods/monostrategy/evidence/ClassifierEvidence.java
+7
-0
src/jcl/learning/methods/monostrategy/gng/ClassifierGNG.java
src/jcl/learning/methods/monostrategy/gng/ClassifierGNG.java
+7
-0
src/jcl/learning/methods/monostrategy/kmeans/ClassifierKmeans.java
...earning/methods/monostrategy/kmeans/ClassifierKmeans.java
+44
-0
src/jcl/learning/methods/monostrategy/kmeans/LearningResultKmeans.java
...ing/methods/monostrategy/kmeans/LearningResultKmeans.java
+6
-0
src/jcl/learning/methods/monostrategy/kmeans/constraint/ConstraintKmeans.java
...hods/monostrategy/kmeans/constraint/ConstraintKmeans.java
+10
-6
src/jcl/learning/methods/monostrategy/kmeans/experimental2/LocalKmeans.java
...ethods/monostrategy/kmeans/experimental2/LocalKmeans.java
+7
-0
src/jcl/learning/methods/monostrategy/kmeans/experimentals/HiddenKmeans.java
...thods/monostrategy/kmeans/experimentals/HiddenKmeans.java
+10
-6
src/jcl/learning/methods/monostrategy/kmeans/genetic/ClassifierKmeansGenetic.java
.../monostrategy/kmeans/genetic/ClassifierKmeansGenetic.java
+8
-0
src/jcl/learning/methods/monostrategy/kmeans/seeded/SeededKmeans.java
...ning/methods/monostrategy/kmeans/seeded/SeededKmeans.java
+10
-6
src/jcl/learning/methods/monostrategy/kmedoids/ClassifierKmedoids.java
...ing/methods/monostrategy/kmedoids/ClassifierKmedoids.java
+8
-0
src/jcl/learning/methods/monostrategy/perceptron/ClassifierPerceptron.java
...methods/monostrategy/perceptron/ClassifierPerceptron.java
+7
-0
src/jcl/learning/methods/monostrategy/random/ClassifierRandom.java
...earning/methods/monostrategy/random/ClassifierRandom.java
+7
-0
src/jcl/learning/methods/monostrategy/som/ClassifierSOM.java
src/jcl/learning/methods/monostrategy/som/ClassifierSOM.java
+7
-0
src/jcl/learning/methods/monostrategy/wrapper/featureRanking/WrapperFeatureRanking.java
...trategy/wrapper/featureRanking/WrapperFeatureRanking.java
+12
-4
src/jcl/learning/methods/multistrategy/evosamarah/gealversion/ClassifierEvoSamarah.java
...strategy/evosamarah/gealversion/ClassifierEvoSamarah.java
+10
-6
src/jcl/learning/methods/multistrategy/evosamarah/gealversioncoevo/ClassifierCoEvoSamarah.java
...y/evosamarah/gealversioncoevo/ClassifierCoEvoSamarah.java
+10
-6
src/jcl/learning/methods/multistrategy/modular/ClassifierModular.java
...ning/methods/multistrategy/modular/ClassifierModular.java
+7
-0
src/jcl/learning/methods/multistrategy/modular/maclac/ClassifierMaclac.java
...ethods/multistrategy/modular/maclac/ClassifierMaclac.java
+10
-0
src/jcl/learning/methods/multistrategy/samarah/HybridClassification.java
...g/methods/multistrategy/samarah/HybridClassification.java
+41
-17
src/jcl/learning/methods/multistrategy/samarah/LearningAgent.java
...learning/methods/multistrategy/samarah/LearningAgent.java
+15
-0
src/jcl/learning/methods/multistrategy/samarahConstrained/HybridClassification.java
...ultistrategy/samarahConstrained/HybridClassification.java
+266
-0
src/jcl/utils/RandomizeTools.java
src/jcl/utils/RandomizeTools.java
+1
-1
src/jcl/utils/io/JCLModelExchange.java
src/jcl/utils/io/JCLModelExchange.java
+56
-18
No files found.
JCL_CookBook.pdf
0 → 100644
View file @
b8f42088
File added
lib/weka.jar
View file @
b8f42088
No preview for this file type
src/jcl/clustering/Cluster.java
View file @
b8f42088
...
...
@@ -6,6 +6,7 @@ import java.io.Serializable;
import
jcl.data.Data
;
import
jcl.data.DataObject
;
import
jcl.weights.Weights
;
import
multiCube.tools.util.exceptions.MethodNotImplementedException
;
/**
* <p>
...
...
@@ -28,7 +29,7 @@ abstract public class Cluster implements Serializable {
protected
Color
color
=
new
Color
(
0
);
/** The cluster's father node color*/
protected
Color
couleur_pere
=
n
ew
Color
(
0
)
;
protected
Color
couleur_pere
=
n
ull
;
/** L'index qui correspond a la place du cluster dans result */
protected
int
id
=
-
1
;
...
...
@@ -204,17 +205,21 @@ abstract public class Cluster implements Serializable {
*
* @param o
* l'index de l'objet
* @return le degre d'appartenance du o-ieme objet e la classe
* @return le degre d'appartenance du o-ieme objet e la classe *
* @throws MethodNotImplementedException
* si la methode n'implante pas cet operateur
*/
abstract
public
double
getMembership
(
final
int
o
);
abstract
public
double
getMembership
(
final
int
o
)
throws
MethodNotImplementedException
;
/**
* <p>
* Probabilite de la classe.
* </p>
*
* @return la probabilite de la classe
* @return la probabilite de la classe *
* @throws MethodNotImplementedException
* si la methode n'implante pas cet operateur
*/
abstract
public
double
getMembershipProbabilityEM
();
abstract
public
double
getMembershipProbabilityEM
()
throws
MethodNotImplementedException
;
/**
* <p>
...
...
src/jcl/clustering/LightCluster.java
View file @
b8f42088
...
...
@@ -7,6 +7,7 @@ import jcl.data.mask.IntArrayMask.IntMaskIterator;
import
jcl.data.mask.Mask
;
import
jcl.weights.Weights
;
import
jj2000.j2k.NotImplementedError
;
import
multiCube.tools.util.exceptions.MethodNotImplementedException
;
public
class
LightCluster
extends
Cluster
{
...
...
@@ -147,13 +148,13 @@ public class LightCluster extends Cluster {
@Override
public
double
getMembership
(
int
o
)
{
throw
new
NotImplementedError
(
"method not Implemented for LighCluster class"
);
public
double
getMembership
(
int
o
)
throws
MethodNotImplementedException
{
throw
new
MethodNotImplementedException
(
"method not Implemented for LighCluster class"
);
}
@Override
public
double
getMembershipProbabilityEM
()
{
throw
new
NotImplementedError
(
"method not Implemented for LighCluster class"
);
public
double
getMembershipProbabilityEM
()
throws
MethodNotImplementedException
{
throw
new
MethodNotImplementedException
(
"method not Implemented for LighCluster class"
);
}
@Override
...
...
src/jcl/clustering/SimpleCluster.java
View file @
b8f42088
...
...
@@ -6,6 +6,7 @@ import jcl.data.Data;
import
jcl.data.DataObject
;
import
jcl.data.SimpleData
;
import
jcl.weights.Weights
;
import
multiCube.tools.util.exceptions.MethodNotImplementedException
;
/**
* <p>
...
...
@@ -44,7 +45,11 @@ public class SimpleCluster extends Cluster {
}
this
.
membershipDegree
=
new
double
[
cluster
.
membershipDegree
.
length
];
for
(
int
i
=
0
;
i
<
this
.
membershipDegree
.
length
;
i
++)
{
this
.
membershipDegree
[
i
]
=
cluster
.
getMembership
(
i
);
try
{
this
.
membershipDegree
[
i
]
=
cluster
.
getMembership
(
i
);
}
catch
(
MethodNotImplementedException
e
)
{
e
.
printStackTrace
();
}
}
this
.
membershipProbabilityEM
=
cluster
.
membershipProbabilityEM
;
}
...
...
@@ -230,18 +235,22 @@ public class SimpleCluster extends Cluster {
this
.
data
=
(
Data
)
cluster
.
getData
(
fromSample
).
clone
();
}
if
(
cluster
instanceof
SimpleCluster
)
{
this
.
membershipDegree
=
new
double
[((
SimpleCluster
)
cluster
).
membershipDegree
.
length
];
for
(
int
i
=
0
;
i
<
this
.
membershipDegree
.
length
;
i
++)
{
this
.
membershipDegree
[
i
]
=
cluster
.
getMembership
(
i
);
}
this
.
membershipProbabilityEM
=
((
SimpleCluster
)
cluster
).
membershipProbabilityEM
;
}
else
{
this
.
membershipDegree
=
new
double
[
cluster
.
getCard
()];
for
(
int
i
=
0
;
i
<
this
.
membershipDegree
.
length
;
i
++)
{
this
.
membershipDegree
[
i
]
=
cluster
.
getMembership
(
i
);
try
{
if
(
cluster
instanceof
SimpleCluster
)
{
this
.
membershipDegree
=
new
double
[((
SimpleCluster
)
cluster
).
membershipDegree
.
length
];
for
(
int
i
=
0
;
i
<
this
.
membershipDegree
.
length
;
i
++)
{
this
.
membershipDegree
[
i
]
=
cluster
.
getMembership
(
i
);
}
this
.
membershipProbabilityEM
=
((
SimpleCluster
)
cluster
).
membershipProbabilityEM
;
}
else
{
this
.
membershipDegree
=
new
double
[
cluster
.
getCard
()];
for
(
int
i
=
0
;
i
<
this
.
membershipDegree
.
length
;
i
++)
{
this
.
membershipDegree
[
i
]
=
cluster
.
getMembership
(
i
);
}
}
}
catch
(
MethodNotImplementedException
e
)
{
e
.
printStackTrace
();
}
if
(
this
.
clusterCenter
==
null
)
...
...
@@ -322,7 +331,7 @@ public class SimpleCluster extends Cluster {
* l'index de l'objet
* @return le degre d'appartenance du o-ieme objet e la classe
*/
public
double
getMembership
(
final
int
o
)
{
public
double
getMembership
(
final
int
o
)
throws
MethodNotImplementedException
{
double
degree
=
0
;
if
((
o
>=
0
)
&&
(
o
<
this
.
membershipDegree
.
length
))
{
degree
=
this
.
membershipDegree
[
o
];
...
...
@@ -337,7 +346,7 @@ public class SimpleCluster extends Cluster {
*
* @return la probabilite de la classe
*/
public
double
getMembershipProbabilityEM
()
{
public
double
getMembershipProbabilityEM
()
throws
MethodNotImplementedException
{
return
this
.
membershipProbabilityEM
;
}
...
...
src/jcl/data/attribute/AttributeMultiDimSequence.java
View file @
b8f42088
...
...
@@ -853,7 +853,7 @@ public class AttributeMultiDimSequence extends Attribute {
}
public static int ArgMin3(final double a, final double b, final double c) {
return (a <
b) ? ((a < c) ? 0 : 2) : (b <
c) ? 1 : 2;
return (a <
= b) ? ((a <= c) ? 0 : 2) : (b <=
c) ? 1 : 2;
}
public static int getMode() {
...
...
@@ -3351,8 +3351,11 @@ public class AttributeMultiDimSequence extends Attribute {
// AttributeMultiDimSequence seq1 = new AttributeMultiDimSequence(new double[][] { { 1.0 }, { 10.0 }, { 10.0 }, { 10.0 }, { 1.0 }, { 1.0 }, {
// 1.0 } });
// AttributeMultiDimSequence seq2 = new AttributeMultiDimSequence(new double[][] { { 1.0 }, { 1.0 }, { 1.0 }, { 10.0 }, { 1.0 } });
AttributeMultiDimSequence seq1 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 1.0 }, { 1.0 }, { 0.0 } });
AttributeMultiDimSequence seq2 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 1.0 }, { 0.0 }, { 0.0 } });
AttributeMultiDimSequence seq1 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 3.0 }, { 1.0 } });
AttributeMultiDimSequence seq2 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 3.0 }, { 1.0 }, { 0.0 } });
AttributeMultiDimSequence seq3 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 3.0 }, { 3.0 }, { 1.0 } });
AttributeMultiDimSequence seq4 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 1.0 }, { 1.0 }, { 1.0 }, { 0.0 } });
AttributeMultiDimSequence seq5 = new AttributeMultiDimSequence(new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 3.0 }, { 0.0 } });
// System.out.println(DTWPageRank(seq1, seq2));
// System.out.println(DTWDistanceToDiagonal(seq1, seq2));
// System.out.println(DTWDistanceToDiagonal(seq2, seq1));
...
...
@@ -3365,7 +3368,12 @@ public class AttributeMultiDimSequence extends Attribute {
// System.out.println(DTWDatedTimeToGo(seq1, new short[] { 0, 2, 3, 4 }, seq2, new short[] { 0, 1, 2, 3, 4 }));
// System.out.println(DTWDatedMeanSpeed(seq1, new short[] { 0, 2, 3, 4 }, seq2, new short[] { 0, 1, 2, 3, 4 }));
AttributeMultiDimSequence.setMode(DTW_BARYCENTRE);
System.out.println(seq1.distance(seq2));
// System.out.println(seq1.distance(seq2));
AttributeMultiDimSequence[] tabSequence = { seq1, seq2, seq3, seq4, seq5 };
AttributeMultiDimSequence avg = DBAMean(seq2, tabSequence);
System.out.println("DBA mean : " +avg);
}
...
...
src/jcl/evaluation/clustering/ClusteringEvaluation.java
View file @
b8f42088
...
...
@@ -13,6 +13,7 @@ import jcl.data.DataObject;
import
jcl.evaluation.QualityIndex
;
import
jcl.utils.MathTools
;
import
jcl.weights.Weights
;
import
multiCube.tools.util.exceptions.MethodNotImplementedException
;
/**
* @author Alexandre BLANSCHE
...
...
@@ -544,7 +545,11 @@ public class ClusteringEvaluation {
int
i
=
0
;
while
(
iter
.
hasNext
())
{
final
double
distance
=
cluster
.
distance
(
iter
.
next
());
sum
+=
distance
*
distance
*
cluster
.
getMembership
(
i
);
try
{
sum
+=
distance
*
distance
*
cluster
.
getMembership
(
i
);
}
catch
(
MethodNotImplementedException
e
)
{
e
.
printStackTrace
();
}
i
++;
}
...
...
@@ -608,9 +613,13 @@ public class ClusteringEvaluation {
for
(
int
i
=
0
;
i
<
clusteringResult
.
getNbObjects
();
i
++)
{
double
proba
=
0
;
for
(
int
k
=
0
;
k
<
clusteringResult
.
getNbClusters
();
k
++)
{
proba
+=
clusteringResult
.
getCluster
(
k
)
.
getMembershipProbabilityEM
()
*
clusteringResult
.
getCluster
(
k
).
getMembership
(
i
);
try
{
proba
+=
clusteringResult
.
getCluster
(
k
)
.
getMembershipProbabilityEM
()
*
clusteringResult
.
getCluster
(
k
).
getMembership
(
i
);
}
catch
(
MethodNotImplementedException
e
)
{
e
.
printStackTrace
();
}
}
sum
+=
Math
.
log
(
proba
);
}
...
...
@@ -757,7 +766,11 @@ public class ClusteringEvaluation {
for
(
int
i
=
0
;
i
<
clusteringResult
.
getNbObjects
();
i
++)
{
double
sum
=
0
;
for
(
int
k
=
0
;
k
<
membership
.
length
;
k
++)
{
membership
[
k
]
=
clusteringResult
.
getCluster
(
k
).
getMembership
(
i
);
try
{
membership
[
k
]
=
clusteringResult
.
getCluster
(
k
).
getMembership
(
i
);
}
catch
(
MethodNotImplementedException
e
)
{
e
.
printStackTrace
();
}
sum
+=
membership
[
k
];
}
for
(
int
k
=
0
;
k
<
membership
.
length
;
k
++)
{
...
...
@@ -1016,7 +1029,11 @@ public class ClusteringEvaluation {
for
(
int
i
=
0
;
i
<
clusteringResult
.
getNbObjects
();
i
++)
{
double
sum
=
0
;
for
(
int
k
=
0
;
k
<
membership
.
length
;
k
++)
{
membership
[
k
]
=
clusteringResult
.
getCluster
(
k
).
getMembership
(
i
);
try
{
membership
[
k
]
=
clusteringResult
.
getCluster
(
k
).
getMembership
(
i
);
}
catch
(
MethodNotImplementedException
e
)
{
e
.
printStackTrace
();
}
sum
+=
membership
[
k
];
}
for
(
int
k
=
0
;
k
<
membership
.
length
;
k
++)
{
...
...
src/jcl/examples/Kmeans.java
View file @
b8f42088
...
...
@@ -52,36 +52,35 @@ public class Kmeans {
Random
randGenerator
=
new
Random
();
for
(
int
i
=
0
;
i
<
NB_OBJECTS
;
i
++)
{
//~ Initialization of objects (random)
Attribute
[]
attributes
=
new
Attribute
[
2
];
Attribute
[]
attributes
=
new
Attribute
[
1
];
if
(
randGenerator
.
nextDouble
()
<
0.5
)
{
// first cluster
attributes
[
0
]
=
new
AttributeNumerical
(
randGenerator
.
nextGaussian
()
+
.
5
);
//
attributes[0] = new AttributeNumerical(randGenerator.nextGaussian() + .5);
double
[]
sequence
=
new
double
[
SEQUENCE_LENGTH
];
for
(
int
l
=
0
;
l
<
sequence
.
length
;
l
++)
{
double
p
=
l
+
randGenerator
.
nextGaussian
();
sequence
[
l
]
=
cos
(
p
/
SEQUENCE_LENGTH
*
2
*
PI
);
}
attributes
[
1
]
=
new
AttributeSequence
(
sequence
);
attributes
[
0
]
=
new
AttributeSequence
(
sequence
);
}
else
{
attributes
[
0
]
=
new
AttributeNumerical
(
randGenerator
.
nextGaussian
()
-
.
5
);
//
attributes[0] = new AttributeNumerical(randGenerator.nextGaussian() - .5);
double
[]
sequence
=
new
double
[
SEQUENCE_LENGTH
];
for
(
int
l
=
0
;
l
<
sequence
.
length
;
l
++)
{
double
p
=
l
+
randGenerator
.
nextGaussian
();
sequence
[
l
]
=
sin
(
p
/
SEQUENCE_LENGTH
*
2
*
PI
);
}
attributes
[
1
]
=
new
AttributeSequence
(
sequence
);
attributes
[
0
]
=
new
AttributeSequence
(
sequence
);
}
objects
.
add
(
new
DataObject
(
attributes
));
}
//~ In order to create a dataset, a model of comparison has to be set
Distance
[]
distances
=
new
Distance
[
2
];
// a distance is set for every attribute
distances
[
0
]
=
NumericalEuclideanDistance
.
getInstance
();
// first attribute compared with an euclidean distance between numericals
distances
[
1
]
=
jcl
.
data
.
distance
.
sequential
.
DistanceDTW
.
getInstance
();
// second attribute (sequential) compared with the DTW distance
Distance
[]
distances
=
new
Distance
[
1
];
// a distance is set for every attribute
//
distances[0] = NumericalEuclideanDistance.getInstance(); // first attribute compared with an euclidean distance between numericals
distances
[
0
]
=
jcl
.
data
.
distance
.
sequential
.
DistanceDTW
.
getInstance
();
// second attribute (sequential) compared with the DTW distance
MetaDistance
metaDistance
=
MetaDistanceEuclidean
.
getInstance
();
// defines the way the two scores are combined (possibility to weight)
Model
model
=
new
Model
(
distances
,
metaDistance
);
...
...
@@ -94,8 +93,8 @@ public class Kmeans {
DistanceParameter
[][]
distanceParameters
=
new
DistanceParameter
[
NB_THREADS
][
2
];
for
(
int
th
=
0
;
th
<
NB_THREADS
;
th
++)
{
distanceParameters
[
th
][
0
]
=
EmptyDistanceParameter
.
getInstance
();
//no parameter for a numerical euclidean distance
distanceParameters
[
th
][
1
]
=
new
ParameterDTW
(
new
double
[
SEQUENCE_LENGTH
][
SEQUENCE_LENGTH
]);
//but yes for DTW (requires a matrix to work in)
//
distanceParameters[th][0] = EmptyDistanceParameter.getInstance(); //no parameter for a numerical euclidean distance
distanceParameters
[
th
][
0
]
=
new
ParameterDTW
(
new
double
[
SEQUENCE_LENGTH
][
SEQUENCE_LENGTH
]);
//but yes for DTW (requires a matrix to work in)
}
param
=
new
ParametersKmeans
(
NB_CLUSTERS
,
NB_TURNS
,
NB_THREADS
,
new
GlobalWeights
(
dataset
),
distanceParameters
);
...
...
src/jcl/learning/LearningMethod.java
View file @
b8f42088
...
...
@@ -8,6 +8,7 @@ import java.util.Vector;
import
javax.swing.JPanel
;
import
jcl.clustering.ClusteringResult
;
import
jcl.clustering.constraints.Constraint
;
import
jcl.data.Data
;
import
jcl.jcld.RmiServer
;
import
jcl.jcld.database.SSHParameters
;
...
...
@@ -277,60 +278,103 @@ public abstract class LearningMethod implements Progressable, Cloneable,
/**
* <p>
* Method
e de fusion d'un ensemble de classes.
* Method
to merge a set of clusters
* </p>
*
* @param learningResult
* resultat d'apprentissage
*
* the learned model
* @param result
*
le resultat e modifier
*
the result to modify
* @param data
*
les donnees d'apprentrissage
*
the data to train the model on
* @param cr
*
l'ensemble des classes representatives e fusionner
* @return
le resultat modifie
*
the set of clusters to merge
* @return
the modified result
* @throws MethodNotImplementedException
*
si la methode n'implante pas cet operateur
*
if the LearningMethod does not implement this method
*/
public
abstract
ClusteringResult
merge
(
LearningResult
learningResult
,
ClusteringResult
result
,
Data
data
,
Vector
cr
)
throws
MethodNotImplementedException
;
/**
*
affichage dans la console, deux cas possible: execution local, algorithme
*
effetue par le client, affichage direct. execution deporte, renvoie du
*
resultat par RMI
*
<p>
*
Method to split a cluster
*
</p>
*
* @param s
* @param learningResult
* the learned model
* @param result
* the result to modify
* @param data
* the data to train the model on
* @param c
* the cluster to remove id
* @param n
* the number of cluster to split the cluster into
* @return the modified result
* @throws MethodNotImplementedException
* if the LearningMethod does not implement this method
*/
public
void
print
(
final
String
s
)
{
for
(
int
i
=
0
;
i
<
this
.
viewers
.
size
();
i
++)
{
this
.
viewers
.
get
(
i
).
print
(
s
);
}
}
public
abstract
ClusteringResult
split
(
LearningResult
learningResult
,
ClusteringResult
result
,
Data
data
,
int
c
,
int
n
)
throws
MethodNotImplementedException
;
/**
* <p>
* Methode de suppresion d'une classe.
* Method to remove a cluster a classify its element
* in the other ones
* </p>
*
* @param learningResult
* resultat d'apprentissage
*
* the learned model
* @param result
*
le resultat a modifier
*
the result to modify
* @param data
*
les donnees d'apprentrissage
*
the data to train the model on
* @param c
*
le numero de la classe a supprimer
* @return
le resultat modifie
*
the cluster to remove id
* @return
the modified result
* @throws MethodNotImplementedException
*
si la methode d'apprentissage n'implante pas cet operateur
*
if the LearningMethod does not implement this method
*/
public
abstract
ClusteringResult
reclass
(
LearningResult
learningResult
,
ClusteringResult
result
,
Data
data
,
int
c
)
throws
MethodNotImplementedException
;
/**
* <p>
* Method to compute a new clustering from the existing one that respect the constraints
* </p>
*
* @param learningResult
* the learned model
* @param result
* the result to modify
* @param data
* the data to train the model on
* @param constraints
* the set of Constraints to use
* @return the modified result
* @throws MethodNotImplementedException
* if the LearningMethod does not implement this method
*/
public
abstract
ClusteringResult
injectConstraints
(
LearningResult
learningResult
,
ClusteringResult
result
,
Data
data
,
Vector
<
Constraint
>
constraints
)
throws
MethodNotImplementedException
;
/**
* affichage dans la console, deux cas possible: execution local, algorithme
* effetue par le client, affichage direct. execution deporte, renvoie du
* resultat par RMI
*
* @param s
*/
public
void
print
(
final
String
s
)
{
for
(
int
i
=
0
;
i
<
this
.
viewers
.
size
();
i
++)
{
this
.
viewers
.
get
(
i
).
print
(
s
);
}
}
/**
* <p>
...
...
@@ -381,30 +425,6 @@ public abstract class LearningMethod implements Progressable, Cloneable,
return
statusName
;
}
/**
* <p>
* Methode de decoupage d'une classe en sous-classes.
* </p>
*
* @param learningResult
* le resultat d'apprentissage
* @param result
* le resultat a modifier
* @param data
* les donnees d'apprentissage
* @param c
* le numero de la classe a scinder
* @param n
* le nombre de sous-classes desire
* @return le resultat modifie
* @throws MethodNotImplementedException
* si la methode d'apprentissage n'implante pas cet operateur
*/
public
abstract
ClusteringResult
split
(
LearningResult
learningResult
,
ClusteringResult
result
,
Data
data
,
int
c
,
int
n
)
throws
MethodNotImplementedException
;
@Override
public
String
toString
()
{
return
this
.
getStringParams
();
...
...
src/jcl/learning/methods/ClassifierUnified.java
View file @
b8f42088
...
...
@@ -3,10 +3,12 @@ package jcl.learning.methods;
import
java.util.Vector
;
import
jcl.clustering.ClusteringResult
;
import
jcl.clustering.constraints.Constraint
;
import
jcl.data.Data
;
import
jcl.learning.LearningMethod
;
import
jcl.learning.LearningParameters
;
import
jcl.learning.LearningResult
;
import
multiCube.tools.util.exceptions.MethodNotImplementedException
;
/**
* <p>
...
...
@@ -165,4 +167,10 @@ public class ClassifierUnified extends LearningMethod implements Cloneable {
"Method split() not yet implemented."
);
}
@Override
public
ClusteringResult
injectConstraints
(
LearningResult
learningResult
,
ClusteringResult
result
,
Data
data
,
Vector
<
Constraint
>
constraints
)
throws
MethodNotImplementedException
{
throw
new
MethodNotImplementedException
();
}
}
src/jcl/learning/methods/ClassifierUtils.java
View file @
b8f42088
...
...
@@ -87,6 +87,11 @@ public class ClassifierUtils {
*/
public
final
static
int
SAMARAHV4
=
121
;
/**
* Identification of the SMARAH algorithm where constraints are handled at agent level
*/
public
final
static
int
SAMARAH_CONSTRAINED
=
122
;
public
final
static
int
MACLAW
=
125
;
/**
* Constante representant un classifieur SAMARAH : Ne pas modifier car correspond à l'indice de
...
...
src/jcl/learning/methods/monostrategy/SingleClassification.java
View file @
b8f42088
...
...
@@ -7,7 +7,6 @@ import java.io.IOException;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Vector
;
import
javax.naming.Context
;
...
...
@@ -17,6 +16,7 @@ import javax.swing.JOptionPane;
import
jcl.Classification
;
import
jcl.clustering.Cluster
;
import
jcl.clustering.ClusteringResult
;
import
jcl.clustering.constraints.Constraint
;
import
jcl.data.Data
;
import
jcl.data.SimpleData
;
import
jcl.jcld.interJcld
;
...
...
@@ -27,7 +27,6 @@ import jcl.learning.methods.ClassifierUtils;
import
jcl.learning.methods.monostrategy.ahc.LearningResultAHC
;
import
jcl.learning.methods.monostrategy.ahc.ParametersAHC
;
import
jcl.learning.methods.monostrategy.kmeans.LearningResultKmeans
;
import
jcl.utils.Progressable
;
import
jcl.utils.exceptions.JCLFormatException
;
import
jcl.weights.ClassificationWeights
;
import
multiCube.tools.util.exceptions.MethodNotImplementedException
;
...
...
@@ -490,6 +489,22 @@ public class SingleClassification extends Classification {
}
}
/**
* Compute a new clustering from the existing one that respect the constraints
* @param constraints
* the set of Constraints to use
* @throws MethodNotImplementedException
* if the LearningMethod does not implement this method
*/
public
void
injectConstraints
(
Vector
<
Constraint
>
constraints
)
throws
MethodNotImplementedException
{
if
(
this
.
getClusteringResult
()
!=
null
)
{
this
.
clusteringResult
=
this
.
getLearningMethod
().
injectConstraints
(
this
.
getLearningResult
(),
this
.
getClusteringResult
(),
this
.
classificationData
,
constraints
);
}
}
@Override
public
void
save
(
final
String
file
)
throws
IOException
{
...
...
src/jcl/learning/methods/monostrategy/ahc/ClassifierAHC.java
View file @
b8f42088
...
...
@@ -4,6 +4,7 @@ import java.util.Iterator;
import
java.util.Vector
;
import
jcl.clustering.ClusteringResult
;
import
jcl.clustering.constraints.Constraint
;
import
jcl.data.Data
;
import
jcl.data.DataObject
;
import
jcl.learning.LearningMethod
;
...
...
@@ -94,24 +95,27 @@ public class ClassifierAHC extends LearningMethod {
public
ClusteringResult
merge
(
final
LearningResult
learningResult
,
final
ClusteringResult
result
,
final
Data
data
,
final
Vector
cr
)
throws
MethodNotImplementedException
{
// TODO Auto-generated method stub
return
null
;
throw
new
MethodNotImplementedException
();
}
@Override
public
ClusteringResult
reclass
(
final
LearningResult
learningResult
,
final
ClusteringResult
result
,
final
Data
data
,
final
int
c
)
throws
MethodNotImplementedException
{
// TODO Auto-generated method stub
return
null
;
throw
new
MethodNotImplementedException
();
}
@Override
public
ClusteringResult
split
(
final
LearningResult
learningResult
,
final
ClusteringResult
result
,
final
Data
data
,
final
int
c
,
final
int
n
)
throws
MethodNotImplementedException
{
// TODO Auto-generated method stub
return
null
;
throw
new
MethodNotImplementedException
();
}
@Override
public
ClusteringResult
injectConstraints
(
LearningResult
learningResult
,
ClusteringResult
result
,
Data
data
,
Vector
<
Constraint
>
constraints
)
throws
MethodNotImplementedException
{
throw
new
MethodNotImplementedException
();
}
}
src/jcl/learning/methods/monostrategy/cobweb/ClassifierCobweb.java
View file @
b8f42088
...
...
@@ -5,11 +5,13 @@ import java.util.Iterator;
import
java.util.Vector
;
import
jcl.clustering.ClusteringResult
;
import
jcl.clustering.constraints.Constraint
;
import
jcl.data.Data
;
import
jcl.data.DataObject
;
import
jcl.learning.LearningMethod
;
import
jcl.learning.LearningResult
;
import
jcl.learning.methods.ClassifierUtils
;
import
multiCube.tools.util.exceptions.MethodNotImplementedException
;
/**
* <p>
...
...
@@ -569,6 +571,12 @@ public class ClassifierCobweb extends LearningMethod implements Cloneable,
return
resultP
;
}
@Override
public
ClusteringResult
injectConstraints
(
LearningResult
learningResult
,
ClusteringResult
result
,
Data
data
,
Vector
<
Constraint
>
constraints
)
throws
MethodNotImplementedException
{
throw
new
MethodNotImplementedException
();
}
/**
* <p>