Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
svm.cpp File Reference
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <float.h>
#include <string.h>
#include <stdarg.h>
#include <limits.h>
#include <locale.h>
#include <mitkLocaleSwitch.h>
#include "svm.h"

Go to the source code of this file.

Macros

#define INF
 
#define TAU
 
#define Malloc(type, n)
 
#define FSCANF(_stream, _format, _var)
 

Typedefs

typedef float Qfloat
 
typedef signed char schar
 

Functions

template<class T >
static T min (T x, T y)
 
template<class T >
static T max (T x, T y)
 
template<class T >
static void swap (T &x, T &y)
 
template<class S , class T >
static void clone (T *&dst, S *src, int n)
 
static double powi (double base, int times)
 
static void print_string_stdout (const char *s)
 
static void info (const char *fmt,...)
 
static void solve_c_svc (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si, double Cp, double Cn)
 
static void solve_nu_svc (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si)
 
static void solve_one_class (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si)
 
static void solve_epsilon_svr (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si)
 
static void solve_nu_svr (const svm_problem *prob, const svm_parameter *param, double *alpha, Solver::SolutionInfo *si)
 
static decision_function svm_train_one (const svm_problem *prob, const svm_parameter *param, double Cp, double Cn)
 
static void sigmoid_train (int l, const double *dec_values, const double *labels, double &A, double &B)
 
static double sigmoid_predict (double decision_value, double A, double B)
 
static void multiclass_probability (int k, double **r, double *p)
 
static void svm_binary_svc_probability (const svm_problem *prob, const svm_parameter *param, double Cp, double Cn, double &probA, double &probB)
 
static double svm_svr_probability (const svm_problem *prob, const svm_parameter *param)
 
static void svm_group_classes (const svm_problem *prob, int *nr_class_ret, int **label_ret, int **start_ret, int **count_ret, int *perm)
 
static void remove_zero_weight (svm_problem *newprob, const svm_problem *prob)
 
svm_modelsvm_train (const svm_problem *prob, const svm_parameter *param)
 
void svm_cross_validation (const svm_problem *prob, const svm_parameter *param, int nr_fold, double *target)
 
int svm_get_svm_type (const svm_model *model)
 
int svm_get_nr_class (const svm_model *model)
 
void svm_get_labels (const svm_model *model, int *label)
 
void svm_get_sv_indices (const svm_model *model, int *indices)
 
int svm_get_nr_sv (const svm_model *model)
 
double svm_get_svr_probability (const svm_model *model)
 
double svm_predict_values (const svm_model *model, const svm_node *x, double *dec_values)
 
double svm_predict (const svm_model *model, const svm_node *x)
 
double svm_predict_probability (const svm_model *model, const svm_node *x, double *prob_estimates)
 
int svm_save_model (const char *model_file_name, const svm_model *model)
 
static char * readline (FILE *input)
 
bool read_model_header (FILE *fp, svm_model *model)
 
svm_modelsvm_load_model (const char *model_file_name)
 
void svm_free_model_content (svm_model *model_ptr)
 
void svm_free_and_destroy_model (svm_model **model_ptr_ptr)
 
void svm_destroy_param (svm_parameter *param)
 
const char * svm_check_parameter (const svm_problem *prob, const svm_parameter *param)
 
int svm_check_probability_model (const svm_model *model)
 
void svm_set_print_string_function (void(*print_func)(const char *))
 

Variables

int libsvm_version
 
static void(* svm_print_string )(const char *)
 
static const char * svm_type_table []
 
static const char * kernel_type_table []
 
static char * line
 
static int max_line_len
 

Macro Definition Documentation

#define FSCANF (   _stream,
  _format,
  _var 
)

Definition at line 2912 of file svm.cpp.

Referenced by read_model_header().

#define INF

Definition at line 89 of file svm.cpp.

#define TAU

Definition at line 90 of file svm.cpp.

Typedef Documentation

typedef float Qfloat

Definition at line 64 of file svm.cpp.

typedef signed char schar

Definition at line 65 of file svm.cpp.

Function Documentation

template<class S , class T >
static void clone ( T *&  dst,
S *  src,
int  n 
)
inlinestatic
template<class T >
static T max ( x,
y 
)
inlinestatic

Definition at line 70 of file svm.cpp.

Referenced by mitk::NavigationDataLandmarkTransformFilter::AccumulateStatistics(), QmitkOverlayController::AdjustOverlayPosition(), mitk::SliceNavigationController::AdjustSliceStepperRange(), itk::DiffusionIntravoxelIncoherentMotionReconstructionImageFilter< TInputPixelType, TOutputPixelType >::BeforeThreadedGenerateData(), mitk::ExtrudedContour::BuildGeometry(), mitk::ConnectomicsNetworkCreator::CalculateCenterOfMass(), mitk::ImageStatisticsCalculator::CalculateExtremaWorld(), mitk::ClippedSurfaceBoundsCalculator::CalculateIntersectionPoints(), mitk::CalculateGrayValueStatisticsTool::CalculateMinMax(), mitk::ConnectomicsStatisticsCalculator::CalculateShortestPathMetrics(), mitk::PlanarPolygon::CheckForLineIntersection(), CheckPlanesOutsideOfBoundingBox(), itk::OdfMaximaExtractionFilter< TOdfPixelType >::ClusterPeaks(), mitk::MultiComponentImageDataComparisonFilter::CompareMultiComponentImage(), mitk::DataStorage::ComputeBoundingGeometry3D(), mitk::AnisotropicIterativeClosestPointRegistration::ComputeCorrespondences(), mitk::ComputeGlobalMinimum(), mitk::ImageStatisticsHolder::ComputeImageStatistics(), mitk::ComputeIntensityProfileStatistics(), mitk::DataStorage::ComputeTimeBounds(), mitk::ImageLiveWireContourModelFilter::CreateDynamicCostMapByITK(), QmitkMapPropertyDelegate::createEditor(), QmitkPropertyDelegate::createEditor(), QmitkToFCompositeFilterWidget::CreateQtPartControl(), QmitkTbssRoiAnalysisWidget::CreateTracts(), mitk::PointSetVtkMapper2D::CreateVTKRenderObjects(), mitk::ClippedSurfaceBoundsCalculator::EnforceImageBounds(), mitk::LevelWindow::EnsureConsistency(), mitk::ImageStatisticsHolder::Expand(), mitk::RandomParcellationGenerator< TPixel, VImageDimension >::ExtendedRegionNotNeighbor(), itk::TractsToVectorImageFilter< PixelType >::FastClustering(), mitk::FeedbackContourTool::FeedbackContourTool(), mitk::FileWriterSelector::FileWriterSelector(), mitk::NavigationDataLandmarkTransformFilter::FindCorrespondentLandmarks(), mitk::ProportionalTimeGeometryToXML::FromXML(), mitk::GeneralizedLinearModel::GeneralizedLinearModel(), itk::MultiHistogramFilter< TInputImageType, TOuputImageType >::GenerateData(), mitk::BoundingObjectToSegmentationFilter::GenerateData(), itk::DwiGradientLengthCorrectionFilter::GenerateData(), itk::TractDensityImageFilter< OutputImageType >::GenerateData(), itk::EvaluateTractogramDirectionsFilter< PixelType >::GenerateData(), itk::OdfMaximaExtractionFilter< TOdfPixelType >::GenerateData(), itk::TractsToDWIImageFilter< PixelType >::GenerateData(), itk::EvaluateDirectionImagesFilter< PixelType >::GenerateData(), mitk::ExtractSliceFilter::GenerateData(), mitk::BoundingObjectCutter::GenerateOutputInformation(), mitk::BoundingShapeCropper::GenerateOutputInformation(), get_statistics_boost(), mitk::vtkSimulationPolyDataMapper2D::GetBounds(), mitk::vtkSimulationPolyDataMapper3D::GetBounds(), berry::Geometry::GetClosestSide(), mitk::DICOMFileReaderSelector::GetFirstReaderWithMinimumNumberOfOutputImages(), mitk::LabeledImageToSurfaceFilter::GetLabelForNthOutput(), mitk::Gizmo::GetLongestRadius(), mitk::SimpleImageHistogram::GetMax(), mitk::PlanarBezierCurve::GetMaximumNumberOfControlPoints(), mitk::ProportionalTimeGeometry::GetMaximumTimePoint(), QmitkOverlayController::GetMinimumSizeForWidget(), mitk::ProportionalTimeGeometry::GetMinimumTimePoint(), mitk::OtsuTool3D::GetNumberOfBins(), mitk::TubeGraphPicker::GetPickedTube(), mitk::ImageStatisticsHolder::GetScalarValue2ndMinNoRecompute(), mitk::ImageStatisticsHolder::GetScalarValueMinNoRecompute(), mitk::ImageStatisticsHolder::ImageStatisticsHolder(), mitk::ProportionalTimeGeometry::Initialize(), mitk::ClippedSurfaceBoundsCalculator::InitializeOutput(), mitk::PartialVolumeAnalysisHistogramCalculator::InternalCalculateMaskFromPlanarFigure(), mitk::MRNormTwoRegionsBasedFilter::InternalComputeMask(), mitk::MaskImageFilter::InternalComputeMask(), mitk::CalculateGrayValueStatisticsTool::ITKHistogramming(), mitk::CalculateSegmentationVolume::ItkImageProcessing(), itk::ExtendedLabelStatisticsImageFilter< TInputImage, TLabelImage >::LabelStatistics::LabelStatistics(), mitk::FiberfoxParameters< ScalarType >::LoadParameters(), main(), mitk::ToFOpenCVImageGrabber::MapScalars(), mitkMultiComponentImageDataComparisonFilterTest(), multiclass_probability(), itk::TractsToDWIImageFilter< PixelType >::NormalizeInsideMask(), QmitkAdaptiveRegionGrowingToolGUI::OnPointAdded(), QmlMitkImageNavigator::OnRefetch(), itk::Functor::NeighborhoodFirstOrderStatistics< TNeighborhoodType, TPixelOutputType >::operator()(), itk::Functor::NeighborhoodCooccurenceMatrix< TNeighborhoodType, TPixelOutputType >::operator()(), mitk::MeshMapper2D::Paint(), mitk::ParticleGrid::ParticleGrid(), mitk::PartialVolumeAnalysisClusteringCalculator::PerformClustering(), itk::TractsToDWIImageFilter< PixelType >::PrepareLogFile(), mitk::CollectionStatistic::Print(), QmitkAnyDoubleWidget::QmitkAnyDoubleWidget(), QmitkAnyFloatWidget::QmitkAnyFloatWidget(), QmitkAnyIntWidget::QmitkAnyIntWidget(), QmitkAnyShortWidget::QmitkAnyShortWidget(), QmitkAnyUIntWidget::QmitkAnyUIntWidget(), QmitkAnyUShortWidget::QmitkAnyUShortWidget(), QmitkLineEditLevelWindowWidget::QmitkLineEditLevelWindowWidget(), mitk::PyramidImageRegistrationMethod::RegisterTwoImagesV4(), mitk::CompareImageDataFilter::ResetCompareResultsToInitial(), mitk::ImageStatisticsHolder::ResetImageStatistics(), mitk::RawShModel< ScalarType >::SampleKernels(), mitk::SliceNavigationController::SelectSliceByPoint(), mitk::RawShModel< ScalarType >::SetAdcRange(), mitk::LevelWindow::SetAuto(), mitk::PlanarEllipse::SetControlPoint(), itk::ShortestPathCostFunctionLiveWire< TInputImageType >::SetCostMapMaximum(), mitk::RawShModel< ScalarType >::SetFaRange(), QmitkAdaptiveRegionGrowingToolGUI::SetInputImageNode(), QmitkSliderNavigatorWidget::SetLabelValues(), QmitkTransferFunctionCanvas::SetMax(), QmlMitkTransferFunctionCanvas::SetMax(), mitk::RenderingManager::SetMaximumLOD(), mitk::RawShModel< ScalarType >::SetMaxNumKernels(), mitk::PlanarBezierCurve::SetNumberOfSegments(), mitk::PlanarDoubleEllipse::SetNumberOfSegments(), QmitkODFDetailsWidget::SetParameters(), mitk::Stepper::SetRange(), mitk::LevelWindow::SetRangeMinMax(), mitk::ToFCompositeFilter::SetThresholdFilterParameter(), mitk::ManufacturerLogo::SetupCamera(), mitk::ManufacturerLogo::SetupPosition(), svm_predict_probability(), itk::FiniteDiffOdfMaximaExtractionFilter< PixelType, ShOrder, NrOdfDirections >::ThreadedGenerateData(), mitk::ShowSegmentationAsSmoothedSurface::ThreadedUpdateFunction(), mitk::ProportionalTimeGeometry::TimeStepToTimePoint(), mitk::ProportionalTimeGeometryToXML::ToXML(), mitk::ClippedSurfaceBoundsCalculator::Update(), mitk::CvMatCompare::Update(), mitk::AnisotropicIterativeClosestPointRegistration::Update(), mitk::ConnectomicsNetwork::UpdateBounds(), mitk::Simulation::UpdateOutputInformation(), QmitkTransferFunctionCanvas::ValidateCoord(), QmlMitkTransferFunctionCanvas::ValidateCoord(), mitk::WeightedPointTransform::WeightedPointRegister(), and us::LDAPExprConstants::WILDCARD().

