Spark Models - Rules-Based Learning
local graph
Chapter 12 — Spark Models - Rules-Based Learning
Section titled “Chapter 12 — Spark Models - Rules-Based Learning”In this section, we will learn how to implement some rule-based algorithms. The method in which these algorithms can be implemented depends upon the language interface you are using and the version of Spark which is running.
For Spark 2.0, the only languages which support rule-based decision trees are Scala and Python. So in order to demonstrate how decision rules can be constructed directly in Spark, we will illustrate an example that uses Python to determine the rules for being frisked.
For other languages, such as R, there is currently no facility to run a decision tree algorithm directly on a Spark dataframe; however, there are other methods that can be used which will yield accurate trees.
We will demonstrate how to first extract a sample from Spark, download it to base R, and run our usual tools, such as rpart. Big datasets will typically contain much more data than you might need for a decision tree, so it makes perfect sense to sample appropriately from your big data source, extract the data from Spark to R, and run your standard tools.
We will introduce the One Rule (OneR) package to see how each single variable is able to predict the outcome. The philosophy of OneR being less is more, we will demonstrate how OneR can optimally bin your numeric values and determine what your top predictors are using decision tree rules. You can also use the OneR package to perform feature selection.
We will be using the diabetes dataset which was constructed in the last chapter. For some of the other decision tree examples, we will need to load the stop and frisk dataset. You can obtain this dataset from the following URL: http://www1.nyc.gov/site/nypd/stats/reports-analysis/stopfrisk.page.
Select the 2015 CSV zip archive and download and extract the files to the projects directory, e.g C:/PracticalPredictiveAnalytics/Data, and name the file 2015_sqf_csv
Databricks contains a simple user interface which allows you to load a file to the Databricks HDFS filesystem. Alternatively, you can load the file directly to Amazon Web Services (AWS) and read the file directly from the Databricks API.
- Switch to the Databricks application, select Tables, and then Data Import. Note that in some of the versions of Databricks this is embedded under the Data menu: Select “Tables”, and then click the +.
- You may be prompted to create a new cluster. If so, first follow the instructions for creating a new cluster as we did in Chapter 9.
- Drag the file named 2015_sqf_csv from the PracticalPredictiveAnalytics directory to the data import box, as shown next:

- Click on Preview Table.
- Enter Table name as stopfrisk.
- Observe how the variables have been assigned (they are all assigned as character strings); however, do not change any of the attributes. Simply click on Create Table (the blue button on the left):

Once you have completed the preceding steps, the table you have just created will be registered in the databricks system and will remain persistent across sessions, i.e you will not need to reload the data every time you login.
Begin by running the first cell (also referred to as a code chunk), which simply will get a count of the number of records by year. You can access the code in this chapter by downloading it from the book’s site. Alternatively, you can copy each section of the following code into a new cell and create your own notebook that way.
Since stop frisk has been imported and has already been registered as a table, we can begin to use SQL to read it some of the counts in order to see how large the file is:
#embed all SQL within the sql() function
yr <- sql("SELECT year,frisked,count(*) as year_cnt FROM stopfrisk group by year,frisked")display(yr)After a few seconds, the output will appear as a simple formatted table. A simple calculation using the year_cat column shows that for 2015, 68% of those who where stopped, were also frisked:

Now that we have some aggregate counts, we have some idea of what we will be looking at. So we will read the entire file into a Spark dataframe via SQL and print the first record (you can print more if you like).
Just by looking at the first record(s), you can see that there are a mix of binary yes/no flags and some numeric variables:
df <- sql("SELECT * FROM stopfrisk")head(df,1)
If you run an str() function on the variables in the dataframe, you will see that all of them are of type chr (character). We also saw that in the import file dialog:
str(df)
We will want some of these variables to be integers, so we can use the cast() function to change some of them. Also, clean up some of the leading and trailing spaces using the trim() function:
df$age <- cast(trim(df$age),'integer')df$perstop <- cast(df$perstop,'integer')df$perobs <- cast(df$perobs,'integer')df$ser_num <- cast(df$ser_num,'integer')df$datestop <- cast(df$datestop,'integer')df$timestop <- cast(df$timestop,'integer')df$repcmd <- cast(df$repcmd,'integer')df$revcmd <- cast(df$revcmd,'integer')df$compyear <- cast(df$compyear,'integer')df$comppct <- cast(df$comppct,'integer')df$ht_feet <- cast(df$ht_feet,'integer')df$ht_inch <- cast(df$ht_inch,'integer')
df$height <- df$ht_feet*12+df$ht_inchdf$weight <- cast(df$weight,'integer')
str(df)At the end of the code we run the str() function, in order to verify that these variables have been changed to integers. You will also see that one extra variable has been created (height) which has been calculated as feet*12 + inches. For our purposes, it is not necessary to keep separate variables for both height in feet and height in inches:
Here is the first page of the output of the str(). Note that ser_num,datestop, timestop,perobs, and perstop have been mapped to integer.

We will now introduce the OneR package to discover some of the important features of the dataset. The OneR package will produce a single decision rule for each of the features and then rank them in terms of accuracy. Accuracy is defined as the probability of classifying the outcome correctly and can be expressed as a confusion or error matrix, which we have seen before in the previous chapters. The OneR package has some other nice features, such as the ability to bin integer variables optimally in order to yield the best predictor.
The OneR package does not run natively on Spark, so we first need to use the collect() and sample() functions to perform a 95% sample of the Spark dataframe and then move it to a local R dataframe via the collect() function.
Although this Spark dataframe is small enough to perform the example without the sampling, it is important to know how to sample from a dataframe, since if you are using Spark as intended, your dataframes will be too large to use the collect function to bring the entire dataframe into a local instance of R. For extremely large Spark tables, you may want to use a sampling percentage of 5-10% or so for an initial analysis. However, for our example we will use a sampling percentage of 95% to capture most of the data, since the 2015 stop and risk data is relatively small. However, if you were bringing in all of the years’ data and concatenating it into one big Spark dataframe, you would consider bringing down the sampling percentage to a more reasonable number. Otherwise, you might end up with more rows than base R could handle.
Also note that the OneR package is not currently available as a default installed package. But you can use devtools to install the latest version from cran:
devtools::install_github("cran/OneR")library(OneR)
#bring 95% of the rows from the Spark dataframe named "df" into a base R dataframe named "local"
local = collect(sample(df, F,.95))Since the dataset is very granular for some of the features such as zip code and GPS location variables, we will first perform a dimension reduction by only including features/variables with a maximum of 20 levels. That will help us formulate models later without worrying about overfitting due to some variables that having high dimensionality. However, the number 20 is not set in stone; you can change the default and always keep variables which you feel are needed in the model regardless of levels.
OneR has a function named maxlevels() which can accomplish this. Any variable which has a number of levels exceeding this is not included in the output.
After running the function, use the str() function to verify some variables have been eliminated. We originally started with 113 variables and now are down to 97. Some of the variables, such as the x and y coordinates, have been eliminated since GPS coordinates obviously have more than 20 levels:
frisked_df <- maxlevels(local, maxlevels = 20, na.omit = TRUE)#check the output to see if the number of levels were reducedstr(frisked_df)Observe the first 3 lines of the output showing that the number of variables has been reduced from 113 to 97:

Of course, we will want to partition the data into test and training datasets. We have covered many ways to separate into test and train. This next method of partitioning will take a 80%/20% training/test split by:
- first extracting the index numbers from the training dataset. We will use the base::sample function to accomplish this
- building the training dataset from these indices
- constructing the test dataset from the rows which are not contained in the index.
Once we obtain the train indices, we will use the optbin function from the OneR package, which will optimally split a numeric variable based upon its ability to predict a Yes or No outcome for frisked. We have already seen this kind of optimal splitting with Decision Trees. In the code below optbin is directed to find the best split point for all of the numerical variables as indicated by specifying frisked~.
set.seed(123)train.index <- base::sample(1:base::nrow(frisked_df), 0.80 * base::nrow(frisked_df))train_data <- optbin(frisked_df[train.index,],frisked~.)test_data <- optbin( frisked_df[-train.index,],frisked~.)
#after partitioning, run a summary of the first 15 rows to see what the output looks like
summary(train_data[1:15])
In the preceding output, observe that each numeric variable has been transformed into one of the two categorical bins. The two-binned categories are represented by starting and ending ranges separated by (,). They are easy to pick out since summary indicates them with a beginning ( and an ending ]:
Take a look at the train_dataset using the special Databricks display command.
display(train_data)
The syntax to the OneR model should be familiar. The outcome variable frisked is specified on the left side of the formula (~) and the features are specified on the right side. As you will recall, the metacharacter (.) designates that all features will be used as predictors:
model <- OneR(train_data, frisked ~ ., verbose = TRUE)summary(model)The (partial) summary output displays the accuracy based upon selecting only one variable as a predictor along with its classification rate. The significant variables are starred.
The attribute and the accuracy metrics for the first 7 variables are shown next. Notice that once accuracy reaches 67.61% it does not decrease:

