forked from ptnplanet/Java-Naive-Bayes-Classifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Classification.java
93 lines (81 loc) · 2.14 KB
/
Classification.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package de.daslaboratorium.machinelearning.classifier;
import java.util.Collection;
/**
* A basic wrapper reflecting a classification. It will store both featureset
* and resulting classification.
*
* @author Philipp Nolte
*
* @param <T> The feature class.
* @param <K> The category class.
*/
public class Classification<T, K> {
/**
* The classified featureset.
*/
private Collection<T> featureset;
/**
* The category as which the featureset was classified.
*/
private K category;
/**
* The probability that the featureset belongs to the given category.
*/
private float probability;
/**
* Constructs a new Classification with the parameters given and a default
* probability of 1.
*
* @param featureset The featureset.
* @param category The category.
*/
public Classification(Collection<T> featureset, K category) {
this(featureset, category, 1.0f);
}
/**
* Constructs a new Classification with the parameters given.
*
* @param featureset The featureset.
* @param category The category.
* @param probability The probability.
*/
public Classification(Collection<T> featureset, K category,
float probability) {
this.featureset = featureset;
this.category = category;
this.probability = probability;
}
/**
* Retrieves the featureset classified.
*
* @return The featureset.
*/
public Collection<T> getFeatureset() {
return featureset;
}
/**
* Retrieves the classification's probability.
* @return
*/
public float getProbability() {
return this.probability;
}
/**
* Retrieves the category the featureset was classified as.
*
* @return The category.
*/
public K getCategory() {
return category;
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "Classification [category=" + this.category
+ ", probability=" + this.probability
+ ", featureset=" + this.featureset
+ "]";
}
}