All Projects → titicaca → Spark Gbtlr

titicaca / Spark Gbtlr

Licence: apache-2.0
Hybrid model of Gradient Boosting Trees and Logistic Regression (GBDT+LR) on Spark

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Spark Gbtlr

Ytk Learn
Ytk-learn is a distributed machine learning library which implements most of popular machine learning algorithms(GBDT, GBRT, Mixture Logistic Regression, Gradient Boosting Soft Tree, Factorization Machines, Field-aware Factorization Machines, Logistic Regression, Softmax).
Stars: ✭ 337 (+316.05%)
Mutual labels:  spark, logistic-regression
Spark Website
Apache Spark Website
Stars: ✭ 75 (-7.41%)
Mutual labels:  spark
Thingsboard
Open-source IoT Platform - Device management, data collection, processing and visualization.
Stars: ✭ 10,526 (+12895.06%)
Mutual labels:  spark
Spark Twitter Stream Example
"Sentiment analysis" on a live Twitter feed with Apache Spark and Apache Bahir
Stars: ✭ 73 (-9.88%)
Mutual labels:  spark
Fast Mrmr
An improved implementation of the classical feature selection method: minimum Redundancy and Maximum Relevance (mRMR).
Stars: ✭ 67 (-17.28%)
Mutual labels:  spark
Apache Spark Hands On
Educational notes,Hands on problems w/ solutions for hadoop ecosystem
Stars: ✭ 74 (-8.64%)
Mutual labels:  spark
Coursera Ml Py
Python programming assignments for Machine Learning by Prof. Andrew Ng in Coursera
Stars: ✭ 1,140 (+1307.41%)
Mutual labels:  logistic-regression
Docker Spark
🚢 Docker image for Apache Spark
Stars: ✭ 78 (-3.7%)
Mutual labels:  spark
Cleanframes
type-class based data cleansing library for Apache Spark SQL
Stars: ✭ 75 (-7.41%)
Mutual labels:  spark
Labs
Research on distributed system
Stars: ✭ 73 (-9.88%)
Mutual labels:  spark
Kamu Cli
Next generation tool for decentralized exchange and transformation of semi-structured data
Stars: ✭ 69 (-14.81%)
Mutual labels:  spark
Usersessionbehaviorofflineanalysis
四川大学拓思爱诺用户session行为数据离线分析项目
Stars: ✭ 69 (-14.81%)
Mutual labels:  spark
Dataspherestudio
DataSphereStudio is a one stop data application development& management portal, covering scenarios including data exchange, desensitization/cleansing, analysis/mining, quality measurement, visualization, and task scheduling.
Stars: ✭ 1,195 (+1375.31%)
Mutual labels:  spark
Kontextfrei
Writing application logic for Spark jobs that can be unit-tested without a SparkContext
Stars: ✭ 67 (-17.28%)
Mutual labels:  spark
Home
ApacheCN 开源组织:公告、介绍、成员、活动、交流方式
Stars: ✭ 1,199 (+1380.25%)
Mutual labels:  spark
Deeplearning
Deep Learning From Scratch
Stars: ✭ 66 (-18.52%)
Mutual labels:  logistic-regression
Luigi Warehouse
A luigi powered analytics / warehouse stack
Stars: ✭ 72 (-11.11%)
Mutual labels:  spark
Lpa Detector
Optimize and improve the Label propagation algorithm
Stars: ✭ 75 (-7.41%)
Mutual labels:  spark
Setl
A simple Spark-powered ETL framework that just works 🍺
Stars: ✭ 79 (-2.47%)
Mutual labels:  spark
Ml code
A repository for recording the machine learning code
Stars: ✭ 75 (-7.41%)
Mutual labels:  logistic-regression

Spark-GBTLR

Build Status License

