In this unit, we describe the procedure for training the commuter activity classifier. Further, we present the classification result for commuter activity classifier.

Commuter activity classifier

[1]:
'''Import and initialize MongoClient'''
import subprocess
import os
import sys
import json
from pymongo import     MongoClient
con = MongoClient()
from scipy import integrate
import numpy as np
import pprint
import math
from pathlib import Path
[2]:
'''Import project specific library'''
sys.path.append(os.path.join(os.getcwd(), 'LibCode'))
import ReadAcclGPSRecord
import SegmentsOtherThanStoppageSegments
import EarthaxisAcceleration
import EarthaxisAccelerationOnRawRecords
import ComputeFeaturesTransportMode
import FeaturesExtraction
import TransportModeFeatureHelper
import CAC_Helper
[3]:
'''Import Libs'''
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import accuracy_score, confusion_matrix,precision_score, recall_score, f1_score
from sklearn import tree
from sklearn.svm import SVC
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import GaussianNB
from collections import Counter
from sklearn.impute import SimpleImputer
[4]:
'''For updating the lib changes effects'''
import importlib
importlib.reload(ReadAcclGPSRecord)
importlib.reload(SegmentsOtherThanStoppageSegments)
importlib.reload(EarthaxisAcceleration)
importlib.reload(EarthaxisAccelerationOnRawRecords)
importlib.reload(ComputeFeaturesTransportMode)
importlib.reload(FeaturesExtraction)
importlib.reload(TransportModeFeatureHelper)
importlib.reload(CAC_Helper)
[4]:
<module 'CAC_Helper' from '/home/pruthvish/JRF/GitVersion_APTS_Software_Np/code/LibCode/CAC_Helper.py'>

Save in MongoDB

The commuter activity classifier is trained and validated using the trip records of the learning module. Aforementioned, the learning module application is carried by the data colleciton volunteers on their trips on different types of vehicles. The accelerometer record is stored in the RouteName = HAR_PDPU_SANAND database of MongoDB.

[5]:
def ReadAndSaveData(SitStandRecordDir, RouteName):

    '''
    input: The route name and dataset directory name

    output: None

    function: It fetches the data records placed in the specified data set directory
    and save them in the MongoDB database
    '''

    '''E.g., BM, CM, Bike, Car'''
    for fileName in [f for f in os.listdir(os.path.join(SitStandRecordDir,RouteName))]:
        fileNameList = fileName.split('_')
        #print(fileName)
        ReadAcclGPSRecord.SaveInMongoFunction(RouteName,
                                              os.path.join(SitStandRecordDir,RouteName,fileName),
                                              fileNameList[0]+'.'+fileNameList[1]+'.'+fileNameList[2]+'.'+fileNameList[3])

Decomposition of accelerometer data

The accelerometer record data is decomposed to horizontal and vertical components with the IntervalLength of 140 points.

[6]:
def ComputeEarthAxisComponentRaw(RouteName, IntervalLength, RecordType):

    '''
    input: The route name, interval length for computing accelerometer components
    and record type variable to specify the segment type of the records.

    output: None

    function: It extracts the raw accelerometer records from the MongoDB database
    for the entire trip records and executes the code to compute the horizontal and
    vertical components based on the method proposed in Jigsaw paper.
    '''

    '''To EarthAxis'''
    SingleTripsInfo = [LR['SingleTripInfo'] for LR in
                       con[RouteName]['TripsInfo'].find({'ConvertedToEarthAxis':False})]

    for SingleTripInfo in SingleTripsInfo:
        print(SingleTripInfo)

        AcclMagRecord = [collection for collection in
                         con[RouteName][SingleTripInfo+'.AcclMagData.Raw'].find().sort([('GPSIndex',1)])]

        AcclMagRecord = CAC_Helper.GetSlicedAcclMagRecord(RouteName,SingleTripInfo)

        EarthaxisAccelerationOnRawRecords.ProcessEarthaxisHVComponentUsingJigSawMethod (RouteName,
                                                                                        SingleTripInfo,
                                                                                        AcclMagRecord,
                                                                                        IntervalLength,RecordType)
        con[RouteName]['TripsInfo'].update_one(
            {'SingleTripInfo':SingleTripInfo},{'$set':{'ConvertedToEarthAxisRaw':True}})

Feature extraction

The feature set-1 to set-4 are computed using the orientation independent horizontal and vertical components of accelerometer records for the window of 128 samples and 50% overlap.