template<class T >
static T min ( x,
y 
)
inlinestatic

Definition at line 67 of file svm.cpp.

Referenced by mitk::NavigationDataLandmarkTransformFilter::AccumulateStatistics(), mitk::SliceNavigationController::AdjustSliceStepperRange(), ApplyMaterial(), Assert_ItkImageImportSucceded_ReturnsTrue(), mitk::ExtrudedContour::BuildGeometry(), mitk::ConnectomicsNetworkCreator::CalculateCenterOfMass(), mitk::ImageStatisticsCalculator::CalculateExtremaWorld(), mitk::ClippedSurfaceBoundsCalculator::CalculateIntersectionPoints(), mitk::CalculateGrayValueStatisticsTool::CalculateMinMax(), mitk::PlanarPolygon::CheckForLineIntersection(), CheckPlanesOutsideOfBoundingBox(), itk::OdfMaximaExtractionFilter< TOdfPixelType >::ClusterPeaks(), mitk::MultiComponentImageDataComparisonFilter::CompareMultiComponentImage(), mitk::ComputeCenterOfMaximumArea(), mitk::ComputeGlobalMaximum(), mitk::ComputeIntensityProfileStatistics(), QmitkMapPropertyDelegate::createEditor(), QmitkPropertyDelegate::createEditor(), CreateJSONEscapes(), QmitkToFCompositeFilterWidget::CreateQtPartControl(), QmitkDataStorageTreeModel::dropMimeData(), mitk::ClippedSurfaceBoundsCalculator::EnforceImageBounds(), mitk::LevelWindow::EnsureConsistency(), mitk::Equal(), mitk::RandomParcellationGenerator< TPixel, VImageDimension >::ExtendedRegionNotNeighbor(), mitk::FiberBundle::ExtractFiberIdSubset(), itk::MultiHistogramFilter< TInputImageType, TOuputImageType >::GenerateData(), mitk::BoundingObjectToSegmentationFilter::GenerateData(), itk::TractsToDWIImageFilter< PixelType >::GenerateData(), mitk::BoundingObjectCutter::GenerateOutputInformation(), mitk::BoundingShapeCropper::GenerateOutputInformation(), get_statistics_boost(), mitk::vtkSimulationPolyDataMapper2D::GetBounds(), mitk::vtkSimulationPolyDataMapper3D::GetBounds(), mitk::IgnorePixelMaskGenerator::GetMask(), mitk::SimpleImageHistogram::GetMin(), mitk::OtsuTool3D::GetNumberOfBins(), itk::MLBSTrackingFilter< ShOrder, NumImageFeatures >::GetRandDouble(), mitk::IndexROI::init(), mitk::ClippedSurfaceBoundsCalculator::InitializeOutput(), mitk::PartialVolumeAnalysisHistogramCalculator::InternalCalculateMaskFromPlanarFigure(), mitk::MRNormTwoRegionsBasedFilter::InternalComputeMask(), mitk::MaskImageFilter::InternalComputeMask(), mitk::CalculateGrayValueStatisticsTool::ITKHistogramming(), mitk::CalculateSegmentationVolume::ItkImageProcessing(), mitk::ToFOpenCVImageGrabber::MapScalars(), us::ModuleVersion::ModuleVersion(), itk::TractsToDWIImageFilter< PixelType >::NormalizeInsideMask(), QmitkIGTPlayerWidget::OnPlaying(), QmitkAdaptiveRegionGrowingToolGUI::OnPointAdded(), QmlMitkImageNavigator::OnRefetch(), QmitkNavigationDataPlayerControlWidget::OnUpdate(), itk::Functor::NeighborhoodFirstOrderStatistics< TNeighborhoodType, TPixelOutputType >::operator()(), itk::Functor::NeighborhoodCooccurenceMatrix< TNeighborhoodType, TPixelOutputType >::operator()(), mitk::MeshMapper2D::Paint(), mitk::VectorImageMapper2D::Paint(), mitk::PlanarFigureMapper2D::PaintPolyLine(), mitk::PartialVolumeAnalysisClusteringCalculator::PerformClustering(), QmitkAnyDoubleWidget::QmitkAnyDoubleWidget(), QmitkAnyFloatWidget::QmitkAnyFloatWidget(), QmitkAnyIntWidget::QmitkAnyIntWidget(), QmitkAnyShortWidget::QmitkAnyShortWidget(), QmitkAnyUIntWidget::QmitkAnyUIntWidget(), QmitkAnyUShortWidget::QmitkAnyUShortWidget(), mitk::PyramidImageRegistrationMethod::RegisterTwoImagesV4(), mitk::FiberBundle::RemoveShortFibers(), mitk::TumorInvasionClassification::SelectTrainingSamples(), mitk::RawShModel< ScalarType >::SetAdcRange(), mitk::LevelWindow::SetAuto(), mitk::LevelWindowManager::SetAutoTopMostImage(), mitk::RawShModel< ScalarType >::SetFaRange(), QmitkAdaptiveRegionGrowingToolGUI::SetInputImageNode(), QmitkSliderNavigatorWidget::SetLabelValues(), QmitkTransferFunctionCanvas::SetMin(), QmlMitkTransferFunctionCanvas::SetMin(), QmitkODFDetailsWidget::SetParameters(), mitk::Stepper::SetRange(), mitk::LevelWindow::SetRangeMinMax(), mitk::ToFCompositeFilter::SetThresholdFilterParameter(), solve_nu_svc(), solve_nu_svr(), solve_one_class(), svm_check_parameter(), svm_predict_probability(), mitk::ShowSegmentationAsSmoothedSurface::ThreadedUpdateFunction(), mitk::ProportionalTimeGeometry::TimeStepToTimePoint(), mitk::LevelWindowManager::Update(), mitk::ClippedSurfaceBoundsCalculator::Update(), mitk::ConnectomicsNetwork::UpdateBounds(), mitk::Simulation::UpdateOutputInformation(), QmitkTransferFunctionCanvas::ValidateCoord(), and QmlMitkTransferFunctionCanvas::ValidateCoord().

