import pandas as pd
# load the training dataset
bike_data = pd.read_csv('data/daily-bike-share.csv')
bike_data.head()
instantint64
dtedayobject
0
1
1/1/2011
1
2
1/2/2011
2
3
1/3/2011
3
4
1/4/2011
4
5
1/5/2011
bike_data['day'] = pd.DatetimeIndex(bike_data['dteday']).day
bike_data.head(32)
instantint64
1 - 32
dtedayobject
1/1/20113.1%
1/2/20113.1%
30 others93.8%
0
1
1/1/2011
1
2
1/2/2011
2
3
1/3/2011
3
4
1/4/2011
4
5
1/5/2011
5
6
1/6/2011
6
7
1/7/2011
7
8
1/8/2011
8
9
1/9/2011
9
10
1/10/2011
numeric_features = ['temp', 'atemp', 'hum', 'windspeed']
bike_data[numeric_features + ['rentals']].describe()
tempfloat64
atempfloat64
count
731
731
mean
0.4953847885
0.4743539886
std
0.1830509961
0.1629611784
min
0.0591304
0.0790696
25%
0.3370835
0.3378425
50%
0.498333
0.486733
75%
0.6554165
0.608602
max
0.861667
0.840896
import pandas as pd
import matplotlib.pyplot as plt
# This ensures plots are displayed inline in the Jupyter notebook
%matplotlib inline
# Get the label column
label = bike_data['rentals']
# Create a figure for 2 subplots (2 rows, 1 column)
fig, ax = plt.subplots(2, 1, figsize = (9,12))
# Plot the histogram
ax[0].hist(label, bins=100)
ax[0].set_ylabel('Frequency')
# Add lines for the mean, median, and mode
ax[0].axvline(label.mean(), color='magenta', linestyle='dashed', linewidth=2)
ax[0].axvline(label.median(), color='cyan', linestyle='dashed', linewidth=2)
# Plot the boxplot
ax[1].boxplot(label, vert=False)
ax[1].set_xlabel('Rentals')
# Add a title to the Figure
fig.suptitle('Rental Distribution')
# Show the figure
fig.show()
# Plot a histogram for each numeric feature
for col in numeric_features:
fig = plt.figure(figsize=(9, 6))
ax = fig.gca()
feature = bike_data[col]
feature.hist(bins=100, ax = ax)
ax.axvline(feature.mean(), color='magenta', linestyle='dashed', linewidth=2)
ax.axvline(feature.median(), color='cyan', linestyle='dashed', linewidth=2)
ax.set_title(col)
plt.show()
import numpy as np
# plot a bar plot for each categorical feature count
categorical_features = ['season','mnth','holiday','weekday','workingday','weathersit', 'day']
for col in categorical_features:
counts = bike_data[col].value_counts().sort_index()
fig = plt.figure(figsize=(9, 6))
ax = fig.gca()
counts.plot.bar(ax = ax, color='steelblue')
ax.set_title(col + ' counts')
ax.set_xlabel(col)
ax.set_ylabel("Frequency")
plt.show()
for col in numeric_features:
fig = plt.figure(figsize=(9, 6))
ax = fig.gca()
feature = bike_data[col]
label = bike_data['rentals']
correlation = feature.corr(label)
plt.scatter(x=feature, y=label)
plt.xlabel(col)
plt.ylabel('Bike Rentals')
ax.set_title('rentals vs ' + col + '- correlation: ' + str(correlation))
plt.show()
# plot a boxplot for the label by each categorical feature
for col in categorical_features:
fig = plt.figure(figsize=(9, 6))
ax = fig.gca()
bike_data.boxplot(column = 'rentals', by = col, ax = ax)
ax.set_title('Label by ' + col)
ax.set_ylabel("Bike Rentals")
plt.show()
# Separate features and labels
X, y = bike_data[['season','mnth', 'holiday','weekday','workingday','weathersit','temp', 'atemp', 'hum', 'windspeed']].values, bike_data['rentals'].values
print('Features:',X[:10], '\nLabels:', y[:10], sep='\n')
Features:
[[1. 1. 0. 6. 0. 2. 0.344167
0.363625 0.805833 0.160446 ]
[1. 1. 0. 0. 0. 2. 0.363478
0.353739 0.696087 0.248539 ]
[1. 1. 0. 1. 1. 1. 0.196364
0.189405 0.437273 0.248309 ]
[1. 1. 0. 2. 1. 1. 0.2
0.212122 0.590435 0.160296 ]
[1. 1. 0. 3. 1. 1. 0.226957
0.22927 0.436957 0.1869 ]
[1. 1. 0. 4. 1. 1. 0.204348
0.233209 0.518261 0.0895652]
[1. 1. 0. 5. 1. 2. 0.196522
0.208839 0.498696 0.168726 ]
[1. 1. 0. 6. 0. 2. 0.165
0.162254 0.535833 0.266804 ]
[1. 1. 0. 0. 0. 1. 0.138333
0.116175 0.434167 0.36195 ]
[1. 1. 0. 1. 1. 1. 0.150833
0.150888 0.482917 0.223267 ]]
Labels:
[331 131 120 108 82 88 148 68 54 41]
from sklearn.model_selection import train_test_split
# Split data 70%-30% into training set and test set
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30, random_state=0)
print ('Training Set: %d rows\nTest Set: %d rows' % (X_train.shape[0], X_test.shape[0]))
Training Set: 511 rows
Test Set: 220 rows
# Train the model
from sklearn.linear_model import LinearRegression
# Fit a linear regression model on the training set
model = LinearRegression().fit(X_train, y_train)
print (model)
LinearRegression()
import numpy as np
predictions = model.predict(X_test)
np.set_printoptions(suppress=True)
print('Predicted labels: ', np.round(predictions)[:10])
print('Actual labels : ' ,y_test[:10])
Predicted labels: [1896. 1184. 1007. -28. 314. 385. 475. 590. 1476. -22.]
Actual labels : [2418 754 222 47 244 145 240 555 3252 38]
import matplotlib.pyplot as plt
%matplotlib inline
plt.scatter(y_test, predictions)
plt.xlabel('Actual Labels')
plt.ylabel('Predicted Labels')
plt.title('Daily Bike Share Predictions')
# overlay the regression line
z = np.polyfit(y_test, predictions, 1)
p = np.poly1d(z)
plt.plot(y_test,p(y_test), color='magenta')
plt.show()
from sklearn.metrics import mean_squared_error, r2_score
mse = mean_squared_error(y_test, predictions)
print("MSE:", mse)
rmse = np.sqrt(mse)
print("RMSE:", rmse)
r2 = r2_score(y_test, predictions)
print("R2:", r2)
MSE: 201972.55947035592
RMSE: 449.4135728595165
R2: 0.6040454736919191
from sklearn.linear_model import Lasso
# Fit a lasso model on the training set
model = Lasso().fit(X_train, y_train)
print (model, "\n")
# Evaluate the model using the test data
predictions = model.predict(X_test)
mse = mean_squared_error(y_test, predictions)
print("MSE:", mse)
rmse = np.sqrt(mse)
print("RMSE:", rmse)
r2 = r2_score(y_test, predictions)
print("R2:", r2)
# Plot predicted vs actual
plt.scatter(y_test, predictions)
plt.xlabel('Actual Labels')
plt.ylabel('Predicted Labels')
plt.title('Daily Bike Share Predictions')
# overlay the regression line
z = np.polyfit(y_test, predictions, 1)
p = np.poly1d(z)
plt.plot(y_test,p(y_test), color='magenta')
plt.show()
Lasso()
MSE: 201155.70593338404
RMSE: 448.5038527519959
R2: 0.6056468637824488
from sklearn.tree import DecisionTreeRegressor
from sklearn.tree import export_text
# Train the model
model = DecisionTreeRegressor().fit(X_train, y_train)
print (model, "\n")
# Visualize the model tree
tree = export_text(model)
print(tree)
DecisionTreeRegressor()
|--- feature_6 <= 0.45
| |--- feature_4 <= 0.50
| | |--- feature_7 <= 0.32
| | | |--- feature_8 <= 0.41
| | | | |--- feature_1 <= 2.50
| | | | | |--- feature_6 <= 0.29
| | | | | | |--- feature_7 <= 0.27
| | | | | | | |--- value: [515.00]
| | | | | | |--- feature_7 > 0.27
| | | | | | | |--- value: [558.00]
| | | | | |--- feature_6 > 0.29
| | | | | | |--- value: [317.00]
| | | | |--- feature_1 > 2.50
| | | | | |--- feature_8 <= 0.40
| | | | | | |--- feature_0 <= 1.50
| | | | | | | |--- value: [968.00]
| | | | | | |--- feature_0 > 1.50
| | | | | | | |--- value: [981.00]
| | | | | |--- feature_8 > 0.40
| | | | | | |--- feature_7 <= 0.28
| | | | | | | |--- value: [532.00]
| | | | | | |--- feature_7 > 0.28
| | | | | | | |--- value: [710.00]
| | | |--- feature_8 > 0.41
| | | | |--- feature_7 <= 0.25
| | | | | |--- feature_7 <= 0.18
| | | | | | |--- feature_8 <= 0.43
| | | | | | | |--- value: [284.00]
| | | | | | |--- feature_8 > 0.43
| | | | | | | |--- feature_7 <= 0.10
| | | | | | | | |--- value: [150.00]
| | | | | | | |--- feature_7 > 0.10
| | | | | | | | |--- feature_7 <= 0.18
| | | | | | | | | |--- feature_7 <= 0.13
| | | | | | | | | | |--- value: [73.00]
| | | | | | | | | |--- feature_7 > 0.13
| | | | | | | | | | |--- feature_6 <= 0.17
| | | | | | | | | | | |--- value: [68.00]
| | | | | | | | | | |--- feature_6 > 0.17
| | | | | | | | | | | |--- value: [67.00]
| | | | | | | | |--- feature_7 > 0.18
| | | | | | | | | |--- value: [117.00]
| | | | | |--- feature_7 > 0.18
| | | | | | |--- feature_8 <= 0.61
| | | | | | | |--- feature_9 <= 0.19
| | | | | | | | |--- value: [333.00]
| | | | | | | |--- feature_9 > 0.19
| | | | | | | | |--- feature_8 <= 0.53
| | | | | | | | | |--- feature_9 <= 0.21
| | | | | | | | | | |--- value: [251.00]
| | | | | | | | | |--- feature_9 > 0.21
| | | | | | | | | | |--- feature_8 <= 0.48
| | | | | | | | | | | |--- value: [205.00]
| | | | | | | | | | |--- feature_8 > 0.48
| | | | | | | | | | | |--- value: [217.00]
| | | | | | | | |--- feature_8 > 0.53
| | | | | | | | | |--- feature_8 <= 0.55
| | | | | | | | | | |--- value: [288.00]
| | | | | | | | | |--- feature_8 > 0.55
| | | | | | | | | | |--- value: [275.00]
| | | | | | |--- feature_8 > 0.61
| | | | | | | |--- feature_6 <= 0.21
| | | | | | | | |--- value: [123.00]
| | | | | | | |--- feature_6 > 0.21
| | | | | | | | |--- value: [140.00]
| | | | |--- feature_7 > 0.25
| | | | | |--- feature_9 <= 0.11
| | | | | | |--- value: [706.00]
| | | | | |--- feature_9 > 0.11
| | | | | | |--- feature_8 <= 0.54
| | | | | | | |--- feature_5 <= 1.50
| | | | | | | | |--- feature_7 <= 0.26
| | | | | | | | | |--- value: [309.00]
| | | | | | | | |--- feature_7 > 0.26
| | | | | | | | | |--- feature_0 <= 2.50
| | | | | | | | | | |--- feature_6 <= 0.26
| | | | | | | | | | | |--- value: [408.00]
| | | | | | | | | | |--- feature_6 > 0.26
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_0 > 2.50
| | | | | | | | | | |--- feature_1 <= 11.50
| | | | | | | | | | | |--- value: [440.00]
| | | | | | | | | | |--- feature_1 > 11.50
| | | | | | | | | | | |--- value: [502.00]
| | | | | | | |--- feature_5 > 1.50
| | | | | | | | |--- value: [618.00]
| | | | | | |--- feature_8 > 0.54
| | | | | | | |--- feature_6 <= 0.29
| | | | | | | | |--- feature_7 <= 0.28
| | | | | | | | | |--- value: [318.00]
| | | | | | | | |--- feature_7 > 0.28
| | | | | | | | | |--- value: [354.00]
| | | | | | | |--- feature_6 > 0.29
| | | | | | | | |--- feature_7 <= 0.29
| | | | | | | | | |--- value: [195.00]
| | | | | | | | |--- feature_7 > 0.29
| | | | | | | | | |--- value: [155.00]
| | |--- feature_7 > 0.32
| | | |--- feature_9 <= 0.25
| | | | |--- feature_7 <= 0.38
| | | | | |--- feature_7 <= 0.36
| | | | | | |--- feature_6 <= 0.36
| | | | | | | |--- feature_1 <= 10.50
| | | | | | | | |--- feature_6 <= 0.34
| | | | | | | | | |--- feature_9 <= 0.21
| | | | | | | | | | |--- feature_1 <= 3.50
| | | | | | | | | | | |--- value: [1047.00]
| | | | | | | | | | |--- feature_1 > 3.50
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_9 > 0.21
| | | | | | | | | | |--- value: [724.00]
| | | | | | | | |--- feature_6 > 0.34
| | | | | | | | | |--- feature_3 <= 3.00
| | | | | | | | | | |--- feature_9 <= 0.16
| | | | | | | | | | | |--- value: [694.00]
| | | | | | | | | | |--- feature_9 > 0.16
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_3 > 3.00
| | | | | | | | | | |--- value: [879.00]
| | | | | | | |--- feature_1 > 10.50
| | | | | | | | |--- feature_8 <= 0.57
| | | | | | | | | |--- feature_9 <= 0.22
| | | | | | | | | | |--- feature_7 <= 0.33
| | | | | | | | | | | |--- value: [1156.00]
| | | | | | | | | | |--- feature_7 > 0.33
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_9 > 0.22
| | | | | | | | | | |--- value: [943.00]
| | | | | | | | |--- feature_8 > 0.57
| | | | | | | | | |--- feature_9 <= 0.10
| | | | | | | | | | |--- feature_9 <= 0.06
| | | | | | | | | | | |--- value: [955.00]
| | | | | | | | | | |--- feature_9 > 0.06
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_9 > 0.10
| | | | | | | | | | |--- feature_3 <= 3.00
| | | | | | | | | | | |--- value: [922.00]
| | | | | | | | | | |--- feature_3 > 3.00
| | | | | | | | | | | |--- value: [767.00]
| | | | | | |--- feature_6 > 0.36
| | | | | | | |--- value: [1658.00]
| | | | | |--- feature_7 > 0.36
| | | | | | |--- feature_1 <= 6.00
| | | | | | | |--- value: [331.00]
| | | | | | |--- feature_1 > 6.00
| | | | | | | |--- feature_2 <= 0.50
| | | | | | | | |--- value: [538.00]
| | | | | | | |--- feature_2 > 0.50
| | | | | | | | |--- value: [560.00]
| | | | |--- feature_7 > 0.38
| | | | | |--- feature_9 <= 0.24
| | | | | | |--- feature_9 <= 0.15
| | | | | | | |--- feature_9 <= 0.11
| | | | | | | | |--- feature_3 <= 3.00
| | | | | | | | | |--- value: [1619.00]
| | | | | | | | |--- feature_3 > 3.00
| | | | | | | | | |--- feature_9 <= 0.08
| | | | | | | | | | |--- value: [1249.00]
| | | | | | | | | |--- feature_9 > 0.08
| | | | | | | | | | |--- value: [1153.00]
| | | | | | | |--- feature_9 > 0.11
| | | | | | | | |--- feature_7 <= 0.41
| | | | | | | | | |--- value: [2252.00]
| | | | | | | | |--- feature_7 > 0.41
| | | | | | | | | |--- value: [2290.00]
| | | | | | |--- feature_9 > 0.15
| | | | | | | |--- feature_7 <= 0.38
| | | | | | | | |--- value: [1651.00]
| | | | | | | |--- feature_7 > 0.38
| | | | | | | | |--- feature_9 <= 0.20
| | | | | | | | | |--- feature_6 <= 0.42
| | | | | | | | | | |--- feature_1 <= 2.00
| | | | | | | | | | | |--- value: [1070.00]
| | | | | | | | | | |--- feature_1 > 2.00
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_6 > 0.42
| | | | | | | | | | |--- value: [1188.00]
| | | | | | | | |--- feature_9 > 0.20
| | | | | | | | | |--- feature_1 <= 8.00
| | | | | | | | | | |--- value: [642.00]
| | | | | | | | | |--- feature_1 > 8.00
| | | | | | | | | | |--- value: [665.00]
| | | | | |--- feature_9 > 0.24
| | | | | | |--- value: [2301.00]
| | | |--- feature_9 > 0.25
| | | | |--- feature_9 <= 0.32
| | | | | |--- feature_8 <= 0.49
| | | | | | |--- value: [397.00]
| | | | | |--- feature_8 > 0.49
| | | | | | |--- feature_8 <= 0.64
| | | | | | | |--- value: [982.00]
| | | | | | |--- feature_8 > 0.64
| | | | | | | |--- feature_0 <= 2.50
| | | | | | | | |--- value: [640.00]
| | | | | | | |--- feature_0 > 2.50
| | | | | | | | |--- value: [480.00]
| | | | |--- feature_9 > 0.32
| | | | | |--- feature_6 <= 0.41
| | | | | | |--- value: [120.00]
| | | | | |--- feature_6 > 0.41
| | | | | | |--- value: [121.00]
| |--- feature_4 > 0.50
| | |--- feature_6 <= 0.34
| | | |--- feature_1 <= 2.50
| | | | |--- feature_7 <= 0.29
| | | | | |--- feature_7 <= 0.19
| | | | | | |--- feature_7 <= 0.14
| | | | | | | |--- feature_8 <= 0.43
| | | | | | | | |--- value: [95.00]
| | | | | | | |--- feature_8 > 0.43
| | | | | | | | |--- feature_6 <= 0.12
| | | | | | | | | |--- value: [86.00]
| | | | | | | | |--- feature_6 > 0.12
| | | | | | | | | |--- value: [89.00]
| | | | | | |--- feature_7 > 0.14
| | | | | | | |--- feature_8 <= 0.46
| | | | | | | | |--- feature_8 <= 0.45
| | | | | | | | | |--- value: [61.00]
| | | | | | | | |--- feature_8 > 0.45
| | | | | | | | | |--- value: [75.00]
| | | | | | | |--- feature_8 > 0.46
| | | | | | | | |--- feature_9 <= 0.30
| | | | | | | | | |--- feature_8 <= 0.49
| | | | | | | | | | |--- feature_6 <= 0.16
| | | | | | | | | | | |--- value: [41.00]
| | | | | | | | | | |--- feature_6 > 0.16
| | | | | | | | | | | |--- value: [38.00]
| | | | | | | | | |--- feature_8 > 0.49
| | | | | | | | | | |--- feature_3 <= 2.00
| | | | | | | | | | | |--- value: [42.00]
| | | | | | | | | | |--- feature_3 > 2.00
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | |--- feature_9 > 0.30
| | | | | | | | | |--- value: [25.00]
| | | | | |--- feature_7 > 0.19
| | | | | | |--- feature_3 <= 4.50
| | | | | | | |--- feature_9 <= 0.26
| | | | | | | | |--- feature_3 <= 2.50
| | | | | | | | | |--- feature_5 <= 1.50
| | | | | | | | | | |--- feature_9 <= 0.19
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_9 > 0.19
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_5 > 1.50
| | | | | | | | | | |--- feature_9 <= 0.12
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_9 > 0.12
| | | | | | | | | | | |--- value: [186.00]
| | | | | | | | |--- feature_3 > 2.50
| | | | | | | | | |--- feature_8 <= 0.51
| | | | | | | | | | |--- feature_6 <= 0.22
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_6 > 0.22
| | | | | | | | | | | |--- value: [82.00]
| | | | | | | | | |--- feature_8 > 0.51
| | | | | | | | | | |--- feature_7 <= 0.23
| | | | | | | | | | | |--- value: [15.00]
| | | | | | | | | | |--- feature_7 > 0.23
| | | | | | | | | | | |--- truncated branch of depth 4
| | | | | | | |--- feature_9 > 0.26
| | | | | | | | |--- feature_6 <= 0.22
| | | | | | | | | |--- value: [34.00]
| | | | | | | | |--- feature_6 > 0.22
| | | | | | | | | |--- feature_8 <= 0.66
| | | | | | | | | | |--- value: [64.00]
| | | | | | | | | |--- feature_8 > 0.66
| | | | | | | | | | |--- value: [72.00]
| | | | | | |--- feature_3 > 4.50
| | | | | | | |--- feature_8 <= 0.47
| | | | | | | | |--- value: [115.00]
| | | | | | | |--- feature_8 > 0.47
| | | | | | | | |--- feature_6 <= 0.24
| | | | | | | | | |--- feature_7 <= 0.21
| | | | | | | | | | |--- value: [148.00]
| | | | | | | | | |--- feature_7 > 0.21
| | | | | | | | | | |--- value: [149.00]
| | | | | | | | |--- feature_6 > 0.24
| | | | | | | | | |--- value: [174.00]
| | | | |--- feature_7 > 0.29
| | | | | |--- feature_3 <= 4.50
| | | | | | |--- feature_7 <= 0.32
| | | | | | | |--- feature_3 <= 2.50
| | | | | | | | |--- feature_6 <= 0.29
| | | | | | | | | |--- value: [206.00]
| | | | | | | | |--- feature_6 > 0.29
| | | | | | | | | |--- feature_6 <= 0.30
| | | | | | | | | | |--- value: [163.00]
| | | | | | | | | |--- feature_6 > 0.30
| | | | | | | | | | |--- value: [173.00]
| | | | | | | |--- feature_3 > 2.50
| | | | | | | | |--- value: [218.00]
| | | | | | |--- feature_7 > 0.32
| | | | | | | |--- feature_9 <= 0.12
| | | | | | | | |--- value: [74.00]
| | | | | | | |--- feature_9 > 0.12
| | | | | | | | |--- value: [135.00]
| | | | | |--- feature_3 > 4.50
| | | | | | |--- feature_5 <= 1.50
| | | | | | | |--- feature_7 <= 0.32
| | | | | | | | |--- value: [310.00]
| | | | | | | |--- feature_7 > 0.32
| | | | | | | | |--- value: [307.00]
| | | | | | |--- feature_5 > 1.50
| | | | | | | |--- value: [227.00]
| | | |--- feature_1 > 2.50
| | | | |--- feature_9 <= 0.20
| | | | | |--- feature_9 <= 0.12
| | | | | | |--- feature_9 <= 0.06
| | | | | | | |--- feature_3 <= 3.00
| | | | | | | | |--- value: [337.00]
| | | | | | | |--- feature_3 > 3.00
| | | | | | | | |--- value: [362.00]
| | | | | | |--- feature_9 > 0.06
| | | | | | | |--- feature_3 <= 3.50
| | | | | | | | |--- feature_5 <= 1.50
| | | | | | | | | |--- value: [143.00]
| | | | | | | | |--- feature_5 > 1.50
| | | | | | | | | |--- feature_6 <= 0.27
| | | | | | | | | | |--- value: [174.00]
| | | | | | | | | |--- feature_6 > 0.27
| | | | | | | | | | |--- value: [178.00]
| | | | | | | |--- feature_3 > 3.50
| | | | | | | | |--- feature_9 <= 0.11
| | | | | | | | | |--- feature_7 <= 0.32
| | | | | | | | | | |--- value: [261.00]
| | | | | | | | | |--- feature_7 > 0.32
| | | | | | | | | | |--- value: [268.00]
| | | | | | | | |--- feature_9 > 0.11
| | | | | | | | | |--- feature_6 <= 0.26
| | | | | | | | | | |--- value: [254.00]
| | | | | | | | | |--- feature_6 > 0.26
| | | | | | | | | | |--- value: [243.00]
| | | | | |--- feature_9 > 0.12
| | | | | | |--- feature_8 <= 0.64
| | | | | | | |--- feature_8 <= 0.45
| | | | | | | | |--- feature_6 <= 0.28
| | | | | | | | | |--- value: [245.00]
| | | | | | | | |--- feature_6 > 0.28
| | | | | | | | | |--- value: [316.00]
| | | | | | | |--- feature_8 > 0.45
| | | | | | | | |--- feature_9 <= 0.14
| | | | | | | | | |--- feature_9 <= 0.13
| | | | | | | | | | |--- value: [429.00]
| | | | | | | | | |--- feature_9 > 0.13
| | | | | | | | | | |--- value: [491.00]
| | | | | | | | |--- feature_9 > 0.14
| | | | | | | | | |--- feature_6 <= 0.30
| | | | | | | | | | |--- feature_9 <= 0.17
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | | |--- feature_9 > 0.17
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_6 > 0.30
| | | | | | | | | | |--- feature_9 <= 0.14
| | | | | | | | | | | |--- value: [359.00]
| | | | | | | | | | |--- feature_9 > 0.14
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | |--- feature_8 > 0.64
| | | | | | | |--- feature_6 <= 0.31
| | | | | | | | |--- value: [168.00]
| | | | | | | |--- feature_6 > 0.31
| | | | | | | | |--- feature_9 <= 0.13
| | | | | | | | | |--- value: [349.00]
| | | | | | | | |--- feature_9 > 0.13
| | | | | | | | | |--- feature_6 <= 0.32
| | | | | | | | | | |--- value: [289.00]
| | | | | | | | | |--- feature_6 > 0.32
| | | | | | | | | | |--- value: [314.00]
| | | | |--- feature_9 > 0.20
| | | | | |--- feature_8 <= 0.78
| | | | | | |--- feature_9 <= 0.23
| | | | | | | |--- feature_9 <= 0.21
| | | | | | | | |--- feature_0 <= 3.00
| | | | | | | | | |--- feature_6 <= 0.26
| | | | | | | | | | |--- value: [221.00]
| | | | | | | | | |--- feature_6 > 0.26
| | | | | | | | | | |--- value: [222.00]
| | | | | | | | |--- feature_0 > 3.00
| | | | | | | | | |--- value: [198.00]
| | | | | | | |--- feature_9 > 0.21
| | | | | | | | |--- feature_6 <= 0.28
| | | | | | | | | |--- feature_9 <= 0.22
| | | | | | | | | | |--- value: [137.00]
| | | | | | | | | |--- feature_9 > 0.22
| | | | | | | | | | |--- value: [123.00]
| | | | | | | | |--- feature_6 > 0.28
| | | | | | | | | |--- feature_8 <= 0.75
| | | | | | | | | | |--- value: [177.00]
| | | | | | | | | |--- feature_8 > 0.75
| | | | | | | | | | |--- value: [191.00]
| | | | | | |--- feature_9 > 0.23
| | | | | | | |--- feature_3 <= 4.50
| | | | | | | | |--- feature_8 <= 0.56
| | | | | | | | | |--- feature_0 <= 1.50
| | | | | | | | | | |--- feature_6 <= 0.25
| | | | | | | | | | | |--- value: [203.00]
| | | | | | | | | | |--- feature_6 > 0.25
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | |--- feature_0 > 1.50
| | | | | | | | | | |--- feature_8 <= 0.43
| | | | | | | | | | | |--- value: [317.00]
| | | | | | | | | | |--- feature_8 > 0.43
| | | | | | | | | | | |--- value: [326.00]
| | | | | | | | |--- feature_8 > 0.56
| | | | | | | | | |--- feature_8 <= 0.62
| | | | | | | | | | |--- feature_8 <= 0.58
| | | | | | | | | | | |--- value: [139.00]
| | | | | | | | | | |--- feature_8 > 0.58
| | | | | | | | | | | |--- value: [150.00]
| | | | | | | | | |--- feature_8 > 0.62
| | | | | | | | | | |--- feature_0 <= 1.50
| | | | | | | | | | | |--- value: [247.00]
| | | | | | | | | | |--- feature_0 > 1.50
| | | | | | | | | | | |--- value: [195.00]
| | | | | | | |--- feature_3 > 4.50
| | | | | | | | |--- feature_0 <= 3.00
| | | | | | | | | |--- feature_0 <= 1.50
| | | | | | | | | | |--- value: [247.00]
| | | | | | | | | |--- feature_0 > 1.50
| | | | | | | | | | |--- feature_9 <= 0.24
| | | | | | | | | | | |--- value: [300.00]
| | | | | | | | | | |--- feature_9 > 0.24
| | | | | | | | | | | |--- value: [307.00]
| | | | | | | | |--- feature_0 > 3.00
| | | | | | | | | |--- value: [456.00]
| | | | | |--- feature_8 > 0.78
| | | | | | |--- feature_7 <= 0.24
| | | | | | | |--- value: [9.00]
| | | | | | |--- feature_7 > 0.24
| | | | | | | |--- feature_3 <= 3.00
| | | | | | | | |--- feature_9 <= 0.23
| | | | | | | | | |--- value: [87.00]
| | | | | | | | |--- feature_9 > 0.23
| | | | | | | | | |--- value: [123.00]
| | | | | | | |--- feature_3 > 3.00
| | | | | | | | |--- feature_9 <= 0.23
| | | | | | | | | |--- value: [179.00]
| | | | | | | | |--- feature_9 > 0.23
| | | | | | | | | |--- value: [166.00]
| | |--- feature_6 > 0.34
| | | |--- feature_3 <= 4.50
| | | | |--- feature_8 <= 0.48
| | | | | |--- feature_6 <= 0.42
| | | | | | |--- feature_8 <= 0.44
| | | | | | | |--- feature_3 <= 1.50
| | | | | | | | |--- value: [208.00]
| | | | | | | |--- feature_3 > 1.50
| | | | | | | | |--- feature_9 <= 0.23
| | | | | | | | | |--- value: [229.00]
| | | | | | | | |--- feature_9 > 0.23
| | | | | | | | | |--- feature_0 <= 2.50
| | | | | | | | | | |--- value: [324.00]
| | | | | | | | | |--- feature_0 > 2.50
| | | | | | | | | | |--- value: [340.00]
| | | | | | |--- feature_8 > 0.44
| | | | | | | |--- feature_3 <= 3.50
| | | | | | | | |--- feature_8 <= 0.47
| | | | | | | | | |--- feature_8 <= 0.46
| | | | | | | | | | |--- value: [518.00]
| | | | | | | | | |--- feature_8 > 0.46
| | | | | | | | | | |--- value: [482.00]
| | | | | | | | |--- feature_8 > 0.47
| | | | | | | | | |--- value: [413.00]
| | | | | | | |--- feature_3 > 3.50
| | | | | | | | |--- value: [663.00]
| | | | | |--- feature_6 > 0.42
| | | | | | |--- feature_7 <= 0.43
| | | | | | | |--- value: [1192.00]
| | | | | | |--- feature_7 > 0.43
| | | | | | | |--- feature_3 <= 1.50
| | | | | | | | |--- value: [795.00]
| | | | | | | |--- feature_3 > 1.50
| | | | | | | | |--- feature_3 <= 3.00
| | | | | | | | | |--- value: [819.00]
| | | | | | | | |--- feature_3 > 3.00
| | | | | | | | | |--- value: [834.00]
| | | | |--- feature_8 > 0.48
| | | | | |--- feature_5 <= 1.50
| | | | | | |--- feature_8 <= 0.55
| | | | | | | |--- feature_1 <= 2.50
| | | | | | | | |--- feature_6 <= 0.36
| | | | | | | | | |--- feature_8 <= 0.51
| | | | | | | | | | |--- value: [199.00]
| | | | | | | | | |--- feature_8 > 0.51
| | | | | | | | | | |--- value: [141.00]
| | | | | | | | |--- feature_6 > 0.36
| | | | | | | | | |--- feature_8 <= 0.50
| | | | | | | | | | |--- value: [253.00]
| | | | | | | | | |--- feature_8 > 0.50
| | | | | | | | | | |--- value: [259.00]
| | | | | | | |--- feature_1 > 2.50
| | | | | | | | |--- feature_8 <= 0.50
| | | | | | | | | |--- value: [331.00]
| | | | | | | | |--- feature_8 > 0.50
| | | | | | | | | |--- value: [432.00]
| | | | | | |--- feature_8 > 0.55
| | | | | | | |--- feature_8 <= 0.65
| | | | | | | | |--- feature_9 <= 0.19
| | | | | | | | | |--- feature_7 <= 0.40
| | | | | | | | | | |--- value: [615.00]
| | | | | | | | | |--- feature_7 > 0.40
| | | | | | | | | | |--- value: [571.00]
| | | | | | | | |--- feature_9 > 0.19
| | | | | | | | | |--- feature_0 <= 1.50
| | | | | | | | | | |--- value: [394.00]
| | | | | | | | | |--- feature_0 > 1.50
| | | | | | | | | | |--- value: [460.00]
| | | | | | | |--- feature_8 > 0.65
| | | | | | | | |--- feature_9 <= 0.10
| | | | | | | | | |--- feature_8 <= 0.74
| | | | | | | | | | |--- feature_3 <= 2.50
| | | | | | | | | | | |--- value: [376.00]
| | | | | | | | | | |--- feature_3 > 2.50
| | | | | | | | | | | |--- value: [370.00]
| | | | | | | | | |--- feature_8 > 0.74
| | | | | | | | | | |--- value: [305.00]
| | | | | | | | |--- feature_9 > 0.10
| | | | | | | | | |--- feature_0 <= 2.50
| | | | | | | | | | |--- value: [439.00]
| | | | | | | | | |--- feature_0 > 2.50
| | | | | | | | | | |--- feature_6 <= 0.41
| | | | | | | | | | | |--- value: [410.00]
| | | | | | | | | | |--- feature_6 > 0.41
| | | | | | | | | | | |--- value: [433.00]
| | | | | |--- feature_5 > 1.50
| | | | | | |--- feature_7 <= 0.39
| | | | | | | |--- feature_9 <= 0.17
| | | | | | | | |--- feature_3 <= 1.50
| | | | | | | | | |--- value: [330.00]
| | | | | | | | |--- feature_3 > 1.50
| | | | | | | | | |--- feature_9 <= 0.12
| | | | | | | | | | |--- value: [534.00]
| | | | | | | | | |--- feature_9 > 0.12
| | | | | | | | | | |--- value: [466.00]
| | | | | | | |--- feature_9 > 0.17
| | | | | | | | |--- feature_9 <= 0.35
| | | | | | | | | |--- feature_8 <= 0.82
| | | | | | | | | | |--- feature_1 <= 2.00
| | | | | | | | | | | |--- value: [269.00]
| | | | | | | | | | |--- feature_1 > 2.00
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | |--- feature_8 > 0.82
| | | | | | | | | | |--- value: [203.00]
| | | | | | | | |--- feature_9 > 0.35
| | | | | | | | | |--- value: [127.00]
| | | | | | |--- feature_7 > 0.39
| | | | | | | |--- feature_9 <= 0.26
| | | | | | | | |--- feature_1 <= 3.00
| | | | | | | | | |--- value: [190.00]
| | | | | | | | |--- feature_1 > 3.00
| | | | | | | | | |--- feature_7 <= 0.40
| | | | | | | | | | |--- value: [233.00]
| | | | | | | | | |--- feature_7 > 0.40
| | | | | | | | | | |--- feature_7 <= 0.42
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | | |--- feature_7 > 0.42
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | |--- feature_9 > 0.26
| | | | | | | | |--- feature_8 <= 0.75
| | | | | | | | | |--- feature_8 <= 0.69
| | | | | | | | | | |--- feature_9 <= 0.33
| | | | | | | | | | | |--- value: [181.00]
| | | | | | | | | | |--- feature_9 > 0.33
| | | | | | | | | | | |--- value: [167.00]
| | | | | | | | | |--- feature_8 > 0.69
| | | | | | | | | | |--- value: [255.00]
| | | | | | | | |--- feature_8 > 0.75
| | | | | | | | | |--- feature_8 <= 0.88
| | | | | | | | | | |--- feature_0 <= 2.50
| | | | | | | | | | | |--- value: [81.00]
| | | | | | | | | | |--- feature_0 > 2.50
| | | | | | | | | | | |--- value: [112.00]
| | | | | | | | | |--- feature_8 > 0.88
| | | | | | | | | | |--- feature_6 <= 0.42
| | | | | | | | | | | |--- value: [50.00]
| | | | | | | | | | |--- feature_6 > 0.42
| | | | | | | | | | | |--- value: [2.00]
| | | |--- feature_3 > 4.50
| | | | |--- feature_8 <= 0.39
| | | | | |--- value: [1807.00]
| | | | |--- feature_8 > 0.39
| | | | | |--- feature_5 <= 1.50
| | | | | | |--- feature_6 <= 0.37
| | | | | | | |--- feature_9 <= 0.19
| | | | | | | | |--- value: [484.00]
| | | | | | | |--- feature_9 > 0.19
| | | | | | | | |--- feature_9 <= 0.24
| | | | | | | | | |--- value: [709.00]
| | | | | | | | |--- feature_9 > 0.24
| | | | | | | | | |--- value: [618.00]
| | | | | | |--- feature_6 > 0.37
| | | | | | | |--- feature_7 <= 0.38
| | | | | | | | |--- value: [1603.00]
| | | | | | | |--- feature_7 > 0.38
| | | | | | | | |--- value: [1095.00]
| | | | | |--- feature_5 > 1.50
| | | | | | |--- feature_7 <= 0.37
| | | | | | | |--- feature_0 <= 2.50
| | | | | | | | |--- value: [246.00]
| | | | | | | |--- feature_0 > 2.50
| | | | | | | | |--- value: [178.00]
| | | | | | |--- feature_7 > 0.37
| | | | | | | |--- feature_6 <= 0.39
| | | | | | | | |--- value: [796.00]
| | | | | | | |--- feature_6 > 0.39
| | | | | | | | |--- feature_8 <= 0.73
| | | | | | | | | |--- feature_6 <= 0.41
| | | | | | | | | | |--- value: [470.00]
| | | | | | | | | |--- feature_6 > 0.41
| | | | | | | | | | |--- value: [447.00]
| | | | | | | | |--- feature_8 > 0.73
| | | | | | | | | |--- value: [548.00]
|--- feature_6 > 0.45
| |--- feature_4 <= 0.50
| | |--- feature_8 <= 0.83
| | | |--- feature_1 <= 10.50
| | | | |--- feature_9 <= 0.28
| | | | | |--- feature_7 <= 0.77
| | | | | | |--- feature_8 <= 0.67
| | | | | | | |--- feature_9 <= 0.09
| | | | | | | | |--- value: [3065.00]
| | | | | | | |--- feature_9 > 0.09
| | | | | | | | |--- feature_8 <= 0.66
| | | | | | | | | |--- feature_9 <= 0.15
| | | | | | | | | | |--- feature_9 <= 0.14
| | | | | | | | | | | |--- truncated branch of depth 8
| | | | | | | | | | |--- feature_9 > 0.14
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | |--- feature_9 > 0.15
| | | | | | | | | | |--- feature_9 <= 0.16
| | | | | | | | | | | |--- truncated branch of depth 4
| | | | | | | | | | |--- feature_9 > 0.16
| | | | | | | | | | | |--- truncated branch of depth 10
| | | | | | | | |--- feature_8 > 0.66
| | | | | | | | | |--- value: [3031.00]
| | | | | | |--- feature_8 > 0.67
| | | | | | | |--- feature_7 <= 0.67
| | | | | | | | |--- feature_7 <= 0.50
| | | | | | | | | |--- feature_1 <= 4.00
| | | | | | | | | | |--- value: [2207.00]
| | | | | | | | | |--- feature_1 > 4.00
| | | | | | | | | | |--- feature_8 <= 0.74
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_8 > 0.74
| | | | | | | | | | | |--- value: [1138.00]
| | | | | | | | |--- feature_7 > 0.50
| | | | | | | | | |--- feature_1 <= 4.00
| | | | | | | | | | |--- value: [3155.00]
| | | | | | | | | |--- feature_1 > 4.00
| | | | | | | | | | |--- feature_6 <= 0.69
| | | | | | | | | | | |--- truncated branch of depth 7
| | | | | | | | | | |--- feature_6 > 0.69
| | | | | | | | | | | |--- truncated branch of depth 6
| | | | | | | |--- feature_7 > 0.67
| | | | | | | | |--- feature_6 <= 0.74
| | | | | | | | | |--- feature_3 <= 0.50
| | | | | | | | | | |--- feature_8 <= 0.76
| | | | | | | | | | | |--- value: [1298.00]
| | | | | | | | | | |--- feature_8 > 0.76
| | | | | | | | | | | |--- value: [1249.00]
| | | | | | | | | |--- feature_3 > 0.50
| | | | | | | | | | |--- feature_6 <= 0.72
| | | | | | | | | | | |--- value: [1521.00]
| | | | | | | | | | |--- feature_6 > 0.72
| | | | | | | | | | | |--- value: [1549.00]
| | | | | | | | |--- feature_6 > 0.74
| | | | | | | | | |--- value: [1920.00]
| | | | | |--- feature_7 > 0.77
| | | | | | |--- feature_9 <= 0.13
| | | | | | | |--- value: [1203.00]
| | | | | | |--- feature_9 > 0.13
| | | | | | | |--- value: [987.00]
| | | | |--- feature_9 > 0.28
| | | | | |--- feature_8 <= 0.52
| | | | | | |--- value: [1558.00]
| | | | | |--- feature_8 > 0.52
| | | | | | |--- feature_8 <= 0.63
| | | | | | | |--- value: [1198.00]
| | | | | | |--- feature_8 > 0.63
| | | | | | | |--- value: [998.00]
| | | |--- feature_1 > 10.50
| | | | |--- feature_7 <= 0.47
| | | | | |--- value: [787.00]
| | | | |--- feature_7 > 0.47
| | | | | |--- value: [1097.00]
| | |--- feature_8 > 0.83
| | | |--- feature_9 <= 0.30
| | | | |--- feature_3 <= 3.00
| | | | | |--- feature_7 <= 0.57
| | | | | | |--- value: [1582.00]
| | | | | |--- feature_7 > 0.57
| | | | | | |--- value: [1483.00]
| | | | |--- feature_3 > 3.00
| | | | | |--- feature_7 <= 0.47
| | | | | | |--- value: [1462.00]
| | | | | |--- feature_7 > 0.47
| | | | | | |--- feature_7 <= 0.49
| | | | | | | |--- value: [1033.00]
| | | | | | |--- feature_7 > 0.49
| | | | | | | |--- value: [902.00]
| | | |--- feature_9 > 0.30
| | | | |--- value: [226.00]
| |--- feature_4 > 0.50
| | |--- feature_8 <= 0.83
| | | |--- feature_3 <= 4.50
| | | | |--- feature_7 <= 0.53
| | | | | |--- feature_9 <= 0.10
| | | | | | |--- feature_6 <= 0.48
| | | | | | | |--- value: [1348.00]
| | | | | | |--- feature_6 > 0.48
| | | | | | | |--- feature_1 <= 3.50
| | | | | | | | |--- value: [1122.00]
| | | | | | | |--- feature_1 > 3.50
| | | | | | | | |--- feature_6 <= 0.51
| | | | | | | | | |--- feature_0 <= 3.00
| | | | | | | | | | |--- value: [846.00]
| | | | | | | | | |--- feature_0 > 3.00
| | | | | | | | | | |--- value: [830.00]
| | | | | | | | |--- feature_6 > 0.51
| | | | | | | | | |--- value: [763.00]
| | | | | |--- feature_9 > 0.10
| | | | | | |--- feature_9 <= 0.23
| | | | | | | |--- feature_3 <= 2.50
| | | | | | | | |--- feature_8 <= 0.64
| | | | | | | | | |--- feature_6 <= 0.47
| | | | | | | | | | |--- feature_8 <= 0.52
| | | | | | | | | | | |--- value: [838.00]
| | | | | | | | | | |--- feature_8 > 0.52
| | | | | | | | | | | |--- value: [922.00]
| | | | | | | | | |--- feature_6 > 0.47
| | | | | | | | | | |--- feature_1 <= 7.50
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | | |--- feature_1 > 7.50
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | |--- feature_8 > 0.64
| | | | | | | | | |--- feature_9 <= 0.14
| | | | | | | | | | |--- feature_6 <= 0.50
| | | | | | | | | | | |--- value: [699.00]
| | | | | | | | | | |--- feature_6 > 0.50
| | | | | | | | | | | |--- value: [637.00]
| | | | | | | | | |--- feature_9 > 0.14
| | | | | | | | | | |--- feature_7 <= 0.48
| | | | | | | | | | | |--- value: [486.00]
| | | | | | | | | | |--- feature_7 > 0.48
| | | | | | | | | | | |--- value: [409.00]
| | | | | | | |--- feature_3 > 2.50
| | | | | | | | |--- feature_6 <= 0.51
| | | | | | | | | |--- feature_9 <= 0.13
| | | | | | | | | | |--- value: [655.00]
| | | | | | | | | |--- feature_9 > 0.13
| | | | | | | | | | |--- feature_7 <= 0.45
| | | | | | | | | | | |--- value: [516.00]
| | | | | | | | | | |--- feature_7 > 0.45
| | | | | | | | | | | |--- truncated branch of depth 4
| | | | | | | | |--- feature_6 > 0.51
| | | | | | | | | |--- feature_6 <= 0.54
| | | | | | | | | | |--- feature_7 <= 0.52
| | | | | | | | | | | |--- value: [735.00]
| | | | | | | | | | |--- feature_7 > 0.52
| | | | | | | | | | | |--- value: [695.00]
| | | | | | | | | |--- feature_6 > 0.54
| | | | | | | | | | |--- feature_7 <= 0.53
| | | | | | | | | | | |--- value: [559.00]
| | | | | | | | | | |--- feature_7 > 0.53
| | | | | | | | | | | |--- value: [550.00]
| | | | | | |--- feature_9 > 0.23
| | | | | | | |--- feature_7 <= 0.47
| | | | | | | | |--- feature_6 <= 0.47
| | | | | | | | | |--- feature_7 <= 0.45
| | | | | | | | | | |--- value: [614.00]
| | | | | | | | | |--- feature_7 > 0.45
| | | | | | | | | | |--- value: [745.00]
| | | | | | | | |--- feature_6 > 0.47
| | | | | | | | | |--- value: [471.00]
| | | | | | | |--- feature_7 > 0.47
| | | | | | | | |--- feature_1 <= 4.50
| | | | | | | | | |--- feature_1 <= 3.50
| | | | | | | | | | |--- value: [834.00]
| | | | | | | | | |--- feature_1 > 3.50
| | | | | | | | | | |--- value: [905.00]
| | | | | | | | |--- feature_1 > 4.50
| | | | | | | | | |--- value: [1008.00]
| | | | |--- feature_7 > 0.53
| | | | | |--- feature_9 <= 0.13
| | | | | | |--- feature_7 <= 0.72
| | | | | | | |--- feature_6 <= 0.68
| | | | | | | | |--- feature_8 <= 0.82
| | | | | | | | | |--- feature_9 <= 0.09
| | | | | | | | | | |--- feature_6 <= 0.63
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_6 > 0.63
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_9 > 0.09
| | | | | | | | | | |--- feature_6 <= 0.64
| | | | | | | | | | | |--- truncated branch of depth 6
| | | | | | | | | | |--- feature_6 > 0.64
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | |--- feature_8 > 0.82
| | | | | | | | | |--- value: [1334.00]
| | | | | | | |--- feature_6 > 0.68
| | | | | | | | |--- feature_9 <= 0.12
| | | | | | | | | |--- feature_6 <= 0.69
| | | | | | | | | | |--- value: [1177.00]
| | | | | | | | | |--- feature_6 > 0.69
| | | | | | | | | | |--- feature_9 <= 0.10
| | | | | | | | | | | |--- value: [1363.00]
| | | | | | | | | | |--- feature_9 > 0.10
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | |--- feature_9 > 0.12
| | | | | | | | | |--- feature_7 <= 0.71
| | | | | | | | | | |--- feature_1 <= 7.50
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_1 > 7.50
| | | | | | | | | | | |--- value: [989.00]
| | | | | | | | | |--- feature_7 > 0.71
| | | | | | | | | | |--- value: [1233.00]
| | | | | | |--- feature_7 > 0.72
| | | | | | | |--- feature_6 <= 0.78
| | | | | | | | |--- feature_7 <= 0.72
| | | | | | | | | |--- value: [568.00]
| | | | | | | | |--- feature_7 > 0.72
| | | | | | | | | |--- value: [673.00]
| | | | | | | |--- feature_6 > 0.78
| | | | | | | | |--- feature_3 <= 3.50
| | | | | | | | | |--- feature_6 <= 0.80
| | | | | | | | | | |--- value: [872.00]
| | | | | | | | | |--- feature_6 > 0.80
| | | | | | | | | | |--- value: [921.00]
| | | | | | | | |--- feature_3 > 3.50
| | | | | | | | | |--- value: [778.00]
| | | | | |--- feature_9 > 0.13
| | | | | | |--- feature_8 <= 0.53
| | | | | | | |--- feature_7 <= 0.73
| | | | | | | | |--- feature_9 <= 0.15
| | | | | | | | | |--- value: [1281.00]
| | | | | | | | |--- feature_9 > 0.15
| | | | | | | | | |--- feature_8 <= 0.51
| | | | | | | | | | |--- feature_1 <= 6.50
| | | | | | | | | | | |--- truncated branch of depth 6
| | | | | | | | | | |--- feature_1 > 6.50
| | | | | | | | | | | |--- truncated branch of depth 4
| | | | | | | | | |--- feature_8 > 0.51
| | | | | | | | | | |--- feature_6 <= 0.65
| | | | | | | | | | | |--- value: [1242.00]
| | | | | | | | | | |--- feature_6 > 0.65
| | | | | | | | | | | |--- value: [1032.00]
| | | | | | | |--- feature_7 > 0.73
| | | | | | | | |--- value: [1405.00]
| | | | | | |--- feature_8 > 0.53
| | | | | | | |--- feature_5 <= 1.50
| | | | | | | | |--- feature_9 <= 0.17
| | | | | | | | | |--- feature_9 <= 0.17
| | | | | | | | | | |--- feature_3 <= 3.50
| | | | | | | | | | | |--- truncated branch of depth 7
| | | | | | | | | | |--- feature_3 > 3.50
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_9 > 0.17
| | | | | | | | | | |--- feature_7 <= 0.67
| | | | | | | | | | | |--- value: [1198.00]
| | | | | | | | | | |--- feature_7 > 0.67
| | | | | | | | | | | |--- value: [1128.00]
| | | | | | | | |--- feature_9 > 0.17
| | | | | | | | | |--- feature_6 <= 0.78
| | | | | | | | | | |--- feature_6 <= 0.72
| | | | | | | | | | | |--- truncated branch of depth 7
| | | | | | | | | | |--- feature_6 > 0.72
| | | | | | | | | | | |--- truncated branch of depth 5
| | | | | | | | | |--- feature_6 > 0.78
| | | | | | | | | | |--- feature_3 <= 3.00
| | | | | | | | | | | |--- value: [662.00]
| | | | | | | | | | |--- feature_3 > 3.00
| | | | | | | | | | | |--- value: [606.00]
| | | | | | | |--- feature_5 > 1.50
| | | | | | | | |--- feature_3 <= 1.50
| | | | | | | | | |--- feature_8 <= 0.76
| | | | | | | | | | |--- feature_7 <= 0.55
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_7 > 0.55
| | | | | | | | | | | |--- truncated branch of depth 4
| | | | | | | | | |--- feature_8 > 0.76
| | | | | | | | | | |--- feature_7 <= 0.56
| | | | | | | | | | | |--- value: [653.00]
| | | | | | | | | | |--- feature_7 > 0.56
| | | | | | | | | | | |--- value: [630.00]
| | | | | | | | |--- feature_3 > 1.50
| | | | | | | | | |--- feature_9 <= 0.19
| | | | | | | | | | |--- feature_9 <= 0.15
| | | | | | | | | | | |--- truncated branch of depth 5
| | | | | | | | | | |--- feature_9 > 0.15
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | |--- feature_9 > 0.19
| | | | | | | | | | |--- feature_1 <= 8.00
| | | | | | | | | | | |--- truncated branch of depth 5
| | | | | | | | | | |--- feature_1 > 8.00
| | | | | | | | | | | |--- value: [428.00]
| | | |--- feature_3 > 4.50
| | | | |--- feature_1 <= 4.00
| | | | | |--- value: [2469.00]
| | | | |--- feature_1 > 4.00
| | | | | |--- feature_8 <= 0.72
| | | | | | |--- feature_9 <= 0.12
| | | | | | | |--- feature_9 <= 0.08
| | | | | | | | |--- value: [1325.00]
| | | | | | | |--- feature_9 > 0.08
| | | | | | | | |--- feature_8 <= 0.65
| | | | | | | | | |--- feature_5 <= 1.50
| | | | | | | | | | |--- value: [1516.00]
| | | | | | | | | |--- feature_5 > 1.50
| | | | | | | | | | |--- value: [1511.00]
| | | | | | | | |--- feature_8 > 0.65
| | | | | | | | | |--- value: [1379.00]
| | | | | | |--- feature_9 > 0.12
| | | | | | | |--- feature_6 <= 0.83
| | | | | | | | |--- feature_1 <= 6.50
| | | | | | | | | |--- feature_8 <= 0.52
| | | | | | | | | | |--- feature_8 <= 0.36
| | | | | | | | | | | |--- value: [898.00]
| | | | | | | | | | |--- feature_8 > 0.36
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_8 > 0.52
| | | | | | | | | | |--- feature_8 <= 0.58
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_8 > 0.58
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | |--- feature_1 > 6.50
| | | | | | | | | |--- feature_6 <= 0.72
| | | | | | | | | | |--- feature_6 <= 0.69
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_6 > 0.69
| | | | | | | | | | | |--- truncated branch of depth 3
| | | | | | | | | |--- feature_6 > 0.72
| | | | | | | | | | |--- feature_8 <= 0.51
| | | | | | | | | | | |--- value: [1366.00]
| | | | | | | | | | |--- feature_8 > 0.51
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | |--- feature_6 > 0.83
| | | | | | | | |--- feature_1 <= 6.50
| | | | | | | | | |--- value: [829.00]
| | | | | | | | |--- feature_1 > 6.50
| | | | | | | | | |--- value: [670.00]
| | | | | |--- feature_8 > 0.72
| | | | | | |--- feature_9 <= 0.20
| | | | | | | |--- feature_1 <= 5.50
| | | | | | | | |--- feature_8 <= 0.73
| | | | | | | | | |--- value: [909.00]
| | | | | | | | |--- feature_8 > 0.73
| | | | | | | | | |--- value: [1417.00]
| | | | | | | |--- feature_1 > 5.50
| | | | | | | | |--- feature_7 <= 0.53
| | | | | | | | | |--- value: [1182.00]
| | | | | | | | |--- feature_7 > 0.53
| | | | | | | | | |--- feature_6 <= 0.70
| | | | | | | | | | |--- feature_9 <= 0.14
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | | |--- feature_9 > 0.14
| | | | | | | | | | | |--- truncated branch of depth 2
| | | | | | | | | |--- feature_6 > 0.70
| | | | | | | | | | |--- value: [1045.00]
| | | | | | |--- feature_9 > 0.20
| | | | | | | |--- feature_7 <= 0.57
| | | | | | | | |--- value: [529.00]
| | | | | | | |--- feature_7 > 0.57
| | | | | | | | |--- value: [533.00]
| | |--- feature_8 > 0.83
| | | |--- feature_5 <= 2.50
| | | | |--- feature_9 <= 0.10
| | | | | |--- value: [258.00]
| | | | |--- feature_9 > 0.10
| | | | | |--- feature_1 <= 5.50
| | | | | | |--- feature_3 <= 4.00
| | | | | | | |--- feature_3 <= 2.50
| | | | | | | | |--- value: [678.00]
| | | | | | | |--- feature_3 > 2.50
| | | | | | | | |--- feature_6 <= 0.59
| | | | | | | | | |--- value: [536.00]
| | | | | | | | |--- feature_6 > 0.59
| | | | | | | | | |--- value: [547.00]
| | | | | | |--- feature_3 > 4.00
| | | | | | | |--- value: [692.00]
| | | | | |--- feature_1 > 5.50
| | | | | | |--- feature_8 <= 0.89
| | | | | | | |--- feature_7 <= 0.55
| | | | | | | | |--- value: [438.00]
| | | | | | | |--- feature_7 > 0.55
| | | | | | | | |--- feature_6 <= 0.64
| | | | | | | | | |--- value: [480.00]
| | | | | | | | |--- feature_6 > 0.64
| | | | | | | | | |--- value: [477.00]
| | | | | | |--- feature_8 > 0.89
| | | | | | | |--- value: [555.00]
| | | |--- feature_5 > 2.50
| | | | |--- feature_6 <= 0.50
| | | | | |--- value: [126.00]
| | | | |--- feature_6 > 0.50
| | | | | |--- feature_6 <= 0.57
| | | | | | |--- feature_7 <= 0.51
| | | | | | | |--- value: [254.00]
| | | | | | |--- feature_7 > 0.51
| | | | | | | |--- feature_3 <= 2.50
| | | | | | | | |--- value: [204.00]
| | | | | | | |--- feature_3 > 2.50
| | | | | | | | |--- value: [217.00]
| | | | | |--- feature_6 > 0.57
| | | | | | |--- value: [315.00]
# Evaluate the model using the test data
predictions = model.predict(X_test)
mse = mean_squared_error(y_test, predictions)
print("MSE:", mse)
rmse = np.sqrt(mse)
print("RMSE:", rmse)
r2 = r2_score(y_test, predictions)
print("R2:", r2)
# Plot predicted vs actual
plt.scatter(y_test, predictions)
plt.xlabel('Actual Labels')
plt.ylabel('Predicted Labels')
plt.title('Daily Bike Share Predictions')
# overlay the regression line
z = np.polyfit(y_test, predictions, 1)
p = np.poly1d(z)
plt.plot(y_test,p(y_test), color='magenta')
plt.show()
MSE: 280549.60909090907
RMSE: 529.6693393910101
R2: 0.45000009969268906
from sklearn.ensemble import RandomForestRegressor
# Train the model
model = RandomForestRegressor().fit(X_train, y_train)
print (model, "\n")
# Evaluate the model using the test data
predictions = model.predict(X_test)
mse = mean_squared_error(y_test, predictions)
print("MSE:", mse)
rmse = np.sqrt(mse)
print("RMSE:", rmse)
r2 = r2_score(y_test, predictions)
print("R2:", r2)
# Plot predicted vs actual
plt.scatter(y_test, predictions)
plt.xlabel('Actual Labels')
plt.ylabel('Predicted Labels')
plt.title('Daily Bike Share Predictions')
# overlay the regression line
z = np.polyfit(y_test, predictions, 1)
p = np.poly1d(z)
plt.plot(y_test,p(y_test), color='magenta')
plt.show()
RandomForestRegressor()
MSE: 116012.99565818181
RMSE: 340.60680506734127
R2: 0.7725638034103391
# Train the model
from sklearn.ensemble import GradientBoostingRegressor
# Fit a lasso model on the training set
model = GradientBoostingRegressor().fit(X_train, y_train)
print (model, "\n")
# Evaluate the model using the test data
predictions = model.predict(X_test)
mse = mean_squared_error(y_test, predictions)
print("MSE:", mse)
rmse = np.sqrt(mse)
print("RMSE:", rmse)
r2 = r2_score(y_test, predictions)
print("R2:", r2)
# Plot predicted vs actual
plt.scatter(y_test, predictions)
plt.xlabel('Actual Labels')
plt.ylabel('Predicted Labels')
plt.title('Daily Bike Share Predictions')
# overlay the regression line
z = np.polyfit(y_test, predictions, 1)
p = np.poly1d(z)
plt.plot(y_test,p(y_test), color='magenta')
plt.show()
GradientBoostingRegressor()
MSE: 103989.17432654052
RMSE: 322.47352500095343
R2: 0.7961357504721963
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import make_scorer, r2_score
# Use a Gradient Boosting algorithm
alg = GradientBoostingRegressor()
# Try these hyperparameter values
params = {
'learning_rate': [0.1, 0.5, 1.0],
'n_estimators' : [50, 100, 150]
}
# Find the best hyperparameter combination to optimize the R2 metric
score = make_scorer(r2_score)
gridsearch = GridSearchCV(alg, params, scoring=score, cv=3, return_train_score=True)
gridsearch.fit(X_train, y_train)
print("Best parameter combination:", gridsearch.best_params_, "\n")
# Get the best model
model=gridsearch.best_estimator_
print(model, "\n")
# Evaluate the model using the test data
predictions = model.predict(X_test)
mse = mean_squared_error(y_test, predictions)
print("MSE:", mse)
rmse = np.sqrt(mse)
print("RMSE:", rmse)
r2 = r2_score(y_test, predictions)
print("R2:", r2)
# Plot predicted vs actual
plt.scatter(y_test, predictions)
plt.xlabel('Actual Labels')
plt.ylabel('Predicted Labels')
plt.title('Daily Bike Share Predictions')
# overlay the regression line
z = np.polyfit(y_test, predictions, 1)
p = np.poly1d(z)
plt.plot(y_test,p(y_test), color='magenta')
plt.show()
Best parameter combination: {'learning_rate': 0.1, 'n_estimators': 50}
GradientBoostingRegressor(n_estimators=50)
MSE: 109481.44017553465
RMSE: 330.8797971704145
R2: 0.7853685079898546
# Train the model
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.linear_model import LinearRegression
import numpy as np
# Define preprocessing for numeric columns (scale them)
numeric_features = [6,7,8,9]
numeric_transformer = Pipeline(steps=[
('scaler', StandardScaler())])
# Define preprocessing for categorical features (encode them)
categorical_features = [0,1,2,3,4,5]
categorical_transformer = Pipeline(steps=[
('onehot', OneHotEncoder(handle_unknown='ignore'))])
# Combine preprocessing steps
preprocessor = ColumnTransformer(
transformers=[
('num', numeric_transformer, numeric_features),
('cat', categorical_transformer, categorical_features)])
# Create preprocessing and training pipeline
pipeline = Pipeline(steps=[('preprocessor', preprocessor),
('regressor', GradientBoostingRegressor())])
# fit the pipeline to train a linear regression model on the training set
model = pipeline.fit(X_train, (y_train))
print (model)
Pipeline(steps=[('preprocessor',
ColumnTransformer(transformers=[('num',
Pipeline(steps=[('scaler',
StandardScaler())]),
[6, 7, 8, 9]),
('cat',
Pipeline(steps=[('onehot',
OneHotEncoder(handle_unknown='ignore'))]),
[0, 1, 2, 3, 4, 5])])),
('regressor', GradientBoostingRegressor())])
# Get predictions
predictions = model.predict(X_test)
# Display metrics
mse = mean_squared_error(y_test, predictions)
print("MSE:", mse)
rmse = np.sqrt(mse)
print("RMSE:", rmse)
r2 = r2_score(y_test, predictions)
print("R2:", r2)
# Plot predicted vs actual
plt.scatter(y_test, predictions)
plt.xlabel('Actual Labels')
plt.ylabel('Predicted Labels')
plt.title('Daily Bike Share Predictions')
z = np.polyfit(y_test, predictions, 1)
p = np.poly1d(z)
plt.plot(y_test,p(y_test), color='magenta')
plt.show()
MSE: 105279.54142181159
RMSE: 324.46808999008147
R2: 0.7936060667700566
# Use a different estimator in the pipeline
pipeline = Pipeline(steps=[('preprocessor', preprocessor),
('regressor', RandomForestRegressor())])
# fit the pipeline to train a linear regression model on the training set
model = pipeline.fit(X_train, (y_train))
print (model, "\n")
# Get predictions
predictions = model.predict(X_test)
# Display metrics
mse = mean_squared_error(y_test, predictions)
print("MSE:", mse)
rmse = np.sqrt(mse)
print("RMSE:", rmse)
r2 = r2_score(y_test, predictions)
print("R2:", r2)
# Plot predicted vs actual
plt.scatter(y_test, predictions)
plt.xlabel('Actual Labels')
plt.ylabel('Predicted Labels')
plt.title('Daily Bike Share Predictions - Preprocessed')
z = np.polyfit(y_test, predictions, 1)
p = np.poly1d(z)
plt.plot(y_test,p(y_test), color='magenta')
plt.show()
Pipeline(steps=[('preprocessor',
ColumnTransformer(transformers=[('num',
Pipeline(steps=[('scaler',
StandardScaler())]),
[6, 7, 8, 9]),
('cat',
Pipeline(steps=[('onehot',
OneHotEncoder(handle_unknown='ignore'))]),
[0, 1, 2, 3, 4, 5])])),
('regressor', RandomForestRegressor())])
MSE: 106586.44287772727
RMSE: 326.4757921771954
R2: 0.79104396849163
import joblib
# Save the model as a pickle file
filename = './models/bike-share.pkl'
joblib.dump(model, filename)
# Load the model from the file
loaded_model = joblib.load(filename)
# Create a numpy array containing a new observation (for example tomorrow's seasonal and weather forecast information)
X_new = np.array([[1,1,0,3,1,1,0.226957,0.22927,0.436957,0.1869]]).astype('float64')
print ('New sample: {}'.format(list(X_new[0])))
# Use the model to predict tomorrow's rentals
result = loaded_model.predict(X_new)
print('Prediction: {:.0f} rentals'.format(np.round(result[0])))
New sample: [1.0, 1.0, 0.0, 3.0, 1.0, 1.0, 0.226957, 0.22927, 0.436957, 0.1869]
Prediction: 99 rentals
# An array of features based on five-day weather forecast
X_new = np.array([[0,1,1,0,0,1,0.344167,0.363625,0.805833,0.160446],
[0,1,0,1,0,1,0.363478,0.353739,0.696087,0.248539],
[0,1,0,2,0,1,0.196364,0.189405,0.437273,0.248309],
[0,1,0,3,0,1,0.2,0.212122,0.590435,0.160296],
[0,1,0,4,0,1,0.226957,0.22927,0.436957,0.1869]])
# Use the model to predict rentals
results = loaded_model.predict(X_new)
print('5-day rental predictions:')
for prediction in results:
print(np.round(prediction))
5-day rental predictions:
561.0
838.0
234.0
193.0
291.0