The call to the function is shown in the log, and the Decision Tree rules are displayed.

The output from the summary gives a good sense of the importance of each variable as an individual predictor. All of the accuracy measures range from 67.61% to 68.56%, so there is no obvious one single variable which can predict being frisked much better than the others.
However, the top ranked variable is sex with a 68.56% accuracy rate. The one simple rule that will classify the outcome into frisked or nonfrisked is:
If sex is male or unknown, then the outcome was predicted correctly 68.56% of the time.
This is reflected in the following two manually calculated contingency tables, in which an asterisk * signifies a correct classification (the following background is green). I added the second contingency table manually, which gives percentages instead of the raw counts supplied by the output.
The following is a confusion matrix with counts and percentages:

- If sex= M, then being frisked was correctly predicted 64% of the time.
- If sex= F, then not being frisked was correctly predicted 4% of the time.
Although this is a small percentage, you can see that males, in general, are stopped much more than females. You can also derive some conditional probabilities from this, in that, if you are a female, there is a 3/7 or 43% chance that you will be frisked. However, if you are a male, there is a 64/92 or 70% chance that you will be frisked.
If sex= Z (unknown), being frisked was correctly predicted 1% of the time.
Even though OneR works by finding the single best predictor, we can also try to improve the predictions by constructing some new variables and tricking OneR into thinking it is one variable.
In the code below we are creating new variables by combining attributes of single variables such ass of build, eyecolor, and hair color. After running the OneR model again, you can see that it helps a bit in terms of prediction accuracy and one of the new variables (eye_hair_build) is now ranked second.
This is a simple example of how you can perform “feature engineering”.
tmp <- train_datatmp$eye_hair_build <- paste(train_data$eyecolor,train_data$haircolr,train_data$build)tmp$weapon <- paste(train_data$knifcuti,train_data$riflshot,train_data$pistol,train_data$machgun,train_data$othrweap)model <- OneR(tmp, frisked ~ ., verbose = TRUE)
The eval_model function applies the rules of the prediction to the test data, and also produces the confusion matrix, for both absolute counts, and relative percentages, so there is no need to calculate the percentages manually, as we did above.
Applying the model results on the test sample shows the accuracy to be similar to the training sample, which somewhat validates the results.
The error rate is the percentages of wrong classifications, which is equivalent to 1 minus the accuracy rate:
prediction <- predict(model, test_data,type="class")#Evaluate prediction statistics
eval_model(prediction, test_data)
This example uses the much larger diabetes dataset. Since most of the variables in this dataset are numeric, OneR can bin all of them:
- First, read the Spark diabetes table using SQL, which has already been registered in a previous chapter.
- Collect a 15% random sample of the data and assign it to an R (not Spark!) dataframe named “local”.
- Bin all of the available variables based upon their ability to predict the outcome and assign it to an R dataframe named “data”:
library(OneR)df = sql("SELECT outcome, age, mass, triceps, pregnant,glucose, pressure, insulin, pedigreeFROM global_temp.df_view")
local = collect(sample(df, F,.15))
data <- optbin(local,outcome~.)summary(data)
4. Run the OneR model using all of the variables to predict the outcome. Recall that the outcome is an indication of whether or not diabetes is present:
model <- OneR(data, outcome~., verbose = TRUE)summary(model)
prediction <- predict(model, data)- Evaluate the prediction statistics. Observe that Glucose and insulin have much better single variable accuracy results than do the other predictors:
eval_model(prediction, data)
Now that we know the important variables, it is time to examine how the OneR package outputs the decision rules. Since glucose was deemed the single best predictor, the decision rule for predicting diabetes is shown under the Rules: section, and the optimal cutoff point (139) for glucose is displayed in the contingency table as shown below.

Now, look at the confusion matrix contingency tables-one for the absolute counts and the other for the relative percentages.
For our example, a glucose level greater or equal to 139 predicts diabetes in 18% of the total cases. However, note that most of the predictive power comes from predicting the nonevent. That is to say that 56% of the correct prediction comes from glucose reading of less than 139, which predicts the absence of diabetes. This is valuable in that it may lead to determine the factors which prevent diabetes, however we may also want to be interested in the the accuracy of a model which is able to predict diabetes as well.
This would involve digging deeper into the interactions of the variables, and would require a more sophisticated algorithm. However, OneR does offer an interesting framework for variable selection.

