![]() ![]() # Predict using the test data pred <- predict ( my_lm, testing ) SSE = sum (( testing - pred ) ^ 2 ) # sum of squared errors SST = sum (( testing - mean ( training )) ^ 2 ) # total sum of squares, remember to use training data here R_square = 1 - SSE / SST message ( 'R_squared on the test data:' ) round ( R_square, 2 ) SSE = sum (( testing - pred ) ^ 2 ) RMSE = sqrt ( SSE / length ( pred )) message ( "Root mean square error on the test data: " ) round ( RMSE, 2 ) # Preparing data for ploting my_data = as. predict ( X_train_scaled ) print ( "R-squared for training dataset: ". fit ( X_train_scaled, y_train ) y_train_scaled_fit = reg_scaled. transform ( X_test ) linear_reg = LinearRegression () reg_scaled = linear_reg. transform ( X_train ) X_test_scaled = std_scale. fit ( X_train ) X_train_scaled = std_scale. # Instantiate linear regression: reg # Standardize features by removing the mean # and scaling to unit variance using the # StandardScaler() function # Apply Scaling to X_train and X_test std_scale = StandardScaler (). The task is a regression problem since the label (or target) we are trying to predict is numeric. You can find more details about the dataset on the UCI page. The real-world data we are using in this post consists of 9,568 data points, each with 4 environmental attributes collected from a Combined Cycle Power Plant over 6 years (2006-2011), and is provided by the University of California, Irvine at UCI Machine Learning Repository Combined Cycle Power Plant Data Set. Next, we will see the other non-linear regression models. In the second part of the post, we will work with regularized linear regression models (ridge, lasso and elasticnet). We will predict power output given a set of environmental readings from various sensors in a natural gas-fired power generation plant. In this part, we will first perform exploratory Data Analysis (EDA) on a real-world dataset, and then apply non-regularized linear regression to solve a supervised regression problem on the dataset. We will use the Scikit-learn library in Python and the Caret package in R. This blog post series is on machine learning with Python and R. Machine Learning with Python scikit-learn Vs R Caret - Part 1 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |