依赖 Scala 2.11 与 Spark 2.4,版本不匹配会编译失败;README 未提供安装步骤,需自行查阅官方文档站点;示例代码需自备 Titanic 数据集路径
TransmogrifAI
salesforceBSD-3-Clause更新放缓基于 Apache Spark 的 AutoML 库,用强类型 DSL 搭建模块化、可复用的机器学习工作流,减少手工调参。
TransmogrifAI (pronounced trăns-mŏgˈrə-fī) is an AutoML library for building modular, reusable, strongly typed machine learning workflows on Apache Spark with minimal hand-tuning
README 未给出安装命令,仅指向文档站点 https://docs.transmogrif.ai 获取入门说明README 未说明具体硬件要求;运行在 Apache Spark 2.4 之上,需自备 Spark 集群或本地环境
基于 Spark 的 Scala AutoML 库,用强类型 API 快速搭建可复用的机器学习工作流
基于 Apache Spark 的 AutoML 库,用强类型 DSL 搭建模块化、可复用的机器学习工作流,减少手工调参。
核心能力
- 用 FeatureBuilder 从 DataFrame 自动抽取特征
- transmogrify 自动完成特征工程
- sanityCheck 自动做特征校验与筛选
- BinaryClassificationModelSelector 自动选模型
- OpWorkflow 串联训练并输出模型摘要
容易踩的坑
- 0.7.0最新正式版2020-06-11 · 2020-06-11 23:58 UTC
Bug fixes:
- Fix flaky
ModelInsighttests #407 - Remove logging of tokens of text fields #420, #438, #447, #474
- Add validation prepare call before model selection when no DAG is passed #424, #429
- Fix
Days.daysBetweenint overflow #471
New features / updates:
- Downsample the number of training samples to
maxTrainingSamplefor regression #413 and multi-class classification #414 - Refactor
InsightLOCOTest#412 - Enable more loss types for
OpLinearRegression#421 - Add property-based tests for regression model selection #427
- Add option to calculate LOCO for dates/texts by leaving out their entire vector #418
- Add Chinese and Korean examples to
TextTokenizerTest#442 - Add support for ignoring text that looks like IDs in
SmartTextVectorizer#448, #455 - Add a unary estimator for detecting names in text fields and transforming to likely gender #445
- Allow result features to be removed by raw feature filter #458
- Metadata changes for sensitive feature information #457
- Add
MinVarianceFilterwhich checks that computed features have a minimum variance #463, #465 - Allow
TextStatslength distribution to be token-based and refactor for testability #464 - Use Spark job grouping to distinguish steps of the machine learning flow #467, #468, #470
- Add categorical detection to be coverage based in addition to unique count based #473
- Remove duplicate features using sanity checker feature to feature correlations #476, #479
- Lift the upper bound on number of hash features #477
- Enable Html stripping on text-like features #478
Dependency updates (#402, #466):
- Update Apache Spark version to 2.4.5
- Avro is a built-in data source in Spark 2.4, so no longer using the spark-avro package
- Avro to 1.8.2
- XGBoost to 0.90
- MLeap to 0.14.0
- json4s to 3.5.3
- JUnit to 4.12
- chill to 0.9.3
- gradle-avro-plugin to 0.16.0
Miscellaneous:
- Add ROADMAP.md #394
- Fix flaky
- 0.6.12019-09-12 · 2019-09-12 00:30 UTC
查看更新说明
Bug fixes:
- Ensure correct metrics despite model failures on some CV folds #404
- Fix flaky
ModelInsighttests #395 - Avoid creating
SparseVectors for LOCO #377
New features / updates:
- Model combiner #385
- Added new sample for HousingPrices #365
- Test to verify that custom metrics appear in model insight metrics #387
- Add
FeatureDistributiontoSerializationFormats #383 - Add metadata to
OpStandadrdScalerto allow for descaling #378 - Improve json serde error in
evalMetFromJson#380 - Track mean & standard deviation as metrics for numeric features and for text length of text features #354
- Making model selectors robust to failing models #372
- Use compact and compressed model json by default #375
- Descale feature contribution for Linear Regression & Logistic Regression #345
Dependency updates:
- Update tika version #382
- 0.6.02019-07-12 · 2019-07-12 22:57 UTC
查看更新说明
Bug fixes:
- Quick Fix Alias Type Names #346
- Forecast Evaluator - fixes SMAPE, adds MASE and Seasonal Error metrics #342
New features / updates:
- Aggregate LOCOs of DateToUnitCircleTransformer. #349
- Convert lambda functions into concrete classes to allow compatibility with Scala 2.12 #357
- Replace mapValues with immutable Map where applicable #363
- Aggregate spark metrics during run time instead of post processing by default #358
- Allow customizing serialization for FeatureGenerator extract function #352
- Update helloworld examples to be simple #351
- Adding
keyctor field in all RawFeatureFilter results #348 - Forecast evaluator + SMAPE metric #337
- Local scoring for model with features of all types #340
- Remove local runner + update docs #335
- Added missing test for java conversions #334
- Get rid of scalaj-collections #333
- Workflow independent model loading #274
- Aggregated LOCOs of SmartTextVectorizer outputs #308
- Added community projects docs section #326
- Add FeatureBuilder.fromSchema #325
- Improve WeekOfMonth in date transformers #323
- Improved datetime unit transformer shortcuts - Part 2 #319
- Correctly pass main class for CLI sub project #321
- Serialize blacklisted map keys with the model + updated access on workflow/model members #320
- Improved datetime unit transformer shortcuts #316
- Improved OpScalarStandardScalerTest #317
- improved PercentileCalibratorTest #318
- Added concrete wrappers for HashingTF, NGram and StopWordsRemover #314
- Avoid singleton random generators #312
- Remove free function aggregation with feature builders #311
- Added util methods to create class/object by name + retrieve type tag by type name #310
Dependency updates:
- 0.5.32019-05-08 · 2019-05-08 21:16 UTC
查看更新说明
Bug fixes:
- Threshold metrics calculation fix when unseen labels are present #293
- DataCutter-related fixes for multiclass #263
- Fixed onSetInput so is always called with new input #280
New features / updates:
- Improved test SmartTextMapVectorizerTest #296
- Add check to raw feature filter for removing all features #303
- Spec-ifying ngram similarity tests #299
- Add random test feature generator to generate datasets with features of all types #298
- Spec-ifying NGramTest #297
- Added base spec for testing Spark wrapping transformers #295
- Add/upgrade string indexing tests #294
- Improved multi pick list map vectorizer test #292
- Improvements of Vectorizer tests #291
- Updated TextMapPivotVectorizerTest to use OpEstimatorSpec #290
- Update TextTokenizerTest to use OpTransformerSpec #289
- Add test for RealNNVectorizer #288
- Improved OPCollectionHashingVectorizerTest test #286
- Created new tests for OpCollection #285
- Update names of transformer tests and files to match class names #284
- Improved test by extending OpTransformerSpec #283
- Skip writing empty stages & skip loading stages without uid-s #282
- Skip serializing estimators + fix test + added empty data transform test #281
Dependency updates: N/A
- 0.5.22019-04-11 · 2019-04-11 03:05 UTC
查看更新说明
Bug fixes:
- Fixed local scoring with multipicklist features #243
- Fixed error messages in
DataCutterandDataBalancer#256 - Fixed bug in in model selector fit method #251
- Fixed some Transmogrifier defaults to be modifiable / exposed #232
- Fixed bug in
OpXGBoostClassificationModel#229 - Minor fixes / cleanup on notebooks, Helloworld examples, and developer guide #226, #230, #240, #259
New features / updates:
- Added transformer classes for common math operations #255, #257
- Added string transformers for substring search and valid email #265
- Added scaler and descaler transformers #223
- Added Raw Feature Filter results e.g., metrics, exclusion reasons to serialization and to
ModelInsights#237, #252, #258, #276 - Changed
OpBinScoreEvaluatorto allow for lift analysis #233 - Added random param builder for random hyperparameter search in model selectors #238
- Added possibility to return top K positives and top K negatives improvement for LOCO #264
- Added a max cardinality percentage that can be set for pivot #241
- Added minimum rows for scoring set in
RawFeatureFilter#250 - Allowed copying model instances across multiple threads #270
- Added stub to allow loading models without workflow #269, #272
- Made decision tree numeric bucketizer tests less flaky #225
- Added Jupyter notebooks for samples #231
Dependency updates:
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
TransmogrifAI
TransmogrifAI (pronounced trăns-mŏgˈrə-fī) is an AutoML library written in Scala that runs on top of Apache Spark. It was developed with a focus on accelerating machine learning developer productivity through machine learning automation, and an API that enforces compile-time type-safety, modularity, and reuse. Through automation, it achieves accuracies close to hand-tuned models with almost 100x reduction in time.
Use TransmogrifAI if you need a machine learning library to:
- Build production ready machine learning applications in hours, not months
- Build machine learning models without getting a Ph.D. in machine learning
- Build modular, reusable, strongly typed machine learning workflows
To understand the motivation behind TransmogrifAI check out these:
- Open Sourcing TransmogrifAI: Automated Machine Learning for Structured Data, a blog post by @snabar
- Meet TransmogrifAI, Open Source AutoML That Powers Einstein Predictions, a talk by @tovbinm
- Low Touch Machine Learning, a talk by @leahmcguire
Skip to Quick Start and Documentation.
Predicting Titanic Survivors with TransmogrifAI
The Titanic dataset is an often-cited dataset in the machine learning community. The goal is to build a machine learnt model that will predict survivors from the Titanic passenger manifest. Here is how you would build the model using TransmogrifAI:
import com.salesforce.op._
import com.salesforce.op.readers._
import com.salesforce.op.features._
import com.salesforce.op.features.types._
import com.salesforce.op.stages.impl.classification._
import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession
implicit val spark = SparkSession.builder.config(new SparkConf()).getOrCreate()
import spark.implicits._
// Read Titanic data as a DataFrame
val passengersData = DataReaders.Simple.csvCase[Passenger](path = pathToData).readDataset().toDF()
// Extract response and predictor Features
val (survived, predictors) = FeatureBuilder.fromDataFrame[RealNN](passengersData, response = "survived")
// Automated feature engineering
val featureVector = predictors.transmogrify()
// Automated feature validation and selection
val checkedFeatures = survived.sanityCheck(featureVector, removeBadFeatures = true)
// Automated model selection
val pred = BinaryClassificationModelSelector().setInput(survived, checkedFeatures).getOutput()
// Setting up a TransmogrifAI workflow and training the model
val model = new OpWorkflow().setInputDataset(passengersData).setResultFeatures(pred).train()
println("Model summary:\n" + model.summaryPretty())
Model summary:
Evaluated Logistic Regression, Random Forest models with 3 folds and AuPR metric.
Evaluated 3 Logistic Regression models with AuPR between [0.6751930383321765, 0.7768725281794376]
Evaluated 16 Random Forest models with AuPR between [0.7781671467343991, 0.8104798040316159]
Selected model Random Forest classifier with parameters:
|-----------------------|--------------|
| Model Param | Value |
|-----------------------|--------------|
| modelType | RandomForest |
| featureSubsetStrategy | auto |
| impurity | gini |
| maxBins | 32 |
| maxDepth | 12 |
| minInfoGain | 0.001 |
| minInstancesPerNode | 10 |
| numTrees | 50 |
| subsamplingRate | 1.0 |
|-----------------------|--------------|
Model evaluation metrics:
|-------------|--------------------|---------------------|
| Metric Name | Hold Out Set Value | Training Set Value |
|-------------|--------------------|---------------------|
| Precision | 0.85 | 0.773851590106007 |
| Recall | 0.6538461538461539 | 0.6930379746835443 |
| F1 | 0.7391304347826088 | 0.7312186978297163 |
| AuROC | 0.8821603927986905 | 0.8766642291593114 |
| AuPR | 0.8225075757571668 | 0.850331080886535 |
| Error | 0.1643835616438356 | 0.19682151589242053 |
| TP | 17.0 | 219.0 |
| TN | 44.0 | 438.0 |
| FP | 3.0 | 64.0 |
| FN | 9.0 | 97.0 |
|-------------|--------------------|---------------------|
Top model insights computed using correlation:
|-----------------------|----------------------|
| Top Positive Insights | Correlation |
|-----------------------|----------------------|
| sex = "female" | 0.5177801026737666 |
| cabin = "OTHER" | 0.3331391338844782 |
| pClass = 1 | 0.3059642953159715 |
|-----------------------|----------------------|
| Top Negative Insights | Correlation |
|-----------------------|----------------------|
| sex = "male" | -0.5100301587292186 |
| pClass = 3 | -0.5075774968534326 |
| cabin = null | -0.31463114463832633 |
|-----------------------|----------------------|
Top model insights computed using CramersV:
|-----------------------|----------------------|
| Top Insights | CramersV |
|-----------------------|----------------------|
| sex | 0.525557139885501 |
| embarked | 0.31582347194683386 |
| age | 0.21582347194683386 |
|-----------------------|----------------------|
While this may seem a bit too magical, for those who want more control, TransmogrifAI also provides the flexibility to completely specify all the features being extracted and all the algorithms being applied in your ML pipeline. Visit our docs site for full documentation, getting started, examples, faq and other information.
Adding TransmogrifAI into your project
You can simply add TransmogrifAI as a regular dependency to an existing project. Start by picking TransmogrifAI version to match your project dependencies from the version matrix below (if not sure - take the stable version):
| TransmogrifAI Version | Spark Version | Scala Version | Java Version |
|---|---|---|---|
| 0.7.1 (unreleased, master), 0.7.0 (stable) | 2.4 | 2.11 | 1.8 |
| 0.6.1, 0.6.0, 0.5.3, 0.5.2, 0.5.1, 0.5.0 | 2.3 | 2.11 | 1.8 |
| 0.4.0, 0.3.4 | 2.2 | 2.11 | 1.8 |
For Gradle in build.gradle add:
repositories {
jcenter()
mavenCentral()
}
dependencies {
// TransmogrifAI core dependency
compile 'com.salesforce.transmogrifai:transmogrifai-core_2.11:0.7.0'
// TransmogrifAI pretrained models, e.g. OpenNLP POS/NER models etc. (optional)
// compile 'com.salesforce.transmogrifai:transmogrifai-models_2.11:0.7.0'
}
For SBT in build.sbt add:
scalaVersion := "2.11.12"
resolvers += Resolver.jcenterRepo
// TransmogrifAI core dependency
libraryDependencies += "com.salesforce.transmogrifai" %% "transmogrifai-core" % "0.7.0"
// TransmogrifAI pretrained models, e.g. OpenNLP POS/NER models etc. (optional)
// libraryDependencies += "com.salesforce.transmogrifai" %% "transmogrifai-models" % "0.7.0"
Then import TransmogrifAI into your code:
// TransmogrifAI functionality: feature types, feature builders, feature dsl, readers, aggregators etc.
import com.salesforce.op._
import com.salesforce.op.aggregators._
import com.salesforce.op.features._
import com.salesforce.op.features.types._
import com.salesforce.op.readers._
// Spark enrichments (optional)
import com.salesforce.op.utils.spark.RichDataset._
import com.salesforce.op.utils.spark.RichRDD._
import com.salesforce.op.utils.spark.RichRow._
import com.salesforce.op.utils.spark.RichMetadata._
import com.salesforce.op.utils.spark.RichStructType._
Quick Start and Documentation
Visit our docs site for full documentation, getting started, examples, faq and other information.
See scaladoc for the programming API.
Authors
- Kevin Moore @jauntbox
- Kin Fai Kan @kinfaikan
- Leah McGuire @leahmcguire
- Matthew Tovbin @tovbinm
- Max Ovsiankin @maxov
- Michael Loh @mikeloh77
- Michael Weil @michaelweilsalesforce
- Shubha Nabar @snabar
- Vitaly Gordon @vitalyg
- Vlad Patryshev @vpatryshev
Internal Contributors (prior to release)
- Chris Rupley @crupley
- Chris Wu @cjwooo
- Eric Wayman @ericwayman
- Felipe Oliveira @feliperazeek
- Gera Shegalov @gerashegalov
- Jean-Marc Soumet @ajmssc
- Marco Vivero @marcovivero
- Mario Rodriguez @mrodriguezsfiq
- Mayukh Bhaowal @mayukhb
- Minh-An Quinn @minhanquinn
- Nicolas Drizard @nicodri
- Oleg Gusak @ogusak
- Patrick Framption @tricktrap
- Ryle Goehausen @ryleg
- Sanmitra Ijeri @sanmitra
- Sky Chen @almandsky
- Sophie Xiaodan Sun @sxd929
- Till Bergmann @tillbe
- Xiaoqian Liu @wingsrc
License
BSD 3-Clause © Salesforce.com, Inc.