[7]:
def GetMode(SingleTripInfo):

    '''
    input: The trip name
    output: The mode of the trip name
    function: It extracts the mode (label) of the trip records
    '''

    if (SingleTripInfo.split('.')[1] == 'Seating' or SingleTripInfo.split('.')[1] == 'Sitting') and (SingleTripInfo.split('.')[2]=='Hand'):
        Mode = 0

    elif (SingleTripInfo.split('.')[1] == 'Seating' or SingleTripInfo.split('.')[1] == 'Sitting') and (SingleTripInfo.split('.')[2]=='ShirtPocket'):
        Mode = 1

    elif (SingleTripInfo.split('.')[1] == 'Standing') and (SingleTripInfo.split('.')[2]=='ShirtPocket'):
        Mode = 2

    elif (SingleTripInfo.split('.')[1] == 'Standing') and (SingleTripInfo.split('.')[2]=='TrouserPocket'):
        Mode = 3

    elif (SingleTripInfo.split('.')[1] == 'Standing') and (SingleTripInfo.split('.')[2]=='Hand'):
        Mode = 4

    return(Mode)
[8]:
def ComputeFeatures_Raw(ProjectDataUsed, WindowList, WindowIndex, RecordType, RouteName):

    '''
    input: The ProjectDataUsed variable specify whether the project dataset should to use project
    dataset or the user collected dataset. The other variables specify the window size for feature
    computation, record type (Raw or Segment other than stoppage segment), and route name.

    output: None

    function: It extracts the appropriate accelerometer components from the MongoDB database based
    on the provided input and computes the features on the windowed accelerometer component. The
    computed features are stored in the MongoDB database.
    '''

    SingleTripsInfo = [LR['SingleTripInfo'] for LR in
                       con[RouteName]['TripsInfo'].find({'FeaturesExtracted':False})]
    for SingleTripInfo in SingleTripsInfo:
        print(SingleTripInfo)
        HVRecord = [Rec for Rec in
                    con[RouteName][SingleTripInfo+'.EAccHVComponent'+RecordType].find().sort([('GPSIndex',1)])]

        #print(HVRecord[0])
        #input()
        Mode = GetMode(SingleTripInfo)

        FeaturesExtraction.ComputeFeatureForComponents(RouteName,HVRecord,Mode,
                                                       WindowSize,SingleTripInfo,RecordType)

        ComputeFeaturesTransportMode.ComputeFeature(SingleTripInfo,HVRecord,Mode,WindowSize,
                                                    RecordType, RouteName)

        con[RouteName]['TripsInfo'].update_one({'SingleTripInfo':SingleTripInfo},
                                               {'$set':{'FeaturesExtracted':True}})


    '''
    if ProjectDataUsed==True:


    else:
        Trips = SingleTripsInfo = [LR['SingleTripInfo'] for LR in con[RouteName]['TripsInfo'].find(
            {'ConvertedToEarthAxisRaw':True})]

        BusTrips = [Trip for Trip in Trips if Trip.split['_'][1]=='Bus']
        CarTrips = [Trip for Trip in Trips if Trip.split['_'][1]=='Car']
        BikeTrips = [Trip for Trip in Trips if Trip.split['_'][1]=='Bike']

        TransportModeFeatureHelper.GetFeaturesForGivenTripType (BusTrips, 0,
                                                                WindowList[WindowIndex],RecordType, RouteName)
        TransportModeFeatureHelper.GetFeaturesForGivenTripType (CarTrips, 1,
                                                                WindowList[WindowIndex],RecordType, RouteName)
        TransportModeFeatureHelper.GetFeaturesForGivenTripType (BikeTrips, 2,
                                                                WindowList[WindowIndex],RecordType, RouteName)
    '''

Processing: For Records other than Stoppage Segment

This section describes the procedure for training the classifier on the segments other than stoppage segment.

Decomposition of accelerometer data

The accelerometer record data is decomposed to horizontal and vertical components with the IntervalLength of 140 points.