static void multiclass_probability ( int  k,
double **  r,
double *  p 
)
static

Definition at line 1930 of file svm.cpp.

References info(), Malloc, and max().

Referenced by svm_predict_probability().

static double powi ( double  base,
int  times 
)
inlinestatic

Definition at line 78 of file svm.cpp.

static void print_string_stdout ( const char *  s)
static

Definition at line 93 of file svm.cpp.

Referenced by svm_set_print_string_function().

static char* readline ( FILE *  input)
static

Definition at line 2887 of file svm.cpp.

References line.

Referenced by svm_load_model().

static void remove_zero_weight ( svm_problem newprob,
const svm_problem prob 
)
static

Definition at line 2197 of file svm.cpp.

References svm_problem::l, svm_model::l, Malloc, svm_problem::W, svm_problem::x, and svm_problem::y.

Referenced by svm_train().

static double sigmoid_predict ( double  decision_value,
double  A,
double  B 
)
static

Definition at line 1919 of file svm.cpp.

Referenced by svm_predict_probability().

static void sigmoid_train ( int  l,
const double *  dec_values,
const double *  labels,
double &  A,
double &  B 
)
static

Definition at line 1806 of file svm.cpp.

References mitk::eps, info(), and Malloc.

Referenced by svm_binary_svc_probability().

