Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::AbstractClassifier Class Referenceabstract

Abstract base class for machine learning classifiers. More...

#include <mitkAbstractClassifier.h>

Inheritance diagram for mitk::AbstractClassifier:
Collaboration diagram for mitk::AbstractClassifier:

Public Member Functions

 mitkClassMacro (AbstractClassifier, BaseData)
 
virtual void Train (const Eigen::MatrixXd &X, const Eigen::MatrixXi &Y)=0
 Train the classifier on a labeled dataset. More...
 
virtual Eigen::MatrixXi Predict (const Eigen::MatrixXd &X)=0
 Predict class labels for the given input samples. More...
 
Eigen::MatrixXi & GetLabels ()
 Get the predicted label matrix from the last prediction. More...
 
virtual bool SupportsPointWiseWeight ()=0
 Query whether this classifier supports per-sample weighting. More...
 
virtual Eigen::MatrixXd & GetPointWiseWeight ()
 Get the per-sample weight matrix. More...
 
virtual void SetPointWiseWeight (const Eigen::MatrixXd &W)
 Set the per-sample weight matrix. More...
 
virtual void UsePointWiseWeight (bool value)
 Enable or disable per-sample weighting during training. More...
 
virtual bool IsUsingPointWiseWeight ()
 Query whether per-sample weighting is currently enabled. More...
 
virtual bool SupportsPointWiseProbability ()=0
 Query whether this classifier supports per-sample class probability output. More...
 
virtual Eigen::MatrixXd & GetPointWiseProbabilities ()
 Get the per-sample class probability matrix from the last prediction. More...
 
virtual void UsePointWiseProbability (bool value)
 Enable or disable per-sample class probability computation. More...
 
virtual bool IsUsingPointWiseProbability ()
 Query whether per-sample class probability output is currently enabled. More...
 
void SetNthItems (const char *val, unsigned int idx)
 Set an item in the property-based item list at the given index. More...
 
std::string GetNthItems (unsigned int idx) const
 Get the item string at the given index from the property-based item list. More...
 
void SetItemList (std::vector< std::string > list)
 Replace the entire item list with the given vector of strings. More...
 
std::vector< std::string > GetItemList () const
 Retrieve all items from the property-based item list. More...
 
void SetRequestedRegionToLargestPossibleRegion () override
 Set the RequestedRegion to the LargestPossibleRegion. More...
 
bool RequestedRegionIsOutsideOfTheBufferedRegion () override
 Determine whether the RequestedRegion is outside of the BufferedRegion. More...
 
bool VerifyRequestedRegion () override
 Verify that the RequestedRegion is within the LargestPossibleRegion. More...
 
void SetRequestedRegion (const itk::DataObject *) override
 Set the requested region from this data object to match the requested region of the data object passed in as a parameter. More...
 
bool IsEmpty () const override
 Check whether the object contains data at any time step. More...
 
- Public Member Functions inherited from mitk::BaseData
 mitkClassMacroItkParent (BaseData, itk::DataObject)
 
BaseProperty::ConstPointer GetConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const override
 Get a const property by its key. More...
 
std::vector< std::string > GetPropertyKeys (const std::string &contextName="", bool includeDefaultContext=false) const override
 Get all property keys stored in the property list. More...
 
std::vector< std::string > GetPropertyContextNames () const override
 Get the names of all property contexts. More...
 
BaseProperty * GetNonConstProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) override
 Get a non-const property by its key. More...
 