GBTLRClassifier is a hybrid model of Gradient Boosting Trees and Logistic Regression. It is quite practical and popular in many data mining competitions. In this hybrid model, input features are transformed by means of boosted decision trees. The output of each individual tree is treated as a categorical input feature to a sparse linear classifer. Boosted decision trees prove to be very powerful feature transforms.

Model details about GBTLR can be found in the following paper: Practical Lessons from Predicting Clicks on Ads at Facebook [1].

GBTLRClassifier on Spark is designed and implemented by combining GradientBoostedTrees and Logistic Regressor in Spark MLlib. Features are firstly trained and transformed into sparse vectors via GradientBoostedTrees, and then the generated sparse features will be trained and predicted in Logistic Regression model.

Usage

GBTLRClassifier is designed and implemented easy to use. Parameters of GBTLRClassifier are the same as the combined parameters of GradientBoostedTrees and LogisticRegression in MLlib.

Examples

The following codes are an example for predicting bank marketing results using Bank Marketing Dataset [2]. The data is related with direct marketing campaigns (phone calls) of a Portuguese banking institution. The classification goal is to predict if the client will subscribe a term deposit (variable y).

Scala API

def main(args: Array[String]): Unit = {
    val spark = SparkSession
        .builder()
        .master("local[2]")
        .appName("gbtlr example")
        .getOrCreate()

    val startTime = System.currentTimeMillis()

    val dataset = spark.read.option("header", "true").option("inferSchema", "true")
        .option("delimiter", ";").csv("data/bank/bank-full.csv")

    val columnNames = Array("job", "marital", "education",
      "default", "housing", "loan", "contact", "month", "poutcome", "y")
    val indexers = columnNames.map(name => new StringIndexer()
        .setInputCol(name).setOutputCol(name + "_index"))
    val pipeline = new Pipeline().setStages(indexers)
    val data1 = pipeline.fit(dataset).transform(dataset)
    val data2 = data1.withColumnRenamed("y_index", "label")

    val assembler = new VectorAssembler()
    assembler.setInputCols(Array("age", "job_index", "marital_index",
      "education_index", "default_index", "balance", "housing_index",
      "loan_index", "contact_index", "day", "month_index", "duration",
      "campaign", "pdays", "previous", "poutcome_index"))
    assembler.setOutputCol("features")

    val data3 = assembler.transform(data2)
    val data4 = data3.randomSplit(Array(4, 1))

    val gBTLRClassifier = new GBTLRClassifier()
        .setFeaturesCol("features")
        .setLabelCol("label")
        .setGBTMaxIter(10)
        .setLRMaxIter(100)
        .setRegParam(0.01)
        .setElasticNetParam(0.5)

    val model = gBTLRClassifier.fit(data4(0))
    val summary = model.evaluate(data4(1))
    val endTime = System.currentTimeMillis()
    val auc = summary.binaryLogisticRegressionSummary
        .asInstanceOf[BinaryLogisticRegressionSummary].areaUnderROC
    println(s"Training and evaluating cost ${(endTime - startTime) / 1000} seconds")
    println(s"The model's auc: ${auc}")

Benchmark

TO BE ADDED..

Requirements

Spark-GBTLR is built on Spark 2.1.1 or later version.

Build From Source

mvn clean package

Licenses

Spark-GBTLR is available under Apache Licenses 2.0.

Acknowledgement

Spark GBTLR is designed and implemented together with my former intern Fang, Jie at Transwarp (transwarp.io). Thanks for his great contribution. In addition, thanks for the supports of Discover Team.

Contact and Feedback

If you encounter any bugs, feel free to submit an issue or pull request. Also you can email to: Yang, Fangzhou ([email protected])

References

[1] He X, Pan J, Jin O, et al. Practical Lessons from Predicting Clicks on Ads at Facebook[J]., 2014: 1-9.

[2] Moro S, Cortez P, Rita P, et al. A Data-Driven Approach to Predict the Success of Bank Telemarketing[J]. Decision support systems, 2014, 62(62): 22-31.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].