-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
GetSummaryDataView() implementation for Pca and Linear Predictors #185
Changes from 8 commits
ec890d6
9394cdd
b508e68
e072546
ec8200a
cf37f62
9943586
45cd5f2
083645f
58d0f31
c5c0173
695abc5
eea9c69
637b325
bdec903
b942537
678633c
3031a4c
b0c2e49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,6 +308,7 @@ public static CommonOutputs.AnomalyDetectionOutput TrainPcaAnomaly(IHostEnvironm | |
// REVIEW: move the predictor to a different file and fold EigenUtils.cs to this file. | ||
public sealed class PcaPredictor : PredictorBase<Float>, | ||
IValueMapper, | ||
ICanGetSummaryAsIDataView, | ||
ICanSaveInTextFormat, ICanSaveModel, ICanSaveSummary | ||
{ | ||
public const string LoaderSignature = "pcaAnomExec"; | ||
|
@@ -469,6 +470,29 @@ public void SaveAsText(TextWriter writer, RoleMappedSchema schema) | |
} | ||
} | ||
|
||
public IDataView GetSummaryDataView(RoleMappedSchema schema) | ||
{ | ||
var bldr = new ArrayDataViewBuilder(Host); | ||
|
||
bldr.AddColumn("MeanVector", NumberType.R4, _mean); | ||
bldr.AddColumn("ProjectedMeanVector", NumberType.R4, _meanProjected); | ||
|
||
ValueGetter<VBuffer<DvText>> getSlotNames = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We probably don't need the slot names here since they don't give any additional information other than the slot index. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
(ref VBuffer<DvText> dst) => | ||
{ | ||
var values = new DvText[_rank]; | ||
for (var i = 0; i < _rank; ++i) | ||
values[i] = new DvText("V" + i); | ||
|
||
// should we reuse dst VBuffer or not? | ||
var tmp = new VBuffer<DvText>(_rank, values); | ||
tmp.CopyTo(ref dst); | ||
}; | ||
|
||
bldr.AddColumn("EigenVectors", getSlotNames, NumberType.R4, _eigenVectors); | ||
return bldr.GetDataView(); | ||
} | ||
|
||
public ColumnType InputType | ||
{ | ||
get { return _inputType; } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a unit test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added