Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code reorganization #183

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f155b09
Merge pull request #2 from aosojnik/multitarget
aosojnik Nov 9, 2015
5c49882
Added some classifiers for multi-label classification
aosojnik Nov 9, 2015
6715ccf
Updates to multi-label methods
aosojnik Nov 9, 2015
fedd0d2
Cosmetic changes (fixed indentation)
aosojnik Nov 9, 2015
a94c96f
Merge branch 'master' of https://github.com/aosojnik/moa
aosojnik Nov 9, 2015
4e3116a
Removed merging artefacts
aosojnik Nov 9, 2015
5dec8c1
Additional merging artefacts fixed
aosojnik Nov 9, 2015
02d2683
Test commit of everything
aosojnik Nov 9, 2015
8e867c3
Revert "Test commit of everything"
aosojnik Nov 9, 2015
4436a24
Revert "Additional merging artefacts fixed"
aosojnik Nov 9, 2015
296844e
Revert "Removed merging artefacts"
aosojnik Nov 9, 2015
562350e
Updates with the new versions of the algorithms (some code is imported
aosojnik Nov 13, 2015
0f8677b
Merge pull request #8 from Waikato/master
abifet Mar 9, 2016
483366b
Intermediary commit for multi-label changes
aosojnik Mar 23, 2016
a78b6f3
Merge branch 'master' of https://github.com/abifet/moa
aosojnik Mar 23, 2016
df564f7
Merge branch 'master' of https://github.com/Waikato/moa
aosojnik Mar 23, 2016
60b81db
Instance, InstanceHeader, ArffReader, etc. rework
aosojnik Mar 24, 2016
3dfb80b
AttributeInformation streamlining and other fixes
aosojnik Mar 24, 2016
66c988f
Instances rework, new iSOUPTree models and import cleanup
aosojnik Jan 10, 2017
16f1214
Commit before cleanup
Jun 13, 2017
4d7a7a2
Added some classifiers for multi-label classification
aosojnik Nov 9, 2015
1cebdab
Updates to multi-label methods
aosojnik Nov 9, 2015
12f6b0c
Removed merging artefacts
aosojnik Nov 9, 2015
3bcb756
Additional merging artefacts fixed
aosojnik Nov 9, 2015
458ac70
Test commit of everything
aosojnik Nov 9, 2015
a40904d
Revert "Test commit of everything"
aosojnik Nov 9, 2015
5a48cb8
Revert "Additional merging artefacts fixed"
aosojnik Nov 9, 2015
e4f2eb6
Revert "Removed merging artefacts"
aosojnik Nov 9, 2015
b6037c6
Updates with the new versions of the algorithms (some code is imported
aosojnik Nov 13, 2015
1b6cdbf
Intermediary commit for multi-label changes
aosojnik Mar 23, 2016
90e39b2
Instance, InstanceHeader, ArffReader, etc. rework
aosojnik Mar 24, 2016
c4a4691
AttributeInformation streamlining and other fixes
aosojnik Mar 24, 2016
bdffa94
Instances rework, new iSOUPTree models and import cleanup
aosojnik Jan 10, 2017
32d534d
Commit before cleanup
Jun 13, 2017
d16bae0
Merge branch 'master' of https://github.com/aosojnik/moa into
aosojnik Jul 2, 2017
5c0c858
Learner, Prediction rework
aosojnik Jul 2, 2017
374ba36
Removed merging artifacts
Jul 3, 2017
e3549e9
Transitional commit
aosojnik Apr 17, 2018
f916c86
Merge with waikato/moa & bugfixes
aosojnik Sep 13, 2019
7d880aa
Merge with waikato/moa 2019-09
aosojnik Sep 13, 2019
5e8945e
Code reorganization
aosojnik Sep 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cosmetic changes (fixed indentation)
  • Loading branch information
aosojnik committed Nov 9, 2015
commit fedd0d2a8e23b838b85a43e006124b43177d94f2
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@
*
*/
public class MultilabelHoeffdingTree extends HoeffdingTreeClassifLeaves implements MultiLabelLearner, MultiTargetRegressor {
// Needs to use InfoGainSplitCriterionMultiLabel, since multilabel entropy is calculated in a different way
// Trains a mlinstance adding statistics of several class values and training node classifiers
// Get votes from the training node classifier
// Needs to use InfoGainSplitCriterionMultiLabel, since multilabel entropy is calculated in a different way
// Trains a mlinstance adding statistics of several class values and training node classifiers
// Get votes from the training node classifier

private static final long serialVersionUID = 1L;

public int m_L = -1;

// Converts multi-label format to single-label format
//protected Converter converter = null;

@Override
public void setModelContext(InstancesHeader raw_header) {
//set the multilabel model context
this.modelContext = raw_header;
}

@Override
@Override
public Prediction getPredictionForInstance(Example<Instance> example) {
return getPredictionForInstance((MultiLabelInstance)example.getData());
}
@Override

@Override
public Prediction getPredictionForInstance(MultiLabelInstance instance) {

double[] predictionArray = this.getVotesForInstance(instance);
Expand Down Expand Up @@ -100,17 +100,17 @@ public void learnFromInstance(Instance inst, HoeffdingTree ht) {
}
}
}

// It uses classifier at nodes, and to be able to train with several class values
public class MultilabelLearningNodeClassifier extends LearningNodeClassifier {

//protected Classifier classifier;

private static final long serialVersionUID = 1L;

public MultilabelLearningNodeClassifier(double[] initialClassObservations, Classifier cl, MultilabelHoeffdingTree ht ) {
super(initialClassObservations);

if (cl== null) {
this.classifier = ((Classifier) getPreparedClassOption(ht.learnerOption)).copy();
this.classifier.resetLearning();
Expand All @@ -136,13 +136,13 @@ public double[] getClassVotes(Instance inst, HoeffdingTree ht) {
public void disableAttribute(int attIndex) {
// should not disable poor atts - they are used in NB calc
}

public Classifier getClassifier() {
return this.classifier;
}

//It uses different class values
@Override
@Override
public void learnFromInstance(Instance mlinst, HoeffdingTree ht) {
this.classifier.trainOnInstance(mlinst);
MultilabelHoeffdingTree mht = ((MultilabelHoeffdingTree) ht);
Expand All @@ -152,7 +152,7 @@ public void learnFromInstance(Instance mlinst, HoeffdingTree ht) {
}
Instance inst = mlinst; //mht.converter.formatInstance(mlinst);
for (int i = 0; i < inst.numInputAttributes(); i++) {
//for (int i = 1; i < inst.numAttributes(); i++) {
//for (int i = 1; i < inst.numAttributes(); i++) {
int instAttIndex = inst.inputAttribute(i).index(); //modelAttIndexToInstanceAttIndex(i, inst);
AttributeClassObserver obs = this.attributeObservers.get(instAttIndex); //i
if (obs == null) {
Expand All @@ -176,13 +176,13 @@ protected LearningNode newLearningNode(double[] initialClassObservations) {
// Create new Learning Node null
return new MultilabelLearningNodeClassifier(initialClassObservations,null,this);
}

//@Override
protected LearningNode newLearningNode(double[] initialClassObservations, Classifier cl) {
// Create new Learning Node
return new MultilabelLearningNodeClassifier(initialClassObservations,cl,this);
}

//It uses MultilabelInactiveLearningNode since there are several class values
@Override
protected void deactivateLearningNode(ActiveLearningNode toDeactivate,
Expand Down Expand Up @@ -229,21 +229,21 @@ public double[] getVotesForInstance(Instance inst) {
// Return empty array (this should only happen once! -- before we build the root node).
return new double[this.m_L];
}


@Override
public void trainOnInstanceImpl(MultiLabelInstance instance) {
trainOnInstanceImpl((Instance) instance);
}
private List<Integer> getRelevantLabels(Instance x) {
List<Integer> classValues = new LinkedList<Integer>();
//get all class attributes
for (int j = 0; j < m_L; j++) {
if (x.value(j) > 0.0) {
classValues.add(j);
}
}
return classValues;
}
trainOnInstanceImpl((Instance) instance);
}

private List<Integer> getRelevantLabels(Instance x) {
List<Integer> classValues = new LinkedList<Integer>();
//get all class attributes
for (int j = 0; j < m_L; j++) {
if (x.value(j) > 0.0) {
classValues.add(j);
}
}
return classValues;
}
}
Loading