Skip to content

Commit

Permalink
Using SVD on median only data centralized data.
Browse files Browse the repository at this point in the history
  • Loading branch information
antononcube committed Jul 19, 2013
1 parent 5dd8554 commit 667626c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions AVCDecisionTreeForest.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,11 @@ Mathematica is (C) Copyright 1988-2012 Wolfram Research, Inc.
Which[
TrueQ[svdLabels === Automatic],
If[numAvcs[[1, 2]]/Length[classLabels] <= 1/2,
numDataRecs =
Pick[dataRecs, Map[# == numAvcs[[1, 1]] &, classLabels]],
numDataRecs =
Pick[dataRecs, Map[# != numAvcs[[1, 1]] &, classLabels]]
],
numDataRecs = Pick[dataRecs, Map[# == numAvcs[[1, 1]] &, classLabels]],
numDataRecs = Pick[dataRecs, Map[# != numAvcs[[1, 1]] &, classLabels]]
],
ListQ[svdLabels],
inRules =
Dispatch[Append[Thread[svdLabels -> True], _?AtomQ -> False]];
inRules = Dispatch[Append[Thread[svdLabels -> True], _?AtomQ -> False]];
numDataRecs = Pick[dataRecs, classLabels /. inRules],
True,
numDataRecs = {}
Expand All @@ -247,7 +244,7 @@ Mathematica is (C) Copyright 1988-2012 Wolfram Research, Inc.
numDataRecs = Union[numDataRecs[[All, numAxes]]];
{U, S, V} = SingularValueDecomposition[numDataRecs, svdRank, Tolerance -> 0.01];
If[cdSVDRank > 0,
{numDataRecs, crs} = CentralizeDataMatrix[numDataRecs, All];
{numDataRecs, crs} = MedianCentralizeDataMatrix[numDataRecs, All];
{cU, cS, cV} = SingularValueDecomposition[numDataRecs, cdSVDRank, Tolerance -> 0.01];
];
]
Expand Down Expand Up @@ -567,6 +564,19 @@ Mathematica is (C) Copyright 1988-2012 Wolfram Research, Inc.
{data, centralizers}
];

Clear[MedianCentralizeDataMatrix]
MedianCentralizeDataMatrix[dataArg_?MatrixQ] := MedianCentralizeDataMatrix[dataArg, All];
MedianCentralizeDataMatrix[dataArg_?MatrixQ, indsArg : ({_Integer ..} | All)] :=
Block[{data = dataArg, m, qd, inds = indsArg, centralizers = {}},
If[inds === All, inds = Range[Dimensions[data][[2]]]];
Do[
m = Median[data[[All, i]]];
data[[All, i]] = (data[[All, i]] - m);
AppendTo[centralizers, {m, 1}]
, {i, inds}];
{data, centralizers}
];

(* DecisionTreeClassificationSuccess *)

Clear[DecisionTreeOrForestClassificationSuccess, DecisionTreeClassificationSuccess, DecisionForestClassificationSuccess]
Expand Down

0 comments on commit 667626c

Please sign in to comment.