While OneR is very good at determining simple classification rules, it is not able to construct full decision trees. However, we can extract a sample from Spark and route it to any R decision tree algorithm, such as rpart.
To illustrate this, let’s first take a 50% sample of the stop and frisk dataframe. We also want to make sure that the amount of data we extract can be processed easily by base R, which has a memory limitation that is dependent upon the CPU size.
- The code below will first extract a 50% sample from Spark and store it in a local R dataframe named dflocal.
- Then it will run an str() command to verify the rowcount and the metadata:
dflocal = collect(sample(df, F,.50,123))str(dflocal)The output indicates that there are 11,311 rows, which is roughly 50% of the 22,563 rows from the Stop and Frisk data.

We will run our rpart algorithm as a regression tree. Recall that a regression tree is used when the output variable is in numerical form, rather than nominal form. Before we do that, we need to map our frisked=Y/N to frisked=1/0 and specify method=“anova” in the call.
The last line of code (fit) will print out the decision rules to the console as text.
The height, sex, age, and city parameters appear as the primary splits:
set.seed(123)library(rpart)dflocal$frisked_bin <- ifelse(dflocal$frisked=="Y",1,0)fit <- rpart(frisked_bin ~ sex + age + weight + height + perstop + city , method="anova", maxdepth=3, cp=.001, data=dflocal)fit
It is much easier to look at a visual representation of a tree. So you will need to install rpart.plot (if you haven’t already) so that you are able to view it.
We can see that the first rule corresponds to the primary rule (splitting on Gender), which was generated by the OneR package earlier in this chapter.
devtools::install_github("cran/rpart.plot")library(rpart.plot)rpart.plot(fit,cex=.75)
In this example, we ran a decision tree in R by extracting a sample from the Spark dataframe and running the tree model using base R. While that is perfectly acceptable (since it forced you to think about sampling), in many instances it would be more efficient to run the models directly on the Spark dataframe using a MLlib package or equivalent.
For the version of Spark, you should be working with (2.1); decision tree algorithms are not available to be run under R. Fortunately, native Spark decision trees are already implemented in Python and Scala. We will illustrate the example using Python so that you can see that there are options available. If you will be following algorithm development in Spark you will find that often algorithms are written first in Scala, since that is the native Spark language.
Here are some notes on the Python decision tree code which appears below.
For the first code chunk, notice the “magic” directive in the first line of the code. The magic directive begins with ’%’ and specifies which language or API you will be using. Therefore, since we will be using Python instead or R, we need to specify %python as the first line. That is because the notebook was originally set up as an R notebook. When mixing languages, you need to specify the language used as the first line, unless you are writing in the default notebook language.
For those of you who are not familiar with Python, the import directives at the top of the code import the needed libraries and modules, which are to be used by Python, similar to how the library function is used in R. If you do not supply import directives, you will usually get errors.
The first code chunk will read the StopFrisk dataframe, similar to how it was performed earlier in this section using spark.sql. Observe that the syntax for sql using Python is very similar to what we have been using with R.
Within the SQL call, the outcome variable frisked is mapped to a binary variable using a CASE statement. The reason for doing this is that the MLLib algorithm handles integer data much better than character data. If using character data, it often needs to be mapped to an integer or a labeled point.
The resulting dataframe (df2) is then displayed using the show(5) function, which is the Python equivalent to the R head(df2,5) function:
%python
from pyspark.mllib.tree import DecisionTree, DecisionTreeModelfrom pyspark.mllib.util import MLUtilsimport pyspark.mllibimport pyspark.mllib.regressionfrom pyspark.mllib.regression import LabeledPointfrom pyspark.sql.functions import *from pyspark.ml.feature import StringIndexer
df2 = spark.sql("SELECT case when frisked='Y' THEN 1 else 0 END as frisked2,case when sex='M' THEN 0 else 1 END as sex2, race, age, weight FROM stopfrisk")
df2.show(5)
Indexing is used to optimize data access and supply the parameters to specific machine learning algorithms in an acceptable format.
We will be incorporating the race variable into the decision tree model, so the first step is to determine what the different values of race are. We will do this by again using SQL to count the frequency by race. Notice we can say either “Group by Race” or “Group by 1” which is a shorthand reference to the first column specified in the select statement (which is race):
%pythondfx = spark.sql("SELECT race,count(*) FROM stopfrisk group by 1")dfx.show()Observe that there are eight values, Q, B, U, Z, A, W, I, and P:

Next, use indexer.fit(df2) transform. This will map a string factor (race) to a numeric index (race_indexed):
%pythonindexer = StringIndexer(inputCol="race", outputCol="race_indexed")df3 = indexer.fit(df2).transform(df2)df3.show(15)#drop race for the final dataframedf4 = df3.drop("race")Look at the pairs of race and race_indexed to see how a number will be used in place of a character:

We are looking at just a few records of the output. What we really want to see are all the values of race, along with their counts. We can use the CountDistinct clause in PySpark SQL to obtain that:
%pythondf3.registerTempTable("df3")
countDistinctDF_sql = sqlContext.sql("SELECT race,race_indexed, count(race) FROM df3 GROUP BY race, race_indexed")countDistinctDF_sql.show()All of the values of race and its corresponding index are then displayed, along with the counts:

We still need a codebook to decode the values of race, to make sure we understand what they designate.
race A ASIAN/PACIFIC ISLANDER B BLACK I AMERICAN INDIAN/ALASKAN NATIVE P BLACK-HISPANIC Q WHITE-HISPANIC W WHITE X UNKNOWN Z OTHERThe decision tree algorithm we will be using is from the standard Spark MLlib library. This implementation requires that the input be formatted in labeled point format. Labeled points assist in specifying which of the variables are target variables and which ones are features.
For this example, the target variable (frisked2) is the first variable listed (we will call the first variable column 0), so the target variable is designated as such within the LabeledPoint call as line[0].
The independent variables, or features, are contained within the remaining columns and are specified as line[1:]. This is shorthand for column 1 and all the following columns until there are no more.
When referring to features, they are also numbered sequentially in the model, corresponding to the order in which they appear in the dataframe. For our model, they have the following nomenclature:
- Feature 0 - Sex
- Feature 1 - Age
- Feature 2 - Weight
- Feature 3 - Race
Since this is an RDD-based model, first map the dataframe to an RDD using labeled points, by first specifying the target variable, followed by the features:
%pythonrdd1 = df4.rdd.map(lambda line:LabeledPoint(line[0],[line[1:]]))Print a portion of the resultant RDD. Debugging the output from an RDD can be difficult; however, you can see from the output that the first key pair of each labeled point is a 1 or 0. The second key pair (enclosed in brackets) is a vector of features, which you can match up to the predictors and scrutinize to make sure your labeled points are correct:
print rdd1.take(5)
(1) Spark Jobs[LabeledPoint(1.0, [0.0,33.0,190.0,2.0]), LabeledPoint(1.0, [0.0,14.0,140.0,0.0]), LabeledPoint(0.0, [0.0,14.0,140.0,0.0]), LabeledPoint(0.0, [0.0,14.0,180.0,0.0]), LabeledPoint(0.0, [0.0,13.0,160.0,0.0])]Remember we discussed the mapping of categorical features? Use the categorical features info parameter to specify which of the variables are truly categorical, that is, not just mapped to an index.
For our example, Frisked has two levels, so it is specified as 0:2 (the target variable with 2 levels) and Race has 8 levels, so it is specified as 3:8 (the third feature having 8 levels):
Set other parameters appropriate to the decision tree model:
- numClasses: This applies to the number of outcomes; in our case, it is 2.
- maxDepth: How deep would you like the decision tree to go? For illustrative purposes, we will set it to 2 levels deep, but for real-world problems, you should attempt to go a bit deeper. Remember, if you go too deep, the model will overfit.
- maxBins: In sparkR, you can go no more than 32 bins.
Now we are set and we can run our model. We will create a simple tree, no more than two levels deep:
%python
model_train = DecisionTree.trainClassifier(rdd1,numClasses=2,maxDepth=2,maxBins=32,categoricalFeaturesInfo={0:2,3:8} )After the model has completed, print it as a text file using the DebugString() function. That will give you your decision tree rules:
print(model_train.toDebugString())
In order to code what feature 0,1,2 and 3 mean, we will need to map the feature number to the feature names, and the resulting value of the features using the codebook and SQL code we ran earlier.
We can manually condense the output to simple English descriptions especially since the decision tree output sometimes gives nonsensical or redundant rules. See if you can spot it in the preceding code!
If sex is equal to 1 (Female) if weight <= 154 then subject was NOT frisked Else if weight > 154 then Subject WAS friskedIf sex is NOT equal to 1 (Male) BOTH race paths lead to Subject WAS friskedSometimes with small trees, the decision rules can be too trivial or obvious. In this can, it often makes sense to increase the number of nodes in the tree. Here we will be generating a tree 15 levels deep:
%pythonrdd1 = df4.rdd.map(lambda line:LabeledPoint(line[0],[line[1:]]))rdd1.take(15)model_train = DecisionTree.trainClassifier(rdd1,numClasses=2,maxDepth=15,maxBins=32,categoricalFeaturesInfo={0:2,3:8} )print(model_train.toDebugString())Again, some of the rules look like they are redundant, so more work would be needed to transform this output to meaningful business rules.

Unless you are able to visualize the output, the decision tree rules can get difficult to interpret. Unless you implement the decision tree in the Scala language (which has a tree visualization method using the databricks Display command), some of your options are:
First parse the Spark output object to JSON format and then input using D3.js to visualize the tree. There are some prebuilt packages on Github, which can assist you in doing this.
Write the RDD you create to a file, input the RDD in Scala, and run DecisionTreeClassifier(). Then, fit the model and use the databricks display command on the model to display the tree.
There is no prediction method for decision trees. However, we can still generate trees from both test and training datasets and compare them for reasonableness.
Using our diabetes example, we can first run a Pyspark decision tree on the training data. Again, our outcome variable is the first column (#0), which is referenced in the LabeledPoint reference, and the features are designated by all the variables that follow (1:):
%python
df = spark.sql("SELECT outcome, age, mass, triceps, pregnant, glucose, pressure, insulin, pedigree FROM global_temp.df_view")
#sqlDF.show()
rdd1 = df.rdd.map(lambda line:LabeledPoint(line[0],[line[1:]]))
model_train =DecisionTree.trainClassifier(rdd1,numClasses=2,maxDepth=2,maxBins=32,categoricalFeaturesInfo={})
print(model_train.toDebugString())The decision tree has identified features 4 (glucose) and 6 (insulin) as the two most important splitting variables. These two variables are a good choice since they both affect blood sugar levels:

Now, run the same code on the testing data. The results are similar; however, the tree reverses the order of features 6 and 4. In the real world that would be acceptable, but if we produced a completely different tree, we would need to look at why the two models differed and try to reconcile the different versions of the model. If you could not explain the differences, you might consider reworking or even abandoning the model if there were gross discrepancies:
%python
test = spark.sql("SELECT outcome, age, mass, triceps, pregnant, glucose, pressure, insulin, pedigree FROM global_temp.test_view")
rdd2 = test.rdd.map(lambda line:LabeledPoint(line[0],[line[1:]]))
model_test = DecisionTree.trainClassifier(rdd2,numClasses=2,maxDepth=2,maxBins=32,categoricalFeaturesInfo={})
#model.save(spark, "/myDecisionTreeClassificationModel")
print(model_test.toDebugString())
This concludes this chapter, and this book. I started off by saying that this was a different kind of predictive analytics book, and I covered many different kinds of topics, from both a technical and conceptual viewpoint. I hope that you have learned a lot from this and that it has given you some new algorithms to use, and has taught you something about some ‘older’ tools, such as SQL, which are very capable of doing some of the heavy lifting that is sometimes needed. I also tried to emphasis ‘small data’, metadata, and sampling in the hopes that that will aid you in understand your data better, just by virtue of being able to look at individual pieces separately. I also hope that some of the material in the book will enable you to work collaboratively with different team members having different skill sets. That could be anything from someone who is an expert in optimizing code, or someone who is an expert in statistics, or even someone who has worked with all of the key people in your business and is able to communicate business needs and wants. Yes, it is great to be able to do it all, but Predictive Analytics is as much about listening, as it as about doing.
Much of what I discuss is applicable to any type of analytics projects you will be involved in, regardless of language or platform choice. That is why I wanted to include some cloud computing and SQL examples at the end, as well as a Python example, to demonstrate that Predictive Analytics practitioners can band together with different skill sets and integrate their work within the 6 steps that were discussed earlier in this book in order to implement a successful analytics methodology and framework.
Happy modeling!