Netherlands: Software

Introductie van Micorosoft SQL Server 2016

Issue link: http://hub-nl.insight.com/i/692679

Contents of this Issue

Navigation

Page 132 of 212

120 C H A P T E R 6 | More analytics FROM nyctaxi_sample tablesample (1 percent) repeatable (98052)" modelDataSource = RxSqlServerData(sqlQuery = modelQuery, colClasses = c(pickup_longitude = "numeric", pickup_latitude = "numeric", dropoff_longitude = "numeric", dropoff_latitude = "numeric", passenger_count = "numeric", trip_distance = "numeric", trip_time_in_secs = "numeric", direct_distance = "numeric"), connectionString = connStr) Predictive model creation After preparing your data, you can create a model by using any of the functions available in the RevoScaleR package. The RxLogit function is a good choice for classification problems. It uses logistic regression to estimate the probability of a variable with two possible values. In the sample code shown in Example 6-8, the goal is to predict whether a tip was given. The summary function provides statistical information about the resulting model, as shown in Figure 6-19. Example 6-8: Creating a logistic regression model logitObj <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + direct_distance, data = modelDataSource) summary(logitObj) Figure 6-19: Viewing the summary of a logistic regression predictive model. Note To learn more about the rxLogit function, see http://www.rdocumentation.org/packages /RevoScaleR/functions/rxLogit. Model usage After you build a predictive model, you can apply it to a data source to predict the dependent variable value, score the prediction, and store the results in a table by using the rxPredict function. You can see the code necessary to perform these steps in Example 6-9. In this example, you define a table without a schema in the rxSqlServerData function. The output from the rxPredict function returns the schema and creates the table, which means the SQL login associated with the rxSqlServerData function (as defined in the connection string) must have permissions to create a table, or the execution of the code fails.

Articles in this issue

Links on this page

Archives of this issue

view archives of Netherlands: Software - Introductie van Micorosoft SQL Server 2016