09.10.2023 Views

Advanced Data Analytics Using Python_ With Machine Learning, Deep Learning and NLP Examples ( 2023)

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3

Supervised Learning Using Python

The following code is an example of a tuning classification condition:

y_test_increasing, predicted_increasing = predict(d1, True, False)

y_test_decreasing, predicted_decreasing = predict(d2, False, False)

prob_increasing = predicted_increasing[:,1]

increasing_mean = prob_increasing.mean()

increasing_std = prob_increasing.std()

prob_decreasing = predicted_decreasing[:,0]

decreasing_mean = prob_decreasing.mean()

decreasing_std = prob_decreasing.std()

ifi> 0:

mean_std_inc = (mean_std_inc + increasing_std)/2

mean_std_dec = (mean_std_dec + decreasing_std)/2

else:

mean_std_inc = increasing_std

mean_std_dec = decreasing_std

for j in range(len(y_test_decreasing)-1):

ac_status = y_test_increasing[j] + y_test_

decreasing[j]

pr_status = 0

if True:

inc = (prob_increasing[j] -

increasing_mean + mean_std_inc)

dec = (prob_decreasing[j] -

decreasing_mean + mean_std_dec)

ifinc> 0 or dec> 0:

ifinc>dec:

pr_status = 1

else:

pr_status = -1

else:

pr_status = 0

72

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!