def main():
    data = extract_data_from_csv("")
    derivatives = computeDerivatives(data)
    """sns.set(color_codes=True)
    sns.distplot(derivatives[4])
    plt.show()"""
    intervals = computeConfidenceIntervals(derivatives)
    print(intervals)
    print(findSuspicious(derivatives, intervals))
def main():
    data = extract_data_from_csv("")
    predictor = Predictor(0, 2, 10000, distance_in_future=15)
    vectors, labels = predictor.generateVectors(data)
    predicted_temp = predictor.generatePredictions_oneValue(
        get_classifier(""), vectors)[-1]
    print("Predicted %d degrees Celcius (+/- 2 degrees) in 15 minutes" %
          predicted_temp)
    if predicted_temp > CUTOFF:
        print("Coffee should be made!")
        sendEmail(
            "Our predictive models have determined that your machine should be turned on within the next 15 minutes.",
            "Coffee machine should be turned on!")
 def generateCostDistribution(self,falsified,size,num_datapoints_testing = -1):
     training_proportion = 0.5
     print("Gathering data")
     raw_data = extract_data_from_csv("")
     training_data = raw_data[0:int(len(raw_data)*training_proportion)]
     training_vectors,training_labels = self.generateVectors(training_data)  
     print("Finished gathering data")    
     print("training model")
     clf = getTrainedModel(training_vectors,training_labels)
     print("model trained")
     costs = list()
     for i in range(size):
         testing_data = getRandomTestingDataSample(0.03,training_proportion,raw_data,num_datapoints_testing)        
         costs.append(self.computeCost(falsified,clf,testing_data)[0])
     return costs
 def quickComparison(self):
     print("Gathering data")
     raw_data = extract_data_from_csv("")
     training_data, testing_data = separateData(raw_data,0.75,0,1)
     training_vectors,training_labels = self.generateVectors(training_data)
     print("Sample vector: "+str(training_vectors[0]))
     print("Finished gathering data")    
     print("training model")
     clf = getTrainedModel(training_vectors,training_labels)
     print("model trained")
     cost_normal,testing_labels,predictions = self.computeCost(False,clf,testing_data)
     cost_falsified,testing_labels_falsified,predictions_falsified = self.computeCost(True,clf,testing_data)
     #incremental_costs = calculate_costs(30,predictions,testing_labels)
     #plt.figure(1)
     #plt.plot(incremental_costs)
     #plt.plot([val/30 for val in testing_labels[::30]])
     #plt.show()
     print("Cost when data is not falsified: "+str(cost_normal))
     print("Cost when data is falsified: "+str(cost_falsified))
     return predictions,predictions_falsified,testing_labels
def get_last_window(num_minutes, root):
    data = extract_data_from_csv(root)
    data = data[(len(data) - num_minutes):(len(data))]
    return data