Skip to content
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

Standalone minimum variance estimator #463

Merged
merged 18 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.salesforce.op.features.FeatureLike
import com.salesforce.op.features.types._
import com.salesforce.op.stages.impl.classification.{Impurity, OpRandomForestClassifier}
import com.salesforce.op.stages.impl.feature.{DropIndicesByTransformer, OpLDA}
import com.salesforce.op.stages.impl.preparators.MinVarianceFilter
import com.salesforce.op.stages.sparkwrappers.specific.OpEstimatorWrapper
import com.salesforce.op.utils.spark.{OpVectorColumnMetadata, OpVectorMetadata}
import org.apache.spark.ml.feature.{IDF, IDFModel}
Expand Down Expand Up @@ -74,7 +75,8 @@ trait RichVectorFeature {
* @param thresholds
* @return
*/
def randomForest(
def randomForest
(
label: FeatureLike[RealNN],
maxDepth: Int = 5,
maxBins: Int = 32,
Expand Down Expand Up @@ -132,13 +134,34 @@ trait RichVectorFeature {
* Allows columns to be dropped from a feature vector based on properties of the
* metadata about what is contained in each column (will work only on vectors)
* created with [[OpVectorMetadata]]
*
* @param matchFn function that goes from [[OpVectorColumnMetadata]] to boolean for dropping
* columns (cases that evaluate to true will be dropped)
* @return new Vector with columns removed by function
*/
def dropIndicesBy(matchFn: OpVectorColumnMetadata => Boolean): FeatureLike[OPVector] = {
new DropIndicesByTransformer(matchFn = matchFn).setInput(f).getOutput()
}

/**
* Apply filter that removes computed features that have variance <= `minVariance``
*
* @param minVariance
* @param removeBadFeatures
* @return
*/
def filterMinVariance
(
minVariance: Double = MinVarianceFilter.MinVariance,
removeBadFeatures: Boolean = MinVarianceFilter.RemoveBadFeatures
): FeatureLike[OPVector] = {
val filter = new MinVarianceFilter()
filter.setInput(f)
.setMinVariance(minVariance)
.setRemoveBadFeatures(removeBadFeatures)
.getOutput()
}

}

}
Loading