void SetProperty (const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Set a property in the property list. More...
 
void RemoveProperty (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
 Remove a property from the property list. More...
 
const mitk::TimeGeometry * GetTimeGeometry () const
 Return the TimeGeometry of the data as const pointer. More...
 
mitk::TimeGeometry * GetTimeGeometry ()
 Return the TimeGeometry of the data as non-const pointer. More...
 
const mitk::TimeGeometry * GetUpdatedTimeGeometry ()
 Return the TimeGeometry of the data after ensuring it is up-to-date. More...
 
virtual void Expand (unsigned int timeSteps)
 Expand the TimeGeometry to a number of time steps. More...
 
const mitk::BaseGeometry * GetUpdatedGeometry (int t=0)
 Return the BaseGeometry of the data at time step t after ensuring it is up-to-date. More...
 
mitk::BaseGeometry * GetGeometry (int t=0) const
 Return the BaseGeometry of the data at time step t as a non-const pointer. More...
 
void UpdateOutputInformation () override
 Update the information for this BaseData so that it can be used as an output of a BaseProcess. More...
 
void CopyInformation (const itk::DataObject *data) override
 Copy information from the specified data set. More...
 
virtual bool IsInitialized () const
 Check whether the data has been initialized. More...
 
virtual void Clear ()
 Reset the data object by calling ClearData() and InitializeEmpty(). More...
 
virtual bool IsEmptyTimeStep (unsigned int t) const
 Check whether the object contains data at the specified time step. More...
 
void ExecuteOperation (Operation *operation) override
 Execute an operation on this data object. More...
 
virtual void SetGeometry (BaseGeometry *aGeometry3D)
 Set the BaseGeometry of the data, which will be referenced (not copied!). More...
 
virtual void SetTimeGeometry (TimeGeometry *geometry)
 Set the TimeGeometry of the data, which will be referenced (not copied!). More...
 
virtual void SetClonedGeometry (const BaseGeometry *aGeometry3D)
 Set a clone of the provided geometry as the BaseGeometry of the data. More...
 
virtual void SetClonedTimeGeometry (const TimeGeometry *geometry)
 Set a clone of the provided TimeGeometry as the TimeGeometry of the data. More...
 
virtual void SetClonedGeometry (const BaseGeometry *aGeometry3D, unsigned int time)
 Set a clone of the provided geometry as the BaseGeometry of a given time step. More...
 
mitk::PropertyList::Pointer GetPropertyList () const
 Get the data's property list. More...
 
void SetPropertyList (PropertyList *propertyList)
 Set the data's property list, replacing the existing one. More...
 
mitk::BaseProperty::Pointer GetProperty (const char *propertyKey) const
 Get a property by its key from the PropertyList. More...
 
void SetProperty (const char *propertyKey, BaseProperty *property)
 Set a property in the PropertyList. More...
 
virtual void SetOrigin (const Point3D &origin)
 Convenience method for setting the origin of the BaseGeometry instances of all time steps. More...
 
itk::SmartPointer< mitk::BaseDataSource > GetSource () const
 Get the process object that generated this data object. More...
 
unsigned int GetTimeSteps () const
 Get the number of time steps from the TimeGeometry. More...
 
itk::ModifiedTimeType GetMTime () const override
 Get the modification time of this data object or its geometry, whichever was modified most recently. More...
 
void Graft (const DataObject *) override
 Graft data and information from another data object. More...
 
- Public Member Functions inherited from mitk::OperationActor
 itkTypeMacroNoParent (OperationActor) virtual ~OperationActor()
 
- Public Member Functions inherited from mitk::Identifiable
 Identifiable ()
 Default constructor. Generates a new random UID. More...
 
 Identifiable (const UIDType &uid)
 Construct with a pre-existing UID. More...
 
 Identifiable (const Identifiable &)=delete
 Copy construction is deleted to prevent UID duplication. More...
 
 Identifiable (Identifiable &&) noexcept
 Move constructor. Transfers ownership of the UID. More...
 
virtual ~Identifiable ()
 Virtual destructor. More...
 
Identifiable & operator= (const Identifiable &)=delete
 Copy assignment is deleted to prevent UID duplication. More...
 
Identifiable & operator= (Identifiable &&other) noexcept
 Move assignment operator. Transfers ownership of the UID. More...
 
virtual UIDType GetUID () const
 Get the unique identifier of this object. More...
 
UIDType GetRuntimeUID () const noexcept
 Get a runtime-unique ID for this object instance. More...
 
- Public Member Functions inherited from mitk::IPropertyOwner
 ~IPropertyOwner () override
 
virtual bool PropertyIsOwned (const std::string &propertyKey, const std::string &contextName="", bool fallBackOnDefaultContext=true) const
 Checks if a certain property exists. More...
 
- Public Member Functions inherited from mitk::IPropertyProvider
virtual ~IPropertyProvider ()
 Virtual destructor. More...
 

Protected Attributes

Eigen::MatrixXi m_OutLabel
 
Eigen::MatrixXd m_PointWiseWeight
 
bool m_IsUsingPointWiseWeight
 
Eigen::MatrixXd m_OutProbability
 
bool m_IsUsingPointWiseProbability
 
- Protected Attributes inherited from mitk::BaseData
bool m_LastRequestedRegionWasOutsideOfTheBufferedRegion
 
unsigned int m_SourceOutputIndexDuplicate
 
bool m_Initialized
 

Additional Inherited Members

- Public Types inherited from mitk::Identifiable
using UIDType = std::string
 Type alias for unique identifiers. More...
 
- Protected Member Functions inherited from mitk::BaseData
 BaseData ()
 
 BaseData (const BaseData &other)
 
 ~BaseData () override
 
virtual void InitializeTimeGeometry (unsigned int timeSteps=1)
 Initialize the TimeGeometry for a number of time steps. The TimeGeometry is initialized empty and evenly timed. In many cases it will be necessary to overwrite this in sub-classes. More...
 
virtual void ClearData ()
 reset to non-initialized state, release memory More...
 
virtual void InitializeEmpty ()
 Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least create one empty object and call Superclass::InitializeTimeGeometry() to ensure an existing valid geometry. More...
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
- Protected Member Functions inherited from mitk::Identifiable
virtual void SetUID (const UIDType &uid)
 

Detailed Description

Abstract base class for machine learning classifiers.

This class defines a common interface for training and prediction with classifiers that operate on Eigen matrices. Derived classes must implement training, prediction, and declare whether they support sample-level weighting and probability estimation.

Features include:

  • Training from feature matrix X and label vector Y
  • Prediction returning class labels
  • Optional per-sample weighting
  • Optional per-sample class probability output
  • An item list stored via the property system for configuration
See also
AbstractGlobalImageFeature

Definition at line 49 of file mitkAbstractClassifier.h.

Member Function Documentation

◆ GetItemList()

std::vector<std::string> mitk::AbstractClassifier::GetItemList ( ) const

Retrieve all items from the property-based item list.

Returns
A vector of strings in index order until a gap is found.

◆ GetLabels()

Eigen::MatrixXi& mitk::AbstractClassifier::GetLabels ( )
inline

Get the predicted label matrix from the last prediction.

Returns
Reference to the label matrix of shape [n_samples, 1].

Definition at line 76 of file mitkAbstractClassifier.h.

◆ GetNthItems()

std::string mitk::AbstractClassifier::GetNthItems ( unsigned int  idx) const

Get the item string at the given index from the property-based item list.

Parameters
[in]idxZero-based index position.
Returns
The string value at the given index.

◆ GetPointWiseProbabilities()

virtual Eigen::MatrixXd& mitk::AbstractClassifier::GetPointWiseProbabilities ( )
inlinevirtual

Get the per-sample class probability matrix from the last prediction.

Returns
Reference to the probability matrix.

Definition at line 158 of file mitkAbstractClassifier.h.

◆ GetPointWiseWeight()

virtual Eigen::MatrixXd& mitk::AbstractClassifier::GetPointWiseWeight ( )
inlinevirtual

Get the per-sample weight matrix.

Returns
Reference to the weight matrix of shape [n_samples, 1].

Definition at line 102 of file mitkAbstractClassifier.h.

◆ IsEmpty()

bool mitk::AbstractClassifier::IsEmpty ( ) const
inlineoverridevirtual

Check whether the object contains data at any time step.

Iterates over all time steps and returns true only if every time step is empty (or the object is not initialized).

Warning
Returns IsInitialized()==false by default for compatibility reasons. Override in sub-classes that support distinction between empty/non-empty state.
Returns
True if the data object is empty at all time steps.
See also
IsEmptyTimeStep

Reimplemented from mitk::BaseData.

Definition at line 234 of file mitkAbstractClassifier.h.

◆ IsUsingPointWiseProbability()

virtual bool mitk::AbstractClassifier::IsUsingPointWiseProbability ( )
inlinevirtual

Query whether per-sample class probability output is currently enabled.

Returns
True if pointwise probability output is active.

Definition at line 178 of file mitkAbstractClassifier.h.

◆ IsUsingPointWiseWeight()

virtual bool mitk::AbstractClassifier::IsUsingPointWiseWeight ( )
inlinevirtual

Query whether per-sample weighting is currently enabled.

Returns
True if pointwise weighting is active.

Definition at line 132 of file mitkAbstractClassifier.h.

◆ mitkClassMacro()

mitk::AbstractClassifier::mitkClassMacro ( AbstractClassifier  ,
BaseData   
)

◆ Predict()

virtual Eigen::MatrixXi mitk::AbstractClassifier::Predict ( const Eigen::MatrixXd &  X)
pure virtual

Predict class labels for the given input samples.

Parameters
[in]XInput samples. Matrix of shape [n_samples, n_features].
Returns
Predicted class labels. Matrix of shape [n_samples, 1].

◆ RequestedRegionIsOutsideOfTheBufferedRegion()

bool mitk::AbstractClassifier::RequestedRegionIsOutsideOfTheBufferedRegion ( )
inlineoverridevirtual

Determine whether the RequestedRegion is outside of the BufferedRegion.

This method returns true if the RequestedRegion is outside the BufferedRegion (true if at least one pixel is outside). This is used by the pipeline mechanism to determine whether a filter needs to re-execute in order to satisfy the current request. If the current RequestedRegion is already inside the BufferedRegion from the previous execution (and the current filter is up to date), then a given filter does not need to re-execute.

Returns
True if the requested region is outside the buffered region.

Implements mitk::BaseData.

Definition at line 227 of file mitkAbstractClassifier.h.

◆ SetItemList()

void mitk::AbstractClassifier::SetItemList ( std::vector< std::string >  list)

Replace the entire item list with the given vector of strings.

Parameters
[in]listA vector of string items to store.

◆ SetNthItems()

void mitk::AbstractClassifier::SetNthItems ( const char *  val,
unsigned int  idx 
)

Set an item in the property-based item list at the given index.

Items are stored as string properties under keys "itemlist.0", "itemlist.1", etc.

Parameters
[in]valThe string value to store.
[in]idxZero-based index position.

◆ SetPointWiseWeight()

virtual void mitk::AbstractClassifier::SetPointWiseWeight ( const Eigen::MatrixXd &  W)
inlinevirtual

Set the per-sample weight matrix.

Parameters
[in]WWeight matrix of shape [n_samples, 1].

Definition at line 112 of file mitkAbstractClassifier.h.

◆ SetRequestedRegion()

void mitk::AbstractClassifier::SetRequestedRegion ( const itk::DataObject *  data)
inlineoverridevirtual

Set the requested region from this data object to match the requested region of the data object passed in as a parameter.

This method is implemented in the concrete subclasses of BaseData.

Parameters
[in]dataThe data object whose requested region will be matched.

Implements mitk::BaseData.

Definition at line 230 of file mitkAbstractClassifier.h.

◆ SetRequestedRegionToLargestPossibleRegion()

void mitk::AbstractClassifier::SetRequestedRegionToLargestPossibleRegion ( )
inlineoverridevirtual

Set the RequestedRegion to the LargestPossibleRegion.

This forces a filter to produce all of the output in one execution (i.e., not streaming) on the next call to Update().

Implements mitk::BaseData.

Definition at line 226 of file mitkAbstractClassifier.h.

◆ SupportsPointWiseProbability()

virtual bool mitk::AbstractClassifier::SupportsPointWiseProbability ( )
pure virtual

Query whether this classifier supports per-sample class probability output.

Returns
True if pointwise probability estimation is supported, false otherwise.

◆ SupportsPointWiseWeight()

virtual bool mitk::AbstractClassifier::SupportsPointWiseWeight ( )
pure virtual

Query whether this classifier supports per-sample weighting.

Returns
True if pointwise weighting is supported, false otherwise.

◆ Train()

virtual void mitk::AbstractClassifier::Train ( const Eigen::MatrixXd &  X,
const Eigen::MatrixXi &  Y 
)
pure virtual

Train the classifier on a labeled dataset.

Parameters
[in]XTraining input samples. Matrix of shape [n_samples, n_features].
[in]YTarget class labels. Matrix of shape [n_samples, 1].

◆ UsePointWiseProbability()

virtual void mitk::AbstractClassifier::UsePointWiseProbability ( bool  value)
inlinevirtual

Enable or disable per-sample class probability computation.

Parameters
[in]valueTrue to enable probability output, false to disable.

Definition at line 168 of file mitkAbstractClassifier.h.

◆ UsePointWiseWeight()

virtual void mitk::AbstractClassifier::UsePointWiseWeight ( bool  value)
inlinevirtual

Enable or disable per-sample weighting during training.

Parameters
[in]valueTrue to enable weighting, false to disable.

Definition at line 122 of file mitkAbstractClassifier.h.

◆ VerifyRequestedRegion()

bool mitk::AbstractClassifier::VerifyRequestedRegion ( )
inlineoverridevirtual

Verify that the RequestedRegion is within the LargestPossibleRegion.

If the RequestedRegion is not within the LargestPossibleRegion, then the filter cannot possibly satisfy the request. This method returns true if the request can be satisfied (even if it will be necessary to process the entire LargestPossibleRegion) and returns false otherwise. Used by PropagateRequestedRegion(), which throws an InvalidRequestedRegionError exception if the requested region is not within the LargestPossibleRegion.

Returns
True if the requested region is within the largest possible region.

Implements mitk::BaseData.

Definition at line 228 of file mitkAbstractClassifier.h.

Member Data Documentation

◆ m_IsUsingPointWiseProbability

bool mitk::AbstractClassifier::m_IsUsingPointWiseProbability
protected

Definition at line 185 of file mitkAbstractClassifier.h.

◆ m_IsUsingPointWiseWeight

bool mitk::AbstractClassifier::m_IsUsingPointWiseWeight
protected

Definition at line 139 of file mitkAbstractClassifier.h.

◆ m_OutLabel

Eigen::MatrixXi mitk::AbstractClassifier::m_OutLabel
protected

Definition at line 82 of file mitkAbstractClassifier.h.

◆ m_OutProbability

Eigen::MatrixXd mitk::AbstractClassifier::m_OutProbability
protected

Definition at line 184 of file mitkAbstractClassifier.h.

◆ m_PointWiseWeight

Eigen::MatrixXd mitk::AbstractClassifier::m_PointWiseWeight
protected

Definition at line 138 of file mitkAbstractClassifier.h.


The documentation for this class was generated from the following file: