public class MultiPropertyDataset extends Dataset
MultiPropertyEntry
, it
will handle the storage of these properties transparently.
Implemented Commands:
target <name> [-keep] - Set class variable to be a certain property
Implemented Save Formats:
prop: Print out the measured and predicted properties
MultiPropertyEntry
,
Serialized FormAttributeName, Entries, Expanders, Generators
Constructor and Description |
---|
MultiPropertyDataset() |
Modifier and Type | Method and Description |
---|---|
void |
addEntries(java.util.Collection<? extends BaseEntry> entries)
Add many entries to a the data set
|
void |
addEntries(Dataset otherDataset,
boolean forceMerge)
Add entries from another dataset.
|
void |
addEntry(BaseEntry e)
Add an entry.
|
void |
addProperty(java.lang.String name)
Add a new property to dataset.
|
void |
addProperty(java.lang.String name,
java.lang.String[] possibleClasses)
Add a new property to dataset.
|
void |
clearPropertyData()
Clear all property information from this dataset.
|
void |
combine(Dataset d)
Combine the dataset with another.
|
MultiPropertyDataset |
createTemplate()
Create a template designed to be saved using serialization
|
void |
definePropertyNames(java.lang.String[] names)
Define all known properties for a dataset.
|
Dataset |
emptyClone()
Creates a new instance with the same class and attribute names, but
without any entries.
|
java.lang.String[] |
getClassNames() |
MultiPropertyEntry |
getEntry(int index)
Retrieve a single entry from the dataset
|
double[] |
getMeasuredPropertyArray(int index)
Get the measured value for a certain property for all entries in the dataset.
|
double[] |
getMeasuredPropertyArray(java.lang.String PropertyName)
Get measured values for a certain property for all entries in the dataset.
|
double[] |
getPredictedPropertyArray(int index)
Get the predicted value for a certain property for all entries in the dataset.
|
double[] |
getPredictedPropertyArray(java.lang.String PropertyName)
Get predicted values for a certain property for all entries in the dataset.
|
int |
getPropertyClassCount(int index)
Get the number of classes for a certain property
|
java.lang.String[] |
getPropertyClasses(int index)
Get list of possible classes for a certain property
|
java.lang.String[] |
getPropertyClasses(java.lang.String name)
Get list of possible classes for a certain property
|
int |
getPropertyIndex(java.lang.String name)
Lookup the index of a property.
|
java.lang.String |
getPropertyName(int index)
Retrieve the name of a certain property.
|
java.lang.String[] |
getPropertyNames()
Get the names of each property stored in this dataset.
|
int |
getTargetPropertyIndex()
Get the index of the currently active property.
|
java.lang.String |
getTargetPropertyName()
Lookup what target property is being used.
|
boolean |
hasProperty(java.lang.String name)
Check whether dataset contains a certain property
|
protected double[] |
importEntryProperties(java.lang.String[] words)
Used by Dataset.importText(java.lang.String, java.lang.Object[])
to import property measurements for each entry.
|
protected void |
importPropertyNames(java.lang.String line)
Given the line describing property names in the input file, read in property
names and possible classes.
|
int |
NClasses() |
int |
NProperties() |
java.lang.Object |
runCommand(java.util.List<java.lang.Object> Command)
Process some command described by a list of Objects.
|
java.lang.String |
saveCommand(java.lang.String Basename,
java.lang.String Format)
Handles complicated saving commands.
|
void |
setClassNames(java.lang.String[] newClassNames)
Set name of class variable (or possible classes)
|
void |
setPropertyClasses(int index,
java.lang.String[] classes)
Define possible classes for a certain property (like "Metal" or "Nonmetal")
|
void |
setTargetProperty(int index,
boolean keepUnmeasured)
Define which property to set as the measured class of each entry.
|
void |
setTargetProperty(java.lang.String Property,
boolean keepUnmeasured)
Define which property to use as the class variable.
|
org.json.JSONObject |
toJSON()
Print dataset to JSON format
|
java.lang.String |
toString() |
boolean |
usingPropertyAsClass() |
about, addAttribute, addAttributeExpander, addAttributeGenerator, addAttributes, addEntry, calculateAttributes, clearAttributeExpanders, clearAttributeGenerators, clearAttributes, clearData, clone, combine, combine, containsEntry, deleteMeasuredClasses, deletePredictedClasses, finalizeGeneration, generateAttributes, getAttributeArray, getAttributeExpanders, getAttributeGenerators, getAttributeIndex, getAttributeName, getAttributeNames, getCitations, getClassName, getClassProbabilityArray, getDistribution, getDistributionCount, getDuplicates, getEntries, getEntriesWriteAccess, getEntryArray, getMeasuredClassArray, getPredictedClassArray, getRandomSplit, getRandomSplit, getRandomSplit, getRandomSplit, getRandomSubset, getRandomSubset, getSingleAttributeArray, getSubset, getTrainingExamples, getUniqueEntries, importText, loadState, matchEntries, NAttributes, NEntries, partition, partition, printAttributeDescription, printCommand, printDescription, printDistribution, printEntries, printEntryDescription, printUsage, removeDuplicates, resolveDuplicates, restoreAttributes, runAttributeCommand, runAttributeExpanders, runAttributeExpansionCommand, runAttributeGeneratorCommand, runAttributeGenerators, saveState, saveTemplate, setAttributeNames, setClassProbabilities, setMeasuredClasses, setOptions, setPredictedClasses, splitForThreading, splitIntoFolds, splitIntoFolds, subtract, transferToWeka
public Dataset emptyClone()
Dataset
emptyClone
in class Dataset
public MultiPropertyDataset createTemplate()
Dataset
createTemplate
in class Dataset
public MultiPropertyEntry getEntry(int index)
Dataset
public int NClasses()
public void addEntries(Dataset otherDataset, boolean forceMerge) throws java.lang.Exception
Entries will be cloned before adding them to this dataset.
For datasets with different properties, the final dataset will contain properties from both datasets. Entries from this datasets that lack properties from the other dataset will have no measured or predicted values for those properties. And, for entries from the other dataset that lack entries from this dataset they will have no measured or predicted values for those properties.
addEntries
in class Dataset
otherDataset
- Dataset to be added to this oneforceMerge
- Whether to force merge if attributes / class / properties are different.java.lang.Exception
- If datasets have different classes or attributes,
and forceMerge is false.public void combine(Dataset d)
public void addEntry(BaseEntry e)
Dataset
public void addEntries(java.util.Collection<? extends BaseEntry> entries)
Dataset
addEntries
in class Dataset
entries
- Any collection type of entriespublic int NProperties()
public java.lang.String[] getPropertyNames()
public java.lang.String[] getClassNames()
getClassNames
in class Dataset
public void setClassNames(java.lang.String[] newClassNames)
Dataset
setClassNames
in class Dataset
newClassNames
- New name(s) to usepublic java.lang.String getPropertyName(int index)
index
- Index of property to look uppublic int getTargetPropertyIndex()
public boolean usingPropertyAsClass()
public java.lang.String getTargetPropertyName()
public int getPropertyIndex(java.lang.String name)
name
- Name of propertypublic void setPropertyClasses(int index, java.lang.String[] classes)
index
- Index of propertyclasses
- Possible classespublic java.lang.String[] getPropertyClasses(java.lang.String name)
name
- Name of propertypublic java.lang.String[] getPropertyClasses(int index)
index
- Index of propertypublic int getPropertyClassCount(int index)
index
- Index of propertypublic boolean hasProperty(java.lang.String name)
name
- Name of propertypublic void definePropertyNames(java.lang.String[] names)
Note: This does not mean that the entries will recognize all of these properties.
You must run either MultiPropertyEntry.addProperty(double)
or
MultiPropertyEntry.setMeasuredProperties(double[])
.
Note: Order of properties may be changed
names
- Names of propertiespublic void setTargetProperty(java.lang.String Property, boolean keepUnmeasured)
Property
- Name of this propertykeepUnmeasured
- Whether to keep entries without a measurement for this propertypublic void setTargetProperty(int index, boolean keepUnmeasured)
index
- Index of the property to be usedkeepUnmeasured
- Whether to keep entries without a measurement for this propertypublic void clearPropertyData()
public void addProperty(java.lang.String name)
NOTE: You must add properties to each entry in the Dataset. This is not done automatically because there are several possible ways to add properties to an entry, depending on what you already know about the entry (see below)
name
- Name of new propertyMultiPropertyEntry.addProperty()
,
MultiPropertyEntry.addProperty(double)
,
MultiPropertyEntry.addProperty(double, double)
public void addProperty(java.lang.String name, java.lang.String[] possibleClasses)
NOTE: You must add properties to each entry in the Dataset. This is not done automatically because there are several possible ways to add properties to an entry, depending on what you already know about the entry (see below)
name
- Name of new propertypossibleClasses
- Possible classes for this propertyMultiPropertyEntry.addProperty()
,
MultiPropertyEntry.addProperty(double)
,
MultiPropertyEntry.addProperty(double, double)
public double[] getMeasuredPropertyArray(java.lang.String PropertyName)
PropertyName
- Name of desired propertypublic double[] getPredictedPropertyArray(java.lang.String PropertyName)
PropertyName
- Name of desired propertypublic double[] getMeasuredPropertyArray(int index)
index
- Index of the desired propertypublic double[] getPredictedPropertyArray(int index)
index
- Index of the desired propertypublic java.lang.Object runCommand(java.util.List<java.lang.Object> Command) throws java.lang.Exception
Commandable
runCommand
in interface Commandable
runCommand
in class Dataset
Command
- Command as a list of objectsjava.lang.Exception
- If something goes wrongpublic java.lang.String saveCommand(java.lang.String Basename, java.lang.String Format) throws java.lang.Exception
Savable
Dev Note: Make sure to add save format to Javadoc. See Dataset as an example. Required format:
<save><p><b>format<b> - Description
<br>Optional room to talk more about format </save>
saveCommand
in interface Savable
saveCommand
in class Dataset
Basename
- Name of file without extensionFormat
- Command specifying format in which to printjava.lang.Exception
- If command not understoodprotected void importPropertyNames(java.lang.String line)
line
- Line describing property namesprotected double[] importEntryProperties(java.lang.String[] words)
words
- Line describing entry, split into words