Exemplo n.º 1
0
def main():
    # Input parameters
    INPUT_SHAPE = (123, 123, 3)

    # Set working directory where files are located
    workingDirectory = "C:\\Users\\Dillon\\Desktop\\Senior_Project"

    trainingImgsPath = workingDirectory + "\\training_Images"
    idDictPath = workingDirectory + "\\data\\data_points.geojson"

    x_train, y_train = makeBatch(idDictPath, trainingImgsPath)

    testIdDictPath = workingDirectory + "\\data\\test_data_points.geojson"
    testingImgsPath = workingDirectory + "\\testing_Images"

    x_test, y_test = makeBatch(testIdDictPath, testingImgsPath)
    print("Batches made\nInitializing model...")

    # model = initModel(0.5, INPUT_SHAPE)
    # train(model,
    #       x_train,
    #       y_train,
    #       num_samples=20000,
    #       batch_size=128,
    #       learningRate = 5e-5,
    #       epochs=100)

    runModel(workingDirectory, x_test, y_test, x_train, y_train)
Exemplo n.º 2
0
    def model(self):
        try:
            if (int(self.e2.get())) > self.df.shape[0] or (int(
                    self.e2.get())) < 3:
                messagebox.showerror(
                    "K Mean Clustring",
                    "please enter a valid number of clusters")

            else:
                try:
                    if (int(self.e3.get())) > 50 or (int(self.e3.get())) < 1:
                        messagebox.showerror(
                            "K Mean Clustring",
                            "please enter a valid number of runs")
                    else:
                        try:
                            # self.master.button1['state'] = 'normal'

                            model.runModel(self.df, int(self.e2.get()),
                                           int(self.e3.get()))
                            self.img = ImageTk.PhotoImage(
                                PIL.Image.open("countries.png"))

                            self.panel = Label(self.master, image=self.img)
                            self.panel.grid(row=8, column=0)

                            self.img1 = ImageTk.PhotoImage(
                                PIL.Image.open(
                                    "Generosity_social_support.png"))
                            self.panel = Label(self.master, image=self.img1)
                            self.panel.grid(row=8, column=1)

                            messagebox.showinfo(
                                "K Mean Clustring",
                                "clustring completed successfully!")

                        except:
                            messagebox.showerror("K Mean Clustring",
                                                 "error while the model")

                except:

                    messagebox.showerror(
                        "K Mean Clustring",
                        "please enter a valid number of runs")

        except:
            messagebox.showerror("K Mean Clustring",
                                 "please enter a valid number of clusters")
Exemplo n.º 3
0
def analysis():
    print "Running Model...."
    Alz = model.runModel()
    print "Running Model"
    if ('username' not in session):
        session ['username'] = None
    if (session.get('username') == None):
        username = session ['username']
    results = request.args.get("Results")
    if (results == "Results"):
        return redirect("/results")
    return render_template("analysis.html")
Exemplo n.º 4
0
    def train(self, tfrecord_filename, begin=0, einde=1000):
        print("Start training with data")

        print("Image Height: %d, Width: %d, Channels: %d" % (self.height, self.width, self.channels))

        T2 = imagesToTfRecord(tfrecord_filename, TRAIN_DIR, TRAIN_LABELS, self.width, self.height, self.channels)
        if os.path.exists(tfrecord_filename):
            """ Read images and labels (tensors) from TFRecord file """
            parsed_image_dataset = T2.readRecord(tfrecord_filename)
            print(parsed_image_dataset)
            #for parsed_record in parsed_image_dataset.take(5):
                #print("parsed_record: ", repr(parsed_record))
                #labels = parsed_record[1][0]
            parsed_image_dataset.batch(32)
            iterator = parsed_image_dataset.make_one_shot_iterator()
            image_ds, label_ds = iterator.get_next()
            test_images, test_labels = image_ds, label_ds
            # print("iterator: ", iterator)

            runModel(image_ds, label_ds, test_images, test_labels)
        else:
            print("File does not exist: ", tfrecord_filename)
Exemplo n.º 5
0
    with open(modelFilename, 'rb') as inputFile, open(os.path.join(outputDirectory, MODEL_FILENAME), 'wb') as outputFile:
        outputFile.write(inputFile.read())

    with open(os.path.join(outputDirectory, SCORE_FILENAME), 'w')as outputFile:
        outputFile.write("%f\n" % score)


if __name__ == '__main__':
    experimentIndex = 0
    for configuration in ConfigurationStore.getTestConfigurationFiles():
        experimentIndex += 1

        with open(CONFIG_FILENAME,'w') as configFile:
            configFile.write(configuration)

        import model as ModelTrainer

        score = ModelTrainer.runModel(MODEL_FILENAME)

        saveExperimentResults(experimentIndex, CONFIG_FILENAME, MODEL_FILENAME, score)

        if os.path.isfile(CONFIG_FILENAME):
            os.remove(CONFIG_FILENAME)

        if os.path.isfile(MODEL_FILENAME):
            os.remove(MODEL_FILENAME)

        del ModelTrainer

Exemplo n.º 6
0
        selectedFeatures = df[[
            "CashIn", "CashOut", "Weekday", "DayOfMonth", "yearlyDeviation",
            "yearlyDeviationChange", "workingDayOrNot", "Season",
            "isReligiousHoliday", "isNationalHoliday", "isSpecialDay"
        ]]

        # "previousWeekCashInAvg",
        # "previousWeekCashInStdDev"

        categoricalFeatureNameList = list(
            selectedFeatures.select_dtypes(exclude=["number", "datetime"]))
        categoricalFeatureIndexList = [
            selectedFeatures.columns.get_loc(c)
            for c in categoricalFeatureNameList
        ]

        scaledArray = model.preprocessModelDf(selectedFeatures,
                                              categoricalFeatureIndexList)
        model_, history, test_X, test_y, prediction_values = model.runModel(
            scaledArray, n_features, n_days_to_feed_model, n_days_to_predict,
            cash_in)

        model.plotLossHistory(history)
        rmse = model.makePrediction(test_X, test_y, prediction_values, model_)
        print("rmse : {}".format(rmse))

    except Exception as e:
        errorLog = str(traceback.format_exc())
        print(errorLog)