[9]:
def ExtractSegment_EarthAxis_OtherThanStoppages(RouteName, Speed_H = 5.6, Speed_L = 3):

    '''
    input: The route name, interval length for computing accelerometer components,
    speed range for computing stoppage segments and record type variable to specify
    the segment type of the records.

    output: None

    function: It extracts the raw accelerometer records from the MongoDB database
    for the computing stoppage segments and executes the code to compute the horizontal
    and vertical components based on the method proposed in Jigsaw paper.
    '''


    '''Extract segment other than stoppage segments'''
    if ProjectDataUsed==True:
        BMSingleTripsInfoList,CMSingleTripsInfoList,PDSingleTripsInfoList = SegmentsOtherThanStoppageSegments.GetTripsBasedOnType(RouteName)

        SegmentsOtherThanStoppageSegments.GetBMAndPDSegments(RouteName,BMSingleTripsInfoList,Speed_H, Speed_L)
        SegmentsOtherThanStoppageSegments.GetBMAndPDSegments(RouteName,PDSingleTripsInfoList,Speed_H, Speed_L)
        SegmentsOtherThanStoppageSegments.GetCMSegments(RouteName,CMSingleTripsInfoList,BMSingleTripsInfoList)
        SegmentsOtherThanStoppageSegments.GetGPSAndAcclReadOfSegment(RouteName)

    else:
        SingleTripsInfo = [LR['SingleTripInfo'] for LR in con[RouteName]['TripsInfo'].find({'SegmentExtracted':False})]
        SegmentsOtherThanStoppageSegments.GetBMAndPDSegments(RouteName,SingleTripsInfo, Speed_H, Speed_L)
        SegmentsOtherThanStoppageSegments.GetGPSAndAcclReadOfSegment(RouteName)

    '''
    for SingleTripInfo in SingleTripsInfo:
        con[RouteName]['TripsInfo'].update_one(
            {'SingleTripInfo':SingleTripInfo},{'$set':{'ConvertedToEarthAxis':False}})
    '''

    EarthaxisAcceleration.ConvertToEarthaxisAcc(RouteName,RecordType)
[10]:
def ComputeFeatures_SegmentOtherThanStoppages_SitStand(ProjectDataUsed, WindowList,
                                                       WindowIndex, RecordType, RouteName):

    '''
    input:
        ProjectDataUsed: flag to determine whether the project dataset or user dataset is used
        WindowList and WindowIndex: The window length for feature computation
        RecordType: The flag to determine whether the features of entire trip is used (.Raw) or
        the features of segment other than stoppage segments is used (.SegmentOtherThanStoppage).

    output: None

    function: It computes the features for the segment other than stoppage segments for the
    provided route name.
    '''

    '''Recent Attempt'''
    Trips = [LR['SingleTripInfo'] for LR in con[RouteName]['TripsInfo'].find(
        {'ConvertedToEarthAxis':True})]

    #Mode = GetMode(Trips)

    TransportModeFeatureHelper.ExtractFeaturesOfGivenTypeOfTrip(Trips,"Bus",0,
                                                                WindowList[WindowIndex],RecordType, RouteName)

For saving Mongo data in numpy

[11]:
def LoadInMongoFromNp(RouteName, NpPathDir):

    '''
    input: The route name and numpy directory path
    output: The MongoDB database collections from the Numpy files
    function: It creates the MongoDB database of TripsInfo collections
    and features collections from the Numpy files.
    '''

    CollectionName = 'TripsInfo'
    TripsInfoRecords = np.load(f'{NpPathDir}/{RouteName}/{CollectionName}.npy', allow_pickle=True)

    print('Saving data in mongoDB')
    print(RouteName, CollectionName)
    con[RouteName][CollectionName].insert_many(TripsInfoRecords.tolist())

    CollectionNames = os.listdir(f'{NpPathDir}/{RouteName}')
    #print(CollectionNames)

    CollectionNames_1 = [rec for rec in CollectionNames if '\'.' not in rec] # To address the error
    CollectionNames_2 = [rec for rec in CollectionNames if 'Feature' in rec]

    #print('Saving data in mongoDB')
    for Collection in CollectionNames_2:
        RecordsList = np.load(f'{NpPathDir}/{RouteName}/{Collection}', allow_pickle=True)
        #print(Collection)
        #pprint.pprint(RecordsList[0:3])

        CollectionName = Collection[0:-4]

        print(RouteName, CollectionName)
        con[RouteName][CollectionName].insert_many(RecordsList.tolist())



def SaveInNp(RouteName, NpPathDir):

    '''
    input: The route name and numpy directory path
    output: Numpy files of the MongoDB database
    function: It stores the Numpy files for the MongoDB database in the specified directory path
    '''


    CollectionNames = [Collection for Collection in
                        con[RouteName].list_collection_names() if Collection!='system.indexes']

    for CollectionName in CollectionNames:
        print('CollectionName', CollectionName)
        RecordsList = [rec for rec in con[RouteName][CollectionName].find().sort([('_id',1)])]

        for RecordDict in RecordsList:
            del[RecordDict['_id']]

        if os.path.exists(os.path.join(NpPathDir, RouteName)) == False:
            os.mkdir(os.path.join(NpPathDir, RouteName))


        #np.save(f'{Path}/{Database}/{CollectionName}.npy', RecordsList)
        np.save(os.path.join(NpPathDir, RouteName,f'{CollectionName}.npy'), RecordsList)

Execute the preprocessing

Parameters

[12]:
path = Path(os.getcwd())
OneLevelUpPath = path.parents[0]
[13]:
IntervalLength = 160

'''Trips and Window size for Feature extraction'''
#BMSingleTripsInfoList,CMSingleTripsInfoList,PDSingleTripsInfoList = TransportModeFeatureHelper.GetTripsBasedOnType(RouteName)
WindowList = [32,64,128,256,512]
WindowIndex = 2
WindowSize = WindowList[WindowIndex]

'''For segment other than stoppages'''
Speed_H = 5.6
Speed_L = 3

'''Path for Np'''
NpPathDir = os.path.join(str(OneLevelUpPath), 'data','NpData')

Variables

ProjectDataUsed: determines whether the project data or the user’s own data is used for execution.

UsedPreTrained: determines whether the pretrained and precomputed dataset or raw data is used for execution.

UseMongoDB: determines whether the MonngoDB database or Numpy file is used for execution.

ReducedKFolds: If false: one fold is used, else ten-fold is used

[15]:
'''
ProjectDataUsed = True
UsedPreTrained = True
ReducedKFolds = False
UseMongoDB = True
'''

#'''
ProjectDataUsed = True
UsedPreTrained = True
ReducedKFolds = True
UseMongoDB = False
#'''

'''
ProjectDataUsed = True
UsedPreTrained = False
ReducedKFolds = False
UseMongoDB = False
'''
[ ]:
#SitStandRecordDir = '/home/pruthvish/JRF/GitVersion_PMC/Data/SitStandRecord'
if ProjectDataUsed==True:
    SitStandRecordDir = os.path.join(str(OneLevelUpPath), 'data','SitStandRecord','')
else:
    SitStandRecordDir = os.path.join(str(OneLevelUpPath), 'data','UserData','SitStandRecord','')
#RouteNamesList = [f for f in os.listdir(SitStandRecordDir)]
RouteNamesList = ['HAR_PDPU_SANAND_ ', 'HAR_PDPU_SANAND_Triggers_']

Code

[16]:
for RouteName in RouteNamesList:
    print(RouteName)
    if UsedPreTrained==False and UseMongoDB==True:
        print('Reading data and saving in MongoDB')
        ReadAndSaveData(SitStandRecordDir, RouteName)

        RecordType = '.Raw'
        print(f'Computing preprocessing for {RecordType} segments')
        ComputeEarthAxisComponentRaw(RouteName, IntervalLength, RecordType)
        print(f'Computing features for {RecordType} segments')
        ComputeFeatures_Raw(ProjectDataUsed, WindowList, WindowIndex, RecordType, RouteName)

        if RouteName == 'HAR_PDPU_SANAND_':
            RecordType = '.SegmentOtherThanStoppage'
            print(f'Computing preprocessing for {RecordType} segments')
            ExtractSegment_EarthAxis_OtherThanStoppages(RouteName, Speed_H , Speed_L)
            print(f'Computing features for {RecordType} segments')
            ComputeFeatures_SegmentOtherThanStoppages_SitStand(ProjectDataUsed, WindowList, WindowIndex,
                                                      RecordType, RouteName)

        print('Saving MongoData in Np files')
        SaveInNp(RouteName, NpPathDir)

    elif UseMongoDB==True:
        RouteNamesListInDB = con.list_database_names()
        if RouteName not in RouteNamesListInDB:
            '''Load the data for RouteName, if RouteName is not in RouteNamesList'''
            print('Loading MongoData from Np files')
            LoadInMongoFromNp(RouteName, NpPathDir)

HAR_PDPU_SANAND_Triggers_
HAR_PDPU_SANAND_

Classification

[17]:
'''Import Libs'''
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import accuracy_score, confusion_matrix,precision_score, recall_score, f1_score
from sklearn import tree
from sklearn.svm import SVC
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import GaussianNB
from collections import Counter
from sklearn.impute import SimpleImputer
[18]:
'''Variables for Classification'''
ResultPathDir = os.path.join(str(OneLevelUpPath), 'results','SitStand','')

if os.path.exists(ResultPathDir) == False:
    os.mkdir(ResultPathDir)

TrainedModelPathDir = os.path.join(str(OneLevelUpPath), 'data', 'TrainedModel','SitStand','')
'''Any one route type as decided by Stoppage experiment'''
#RecordType = '.SegmentOtherThanStoppage'
#RecordType = '.StoppageSegment'
RecordType = '.Raw'

ClassifierList = [GaussianNB(), LogisticRegression(random_state=0),
                  RandomForestClassifier(max_depth=20), tree.DecisionTreeClassifier(),
                  SVC(gamma='auto')
                 ]
ClassifierNameList = ['NB', 'LogisticRegression', 'RF', 'DT', 'SVC']
[19]:
def GetFeaturesForClass(RouteNameTestList, FeatureType, RecordType,
                        SelectedFeatures, SelectedFeaturesFlag, NpPathDir, UseMongoDB):
    '''
    if ProjectDataUsed==True:
        X, y = TMC_Helper.GetData(FeatureType, RecordType, SelectedFeatures, SelectedFeaturesFlag)
    else:
    '''
    #X = []
    #y = []
    if UseMongoDB==True:
        First_InputFlag = True

        for RouteNameTest in RouteNameTestList:
            X_Route, y_Route = CAC_Helper.GetData_User(RouteNameTest, FeatureType, RecordType,
                                                       SelectedFeatures, SelectedFeaturesFlag)

            if First_InputFlag==True:
                X = X_Route
                y = y_Route
                First_InputFlag = False

            else:
                X = np.concatenate((X, X_Route))
                y = np.concatenate((y, y_Route))
                '''
                X += X_Route
                y += y_Route
                '''

            print('X.shape', X.shape)
            print('y.shape', y.shape)

        '''Save in NpData'''

        if os.path.exists(os.path.join(NpPathDir,'SitStand'))==False:
            os.mkdir(os.path.join(NpPathDir,'SitStand'))

        np.save(f'{NpPathDir}/SitStand/X_{FeatureType}_{RecordType}_{SelectedFeaturesFlag}.npy', X)
        np.save(f'{NpPathDir}/SitStand/y_{FeatureType}_{RecordType}_{SelectedFeaturesFlag}.npy', y)

    else:
        X = np.load(f'{NpPathDir}/SitStand/X_{FeatureType}_{RecordType}_{SelectedFeaturesFlag}.npy',
                    allow_pickle=True)
        y = np.load(f'{NpPathDir}/SitStand/y_{FeatureType}_{RecordType}_{SelectedFeaturesFlag}.npy',
                    allow_pickle=True)

    return(X, y)
[20]:
def ApplyClassification(Classes, FeatureType, RecordType, SelectedFeatures, SelectedFeaturesFlag,
                        Classifier, ClassifierName, ResultPathDir, ProjectDataUsed, RouteNameTestList,
                        UsedPreTrained, ClassifierName_ForModelSave, TrainedModelPathDir, ReducedKFolds,
                        NpPathDir, UseMongoDB
                       ):

    '''
    input:
        Classes: The number of classes

        FeatureType and RecordType: feature type and record type information

        SelectedFeatures and SelectedFeaturesFlag: selected features list and flag to
        determine if selected features are list is used

        Classifier and ClassifierName: classifier object variable and classifier name

        ResultPathDir: path of result directory

        ProjectDataUsed: flag to determine whether the project dataset or user dataset is used

        RouteNameTestList: The route names list to be considered during classification

        UsedPreTrained: Flag to determine whether the pretrained classifier should be used
        or the classifier is to be trained

        ClassifierName_ForModelSave: the name of classifier for saving a model

        TrainedModelPathDir: path of trainedModel directory

        NpPathDir:

        UseMongoDB:

    output: None

    function: It trains and validates the classifier the ten-fold cross-validation with stratified
    sampling of each class. The performance metrics of the classifier is stores as a txt file in the
    result directory

    '''

    MetricsDict = CAC_Helper.InitializeMetricsDict(Classes)


    X, y = GetFeaturesForClass(RouteNameTestList, FeatureType, RecordType,
                               SelectedFeatures, SelectedFeaturesFlag, NpPathDir, UseMongoDB)


    MetricsDict = CAC_Helper.TrainAndPredict(X, y, Classifier, MetricsDict, ResultPathDir,
                                             ClassifierName, UsedPreTrained,
                                             ClassifierName_ForModelSave, TrainedModelPathDir, ReducedKFolds)
    CAC_Helper.PrintMetricsDict(ClassifierName, ResultPathDir, FeatureType, RecordType,
                                SelectedFeaturesFlag, MetricsDict)

    CAC_Helper.InfereSitStand_And_PrintMetrics(MetricsDict, ClassifierName, ResultPathDir)

    '''
    filename = 'finalized_model.sav'
    pickle.dump(model, open(ResultPathDir, 'wb'))
    '''

[21]:
Classes = 5
[22]:
for Classifier, ClassifierName in zip(ClassifierList, ClassifierNameList):
    print('Classifier, ClassifierName', Classifier, ClassifierName)
    #for RecordType in ['.Raw', '.SegmentOtherThanStoppage']:

    '''Feature set-1'''
    FeatureType = '.HARFeature'
    SelectedFeaturesFlag = False
    SelectedFeatures = []

    print('Feature set-1')
    ClassifierName_ForModelSave = ClassifierName+"_Set1"
    ApplyClassification(Classes, FeatureType, RecordType, SelectedFeatures, SelectedFeaturesFlag,
                        Classifier, ClassifierName, ResultPathDir, ProjectDataUsed, RouteNamesList,
                        UsedPreTrained, ClassifierName_ForModelSave, TrainedModelPathDir, ReducedKFolds,
                        NpPathDir, UseMongoDB
                       )

    '''Feature set-2'''
    FeatureType = '.HARFeature'
    SelectedFeaturesFlag = True
    ClassifierName_ForModelSave = ClassifierName+"_Set2"
    SelectedFeatures = CAC_Helper.SelectedFeaturesForFeatureType(FeatureType)

    print('Feature set-2')

    ApplyClassification(Classes, FeatureType, RecordType, SelectedFeatures, SelectedFeaturesFlag,
                        Classifier, ClassifierName, ResultPathDir, ProjectDataUsed, RouteNamesList,
                        UsedPreTrained, ClassifierName_ForModelSave, TrainedModelPathDir, ReducedKFolds,
                        NpPathDir, UseMongoDB
                       )

    '''Feature set-3'''
    FeatureType = '.TransportFeatures'
    SelectedFeatures = []
    SelectedFeaturesFlag = False
    print('Feature set-3')
    ClassifierName_ForModelSave = ClassifierName+"_Set3"

    ApplyClassification(Classes, FeatureType, RecordType, SelectedFeatures, SelectedFeaturesFlag,
                        Classifier, ClassifierName, ResultPathDir, ProjectDataUsed, RouteNamesList,
                        UsedPreTrained, ClassifierName_ForModelSave, TrainedModelPathDir, ReducedKFolds,
                        NpPathDir, UseMongoDB
                       )


    '''Feature set-4'''
    FeatureType = '.TransportFeatures'
    SelectedFeatures = CAC_Helper.SelectedFeaturesForFeatureType(FeatureType)
    SelectedFeaturesFlag = True

    print('Feature set-4')
    ClassifierName_ForModelSave = ClassifierName+"_Set4"
    ApplyClassification(Classes, FeatureType, RecordType, SelectedFeatures, SelectedFeaturesFlag,
                        Classifier, ClassifierName, ResultPathDir, ProjectDataUsed, RouteNamesList,
                        UsedPreTrained, ClassifierName_ForModelSave, TrainedModelPathDir, ReducedKFolds,
                        NpPathDir, UseMongoDB
                       )


Classifier, ClassifierName GaussianNB() NB
Feature set-1
Feature set-2
Feature set-3
Feature set-4
Classifier, ClassifierName LogisticRegression(random_state=0) LogisticRegression
Feature set-1
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
Feature set-2
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
Feature set-3
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
Feature set-4
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
/home/pruthvish/JRF/RoadNetwork/RoadNetwork_VirtualEnv/lib/python3.8/site-packages/sklearn/linear_model/_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:
    https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
  n_iter_i = _check_optimize_result(
Classifier, ClassifierName RandomForestClassifier(max_depth=20) RF
Feature set-1
Feature set-2
Feature set-3
Feature set-4
Classifier, ClassifierName DecisionTreeClassifier() DT
Feature set-1
Feature set-2
Feature set-3
Feature set-4
Classifier, ClassifierName SVC(gamma='auto') SVC
Feature set-1
Feature set-2
Feature set-3
Feature set-4
[23]:
'''Read the value for one of the machine learning algorithm'''
file = os.path.join(ResultPathDir,f'{ClassifierName}.txt')
f = open(file, "r")
print(f.read())
Results for .Raw, .HARFeature, and selected features flag: False
ConfusionMatrix
[[845.   0.   4.  24.   5.]
 [ 12. 902.   0.   5.   3.]
 [  1.   0. 859.   5.   1.]
 [111.   0.  26. 714.   1.]
 [ 78.   5.   6.  23. 309.]]

PrecissionValue
[0.80706781 0.99448732 0.95977654 0.92607004 0.96865204]

RecallValue
[0.96241458 0.97830803 0.99191686 0.83802817 0.73396675]

F1ScoreValue
[0.87792208 0.98633133 0.97558206 0.87985213 0.83513514]

AccuracyValue
0.9212998222899214

Inference for sit-stand
SitStand_ConfusionMetrics
[[1759.   41.]
 [ 195. 1944.]]

PrecissionMetrics
[0.90020471 0.97934509]

RecallMetrics
[0.97722222 0.9088359 ]

Accuracy
0.94008632

Results for .Raw, .HARFeature, and selected features flag: True
ConfusionMatrix
[[831.   2.   4.  32.   9.]
 [ 19. 887.   0.  12.   4.]
 [  4.   0. 855.   6.   1.]
 [150.   0.  25. 676.   1.]
 [ 96.   6.   3.  28. 288.]]

PrecissionValue
[0.75545455 0.99106145 0.96392334 0.89655172 0.95049505]

RecallValue
[0.94646925 0.96203905 0.98729792 0.79342723 0.68408551]

F1ScoreValue
[0.84024267 0.97633462 0.97547062 0.84184309 0.79558011]

AccuracyValue
0.897943640517898

Inference for sit-stand
SitStand_ConfusionMetrics
[[1739.   61.]
 [ 256. 1883.]]

PrecissionMetrics
[0.8716792 0.9686214]

RecallMetrics
[0.96611111 0.88031791]

Accuracy
0.91952272

Results for .Raw, .TransportFeatures, and selected features flag: False
ConfusionMatrix
[[792.   1.   6.  73.   6.]
 [ 26. 886.   0.   8.   2.]
 [  2.   0. 847.  15.   2.]
 [198.   0.  64. 585.   5.]
 [ 93.   6.   4.  53. 265.]]

PrecissionValue
[0.71287129 0.99216125 0.91965255 0.79700272 0.94642857]

RecallValue
[0.90205011 0.96095445 0.97806005 0.68661972 0.62945368]

F1ScoreValue
[0.79638009 0.97630854 0.94795747 0.73770492 0.75606277]

AccuracyValue
0.8568164508758568

Inference for sit-stand
SitStand_ConfusionMetrics
[[1705.   95.]
 [ 299. 1840.]]

PrecissionMetrics
[0.8507984  0.95090439]

RecallMetrics
[0.94722222 0.86021505]

Accuracy
0.89997461

Results for .Raw, .TransportFeatures, and selected features flag: True
ConfusionMatrix
[[666.   1.   6. 197.   8.]
 [ 37. 876.   0.   5.   4.]
 [  2.   0. 854.   8.   2.]
 [136.   0.  78. 632.   6.]
 [ 62.   6.   2.  80. 271.]]

PrecissionValue
[0.73754153 0.99207248 0.90851064 0.68546638 0.93127148]

RecallValue
[0.75854214 0.95010846 0.98614319 0.74178404 0.64370546]

F1ScoreValue
[0.74789444 0.97063712 0.94573643 0.71251409 0.76123596]

AccuracyValue
0.8375222137598375

Inference for sit-stand
SitStand_ConfusionMetrics
[[1580.  220.]
 [ 206. 1933.]]

PrecissionMetrics
[0.88465845 0.897817  ]

RecallMetrics
[0.87777778 0.90369331]

Accuracy
0.89185072

Results for .Raw, .HARFeature, and selected features flag: False
ConfusionMatrix
[[6.411e+03 5.700e+02 1.480e+02 1.345e+03 3.110e+02]
 [2.820e+02 8.695e+03 6.000e+00 1.620e+02 7.300e+01]
 [1.050e+02 3.000e+00 8.478e+03 4.800e+01 2.400e+01]
 [1.283e+03 2.680e+02 1.220e+02 6.548e+03 2.960e+02]
 [3.440e+02 6.900e+01 9.300e+01 3.210e+02 3.385e+03]]

PrecissionValue
[0.77221065 0.90661502 0.95917178 0.78573975 0.83559251]

RecallValue
[0.72973831 0.94326348 0.97921478 0.76881548 0.80366145]

F1ScoreValue
[0.74170005 0.92405406 0.9684548  0.76867826 0.81715013]

AccuracyValue
0.850901243970551

Inference for sit-stand
SitStand_ConfusionMetrics
[[15958.  2045.]
 [ 2072. 19315.]]

PrecissionMetrics
[0.88508042 0.9042603 ]

RecallMetrics
[0.88640782 0.90311872]

Accuracy
0.89548109

Results for .Raw, .HARFeature, and selected features flag: True
ConfusionMatrix
[[6.232e+03 6.290e+02 1.270e+02 1.417e+03 3.800e+02]
 [3.010e+02 8.658e+03 5.000e+00 1.690e+02 8.500e+01]
 [9.500e+01 3.000e+00 8.496e+03 3.600e+01 2.800e+01]
 [1.424e+03 2.420e+02 1.020e+02 6.308e+03 4.410e+02]
 [3.480e+02 6.100e+01 1.020e+02 4.610e+02 3.240e+03]]

PrecissionValue
[0.75463315 0.90437809 0.96269186 0.75994438 0.79393358]

RecallValue
[0.70936727 0.93924905 0.9812933  0.74063281 0.76924328]

F1ScoreValue
[0.7201712  0.92085993 0.97139228 0.74138269 0.77600607]

AccuracyValue
0.8361005331302362

Inference for sit-stand
SitStand_ConfusionMetrics
[[15820.  2183.]
 [ 2173. 19214.]]

PrecissionMetrics
[0.87923081 0.89797635]

RecallMetrics
[0.87874243 0.89839622]

Accuracy
0.88941356

Results for .Raw, .TransportFeatures, and selected features flag: False
ConfusionMatrix
[[6.116e+03 6.870e+02 2.060e+02 1.348e+03 4.280e+02]
 [3.510e+02 8.622e+03 1.100e+01 1.130e+02 1.210e+02]
 [1.110e+02 2.000e+00 8.407e+03 1.080e+02 3.000e+01]
 [1.198e+03 2.990e+02 2.560e+02 6.086e+03 6.780e+02]
 [3.850e+02 6.900e+01 1.020e+02 9.110e+02 2.745e+03]]

PrecissionValue
[0.76300127 0.89270197 0.93830331 0.70882715 0.72055284]

RecallValue
[0.69618289 0.93534414 0.97101617 0.71455151 0.6517235 ]

F1ScoreValue
[0.72226182 0.91297962 0.95307652 0.70703822 0.67477471]

AccuracyValue
0.8117796395024117

Inference for sit-stand
SitStand_ConfusionMetrics
[[15776.  2227.]
 [ 2064. 19323.]]

PrecissionMetrics
[0.88430493 0.89665893]

RecallMetrics
[0.87629839 0.90349278]

Accuracy
0.89106372

Results for .Raw, .TransportFeatures, and selected features flag: True
ConfusionMatrix
[[5831.  591.  233. 1691.  439.]
 [ 397. 8566.   11.  115.  129.]
 [  99.    0. 8393.  133.   33.]
 [ 656.  224.  290. 6334. 1013.]
 [ 271.   51.  105. 1035. 2750.]]

PrecissionValue
[0.8081682  0.90975895 0.93256886 0.68071759 0.67523934]

RecallValue
[0.66373999 0.92927039 0.96939954 0.74364556 0.65290439]

F1ScoreValue
[0.72637961 0.91879468 0.94899862 0.70854827 0.65282446]

AccuracyValue
0.8091901497842091

Inference for sit-stand
SitStand_ConfusionMetrics
[[15385.  2618.]
 [ 1301. 20086.]]

PrecissionMetrics
[0.92203044 0.88468992]

RecallMetrics
[0.85457979 0.93916865]

Accuracy
0.90050774