-
Notifications
You must be signed in to change notification settings - Fork 394
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
Keep raw feature distributions calculated in raw feature filter #76
Changes from 3 commits
c101cfe
607a58a
1cd4f63
15b0cca
37d194c
30c60f9
8b5cf07
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 |
---|---|---|
|
@@ -191,6 +191,26 @@ class FeaturesTest extends WordSpec with PassengerFeaturesTest with TestCommon { | |
|""".stripMargin | ||
} | ||
} | ||
"with distributions" should { | ||
"make a copy of the feature containing the specified distributions" in { | ||
val distrib = new FeatureDistributionBase { | ||
override val count: Long = 1L | ||
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.
|
||
override val nulls: Long = 1L | ||
override val distribution: Array[Double] = Array(0.5) | ||
override val summaryInfo: Array[Double] = Array(0.5) | ||
override val name: String = age.name | ||
override val key: Option[String] = None | ||
} | ||
val newAge = age.withDistributions(Seq(distrib)) | ||
newAge.name shouldEqual age.name | ||
newAge.isResponse shouldEqual age.isResponse | ||
newAge.originStage shouldEqual age.originStage | ||
newAge.parents shouldEqual age.parents | ||
newAge.uid shouldEqual age.uid | ||
newAge.distributions.length shouldEqual 1 | ||
newAge.distributions.head shouldEqual distrib | ||
} | ||
} | ||
// TODO: test other feature methods | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2017, Salesforce.com, Inc. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package com.salesforce.op.features | ||
|
||
|
||
/** | ||
* Keeps the distribution information for features | ||
*/ | ||
trait FeatureDistributionBase { | ||
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. @leahmcguire why do we need the trait? if we do, let's name it 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. ok - It seemed nicer to make the trait than to move all of the classes in raw feature filter here. though I am willing to hear counter arguments :-P 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. Oh, I missed the part that it's located in a separate project. Makes sense then. |
||
|
||
/** | ||
* name of the feature | ||
*/ | ||
val name: String | ||
|
||
/** | ||
* key map key associated with distribution (when the feature is a map) | ||
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.
|
||
*/ | ||
val key: Option[String] | ||
|
||
/** | ||
* total count of feature seen | ||
*/ | ||
val count: Long | ||
|
||
/** | ||
* number of empties seen in feature | ||
*/ | ||
val nulls: Long | ||
|
||
/** | ||
* binned counts of feature values (hashed for strings, evently spaced bins for numerics) | ||
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.
|
||
*/ | ||
val distribution: Array[Double] | ||
|
||
/** | ||
* either min and max number of tokens for text data, or number of splits used for bins for numeric data | ||
*/ | ||
val summaryInfo: Array[Double] | ||
} |
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.
Please update doc.