static void solve_c_svc ( const svm_problem prob,
const svm_parameter param,
double *  alpha,
Solver::SolutionInfo *  si,
double  Cp,
double  Cn 
)
static
static void solve_epsilon_svr ( const svm_problem prob,
const svm_parameter param,
double *  alpha,
Solver::SolutionInfo *  si 
)
static
static void solve_nu_svc ( const svm_problem prob,
const svm_parameter param,
double *  alpha,
Solver::SolutionInfo *  si 
)
static
static void solve_nu_svr ( const svm_problem prob,
const svm_parameter param,
double *  alpha,
Solver::SolutionInfo *  si 
)
static
static void solve_one_class ( const svm_problem prob,
const svm_parameter param,
double *  alpha,
Solver::SolutionInfo *  si 
)
static
static void svm_binary_svc_probability ( const svm_problem prob,
const svm_parameter param,
double  Cp,
double  Cn,
double &  probA,
double &  probB 
)
static
int svm_check_probability_model ( const svm_model model)
void svm_free_and_destroy_model ( svm_model **  model_ptr_ptr)
void svm_get_labels ( const svm_model model,
int *  label 
)

Definition at line 2623 of file svm.cpp.

References svm_model::label, and svm_model::nr_class.

int svm_get_nr_class ( const svm_model model)

Definition at line 2618 of file svm.cpp.

References svm_model::nr_class.

Referenced by svm_cross_validation().

int svm_get_nr_sv ( const svm_model model)

Definition at line 2637 of file svm.cpp.

References svm_model::l.

void svm_get_sv_indices ( const svm_model model,
int *  indices 
)

Definition at line 2630 of file svm.cpp.

References svm_model::l, and svm_model::sv_indices.

int svm_get_svm_type ( const svm_model model)

Definition at line 2613 of file svm.cpp.

References svm_model::param, and svm_parameter::svm_type.

double svm_get_svr_probability ( const svm_model model)

Definition at line 2642 of file svm.cpp.

References EPSILON_SVR, NU_SVR, svm_model::param, svm_model::probA, and svm_parameter::svm_type.

static void svm_group_classes ( const svm_problem prob,
int *  nr_class_ret,
int **  label_ret,
int **  start_ret,
int **  count_ret,
int *  perm 
)
static
double svm_predict ( const svm_model model,
const svm_node x 
)
double svm_predict_probability ( const svm_model model,
const svm_node x,
double *  prob_estimates 
)
double svm_predict_values ( const svm_model model,
const svm_node x,
double *  dec_values 
)
void svm_set_print_string_function ( void(*)(const char *)  print_func)

Definition at line 3301 of file svm.cpp.

References print_string_stdout(), and svm_print_string.

static double svm_svr_probability ( const svm_problem prob,
const svm_parameter param 
)
static
static decision_function svm_train_one ( const svm_problem prob,
const svm_parameter param,
double  Cp,
double  Cn 
)
static

Variable Documentation

const char* kernel_type_table[]
static

Definition at line 2789 of file svm.cpp.

int libsvm_version

Definition at line 63 of file svm.cpp.

int max_line_len
static

Definition at line 2885 of file svm.cpp.

void(* svm_print_string) (const char *)
static

Definition at line 98 of file svm.cpp.

Referenced by svm_set_print_string_function().

const char* svm_type_table[]
static

Definition at line 2784 of file svm.cpp.