示例#1
0
        f.write('lr: {0}\n'.format(hp.lr))
        f.write('lr_scheduler_step_size: {0}\n'.format(
            hp.lr_scheduler_step_size))
        f.write('max_epoch: {0}\n'.format(hp.max_epoch))
        if hp.optimizer != 'sgdr':
            f.write('lr_gamma: {0}\n'.format(hp.lr_gamma))
        else:
            f.write('sgdr_T_mult: {0}\n'.format(hp.sgdr_T_mult))
        f.write('lr_sgd_momentum: {0}\n'.format(hp.lr_sgd_momentum))
        f.write('lr_weight_decay: {0}\n'.format(hp.lr_weight_decay))
        f.write('bn_momentum: {0}\n'.format(hp.bn_momentum))
        f.write('bn_gamma: {0}\n'.format(hp.bn_gamma))
        f.write('bn_clip: {0}\n'.format(hp.bn_clip))
        f.write('bn_step_size: {0}\n'.format(hp.bn_step_size))
        f.write('optimizer: {0}\n'.format(hp.optimizer))
        f.write('net: {0}\n'.format(hp.net))
        f.write('grid_size: {0}\n'.format(hp.grid_size))
        f.write('time_step: {0}\n'.format(hp.time_step))
        f.write('pic_flip: {0}\n'.format(hp.pic_flip))
        f.write('sigma: {0}\n'.format(hp.sigma))
        f.write('manual_seed: {0}\n'.format(hp.manual_seed))
        f.write('device: {0}\n'.format(hp.device))
        f.write('batch_size: {0}\n'.format(hp.batch_size))
        f.write('drop_rate: {0}\n'.format(hp.drop_rate))
        f.write('label_smooth: {0}\n'.format(hp.label_smooth))
        f.write('penalty: {0}\n'.format(hp.penalty))
        f.write('oversampling: {0}\n'.format(hp.oversampling))
        f.write('batch_norm: {0}\n'.format(hp.batch_norm))

    trainer.train()
示例#2
0
                "mobileData?access_token=QCOI7AjXi7Is90f9hK0BQsOQuKxoU2ISnBa9HLt6Bmsg0nvQbOqPAbELCzTsl2ww"
    sensorUrl = "http://sensing-ms-api.mybluemix.net/api/Patients/0/" \
                "sensorData?access_token=QCOI7AjXi7Is90f9hK0BQsOQuKxoU2ISnBa9HLt6Bmsg0nvQbOqPAbELCzTsl2ww"
    featuresNames = ["heartrate", "temperature", "steps", "activity"]
    allFeaturesNames = [
        "heartrate_std", "heartrate_max", "heartrate_avg", "heartrate_min",
        "temperature_std", "temperature_max", "temperature_avg", "temperature_min",
        "steps", "activity_score", "activity_minutes"

    ]
    mobileData = getData(mobileUrl)
    sensorData = getData(sensorUrl)
    groups = groupData(mobileData, sensorData)
    features, labels = extractFeatures(groups, featuresNames)
    clf = Classifier()
    clf.train(features, labels)
    rules = clf.getDangerousRules(allFeaturesNames)
    print rules
    maxSeconds = 1
    seconds = maxSeconds
    previousSensorData = None
    while True:
        if seconds > 0:
            print "\nWaiting for "+str(seconds)+" seconds."
            sleep(1)
            seconds -= 1
        else:
            print "\nStarting again..."
            latestSensorData = getLatestSensorData(sensorUrl)
            if previousSensorData is None or latestSensorData["datetime"] != previousSensorData["datetime"]:
                previousSensorData = latestSensorData
示例#3
0
 mobileUrl = "http://sensing-ms-api.mybluemix.net/api/Patients/0/" \
             "mobileData?access_token=QCOI7AjXi7Is90f9hK0BQsOQuKxoU2ISnBa9HLt6Bmsg0nvQbOqPAbELCzTsl2ww"
 sensorUrl = "http://sensing-ms-api.mybluemix.net/api/Patients/0/" \
             "sensorData?access_token=QCOI7AjXi7Is90f9hK0BQsOQuKxoU2ISnBa9HLt6Bmsg0nvQbOqPAbELCzTsl2ww"
 featuresNames = ["heartrate", "temperature", "steps", "activity"]
 allFeaturesNames = [
     "heartrate_std", "heartrate_max", "heartrate_avg", "heartrate_min",
     "temperature_std", "temperature_max", "temperature_avg",
     "temperature_min", "steps", "activity_score", "activity_minutes"
 ]
 mobileData = getData(mobileUrl)
 sensorData = getData(sensorUrl)
 groups = groupData(mobileData, sensorData)
 features, labels = extractFeatures(groups, featuresNames)
 clf = Classifier()
 clf.train(features, labels)
 rules = clf.getDangerousRules(allFeaturesNames)
 print rules
 maxSeconds = 1
 seconds = maxSeconds
 previousSensorData = None
 while True:
     if seconds > 0:
         print "\nWaiting for " + str(seconds) + " seconds."
         sleep(1)
         seconds -= 1
     else:
         print "\nStarting again..."
         latestSensorData = getLatestSensorData(sensorUrl)
         if previousSensorData is None or latestSensorData[
                 "datetime"] != previousSensorData["datetime"]: