Wavelet Packet Transform (WPT)

Feature extraction and supervised classification using WPT

This algorithm takes time series for turning experiments as input and it generates the feature matrix based on specified WPT level. The reconstructed Wavelet packets and corresponding frequency domain feature matrices should be computed before running this algorithm. Please see the instructions for Matlab functions on this documentation before using this algorithm. The Wavelet packets frequency domain features and datafiles should be in the same folder. It asks for file paths for the data files. Algorithm performs the classfication with chosen algorithm and provides results in a np.array. It plots the mean accuracies and deviations for test and training set with respect to number of features used in classification, if user enables plotting option of the algorithm. It also prints the total elapsed time.

WPT_Feature_Extraction.WPT_Feature_Extraction(stickout_length, WPT_Level, Classifier, plotting)[source]
Parameters:
  • (stickout_length) (str) –

    The distance between heel of the boring bar and the back surface of the cutting tool

    • if stickout length is 2 inch, ‘2’
    • if stickout length is 2.5 inch, ‘2p5’
    • if stickout length is 3.5 inch, ‘3p5’
    • if stickout length is 4.5 inch, ‘4p5’
  • (WPT_Level) (int) – Level of Wavelet Packet Decomposition
  • (Classifier) (str) –

    Classifier defined by user

    • Support Vector Machine: ‘SVC’
    • Logistic Regression: ‘LR’
    • Random Forest Classification: ‘RF’
    • Gradient Boosting: ‘GB’
  • (Plotting) (str) – Function will return the plot of the results depending on the number of features used in the classification, if the Plotting is ‘True’.
Returns:
results:

(np.array([])) Classification results for training and test set for all combination of ranked features and devition for both set.

  • first column: mean accuracies for training set
  • second column: deviation for training set accuracies
  • third column: mean accuracies for test set
  • fourth column: deviation for test set accuracies
plot:

Deviations and mean accuracies for training and test set vs number of features used in feature matrix generation

time:

(str) Elapsed time during feature matrix generation and classification

Example:
>>> from WPT_Feature_Extraction import WPT_Feature_Extraction
>>> import matplotlib.pyplot as plt
>>> from matplotlib import rc
>>> import matplotlib
>>> matplotlib.rcParams.update({'font.size': 14})
>>> rc('font',**{'family':'serif','serif':['Palatino']})
>>> rc('text', usetex=True)
 
#parameters
 
>>> stickout_length='2'
>>> WPT_Level = 4
>>> Classifier = 'SVC'
>>> plotting = True

>>> results = WPT_Feature_Extraction(stickout_length, WPT_Level, 
>>>                                  Classifier, plotting)     
Enter the path of the data files:
>>> D\...\cutting_tests_processed\data_2inch_stickout
_images/example.jpg

Transfer Learning Application Using WPT

This function uses transfer learning principles to transfer the knowledge obtained from one cutting configuration to another one. It assumes that the reconstructed Wavelet packets and frequency domain features are available an they are in the same folder with the data files. It computes feature matrices for training and test set and performs the classification with chosen algorithm. It returns the results in an array. It also prints the total elapsed time.

WPT_Transfer_Learning.WPT_Transfer_Learning(stickout_length_training, stickout_length_test, WPT_Level, Classifier)[source]
Parameters:
  • (stickout_length_training) (str) –

    Stickout length for the training data set

    • if stickout length is 2 inch, ‘2’
    • if stickout length is 2.5 inch, ‘2p5’
    • if stickout length is 3.5 inch, ‘3p5’
    • if stickout length is 4.5 inch, ‘4p5’
  • (stickout_length_test) (str) –

    Stickout length for the test data set

    • if stickout length is 2 inch, ‘2’
    • if stickout length is 2.5 inch, ‘2p5’
    • if stickout length is 3.5 inch, ‘3p5’
    • if stickout length is 4.5 inch, ‘4p5’
  • (WPT_Level) (int) – Level of Wavelet Packet Decomposition
  • (Classifier) (str) –
    Classifier defined by user
    • Support Vector Machine: ‘SVC’
    • Logistic Regression: ‘LR’
    • Random Forest Classification: ‘RF’
    • Gradient Boosting: ‘GB’
Returns:
results:

(np.array([])) Classification results for training and test set for all combination of ranked features and devition for both set.

  • first column: mean accuracies for training set
  • second column: deviation for training set accuracies
  • third column: mean accuracies for test set
  • fourth column: deviation for test set accuracies
time:

(str) Elapsed time during feature matrix generation and classification

Example:
>>> from WPT_Transfer_Learning import WPT_Transfer_Learning

#parameters
 
>>> stickout_length_training = '2'
>>> stickout_length_test = '4p5'
>>> WPT_Level=4
>>> Classifier='SVC'

>>> results = WPT_Transfer_Learning(stickout_length_training, 
>>>                                     stickout_length_test,
>>>                                    WPT_Level, Classifier)     
Enter the path of training set data files:
>>> D\...\cutting_tests_processed\data_2inch_stickout
Enter the path of test set data files:
>>> D\...\cutting_tests_processed\data_4p5inch_stickout

Transfer Learning On Two Cases Using WPT

This fuction implement transfer learning by training a classifier on two different data sets and testing it on remaining two different data sets. Stickout lengths of each data set should be determined by user. It asks for file paths to training and test set files. It assumes that reconstructed wavelet packets and frequency domain features are available in the specified data file folder. Algorithm performs classfication based on chosen classifier and returns the results in an array. It also prints the total elapsed time.

WPT_Transfer_Learning_2case.WPT_Transfer_Learning_2case(stickout_lengths, WPT_Level, Classifier)[source]
Parameters:
  • (stickout_lengths) (str) –

    Stickout length for the training and test set in a np.array([]) format.First two stickout length are considered as training set data and the remaining ones are test set data.

    • if stickout length is 2 inch, ‘2’
    • if stickout length is 2.5 inch, ‘2p5’
    • if stickout length is 3.5 inch, ‘3p5’
    • if stickout length is 4.5 inch, ‘4p5’
  • (WPT_Level) (int) – Level of Wavelet Packet Decomposition
  • (Classifier) (str) –
    Classifier defined by user
    • Support Vector Machine: ‘SVC’
    • Logistic Regression: ‘LR’
    • Random Forest Classification: ‘RF’
    • Gradient Boosting: ‘GB’
Returns:
results:

(np.array([])) Classification results for training and test set for all combination of ranked features and devition for both set.

  • first column: mean accuracies for training set
  • second column: deviation for training set accuracies
  • third column: mean accuracies for test set
  • fourth column: deviation for test set accuracies
time:

(str) Elapsed time during feature matrix generation and classification

Example:
>>> from WPT_Transfer_Learning_2case import WPT_Transfer_Learning_2case

#parameters
 
>>> stickout_lengths = ['2','2p5','3p5','4p5']
>>> WPT_Level=4
>>> Classifier='SVC'

>>> results = WPT_Transfer_Learning_2case(stickout_lengths, 
>>>                                       WPT_Level, Classifier)     
Enter the path of first training set data files:
>>> D\...\cutting_tests_processed\data_2inch_stickout
Enter the path of second training set data files:
>>> D\...\cutting_tests_processed\data_2p5inch_stickout
Enter the path of first test set data files:
>>> D\...\cutting_tests_processed\data_3p5inch_stickout   
Enter the path of second test set data files:
>>> D\...\cutting_tests_processed\data_4p5inch_stickout