From 669c6cc9e223a78fa75172a33114cde018e40f0f Mon Sep 17 00:00:00 2001 From: jamie michel <jamie.michel@hotmail.com> Date: Sat, 22 May 2021 02:47:47 +0100 Subject: [PATCH] Builds model, placeholder code at bottom for restarting the services --- NodeAPI/index.js | 2 +- build.py | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/NodeAPI/index.js b/NodeAPI/index.js index 722ff27..9e489aa 100644 --- a/NodeAPI/index.js +++ b/NodeAPI/index.js @@ -3,7 +3,7 @@ const bodyParser = require('body-parser'); const request = require('request'); const app = express() -const port = 3000; +const port = 80; app.set('view engine', 'ejs') diff --git a/build.py b/build.py index 9dadca9..1794e1f 100644 --- a/build.py +++ b/build.py @@ -16,14 +16,13 @@ from numpy import array from sklearn.feature_extraction.text import CountVectorizer from sklearn.model_selection import train_test_split - +from datetime import datetime #Functions for splitting into train/test sets. def split_dataset(df, test_size=0.25): movies_train, movies_test = train_test_split(df, test_size=test_size, shuffle=True) return movies_train, movies_test - def get_train_test(df, test_size=0.25): movies_train, movies_test = split_dataset(df, test_size) @@ -453,19 +452,16 @@ classifier = OneVsRestClassifier(lr_classifier) classifier.fit(x_train_lr, y_train_lr) -with open('vectorizer.pickle', 'wb') as handle: - pickle.dump(vectorizer, handle) - -with open('mlb.pickle', 'wb') as handle: - pickle.dump(mlb, handle) +for item in ['mlb', 'vectorizer','model']: + with open(f'{item}.pickle', 'wb') as handle: + pickle.dump(item, handle) -with open('model.pickle', 'wb') as handle: - pickle.dump(classifier, handle) +#Automatically restart the services: MAY NEED TO CHANGE TO PUSH TO GITHUB AND THEN SSHING INTO THE SERVER ETC ETC -print('Restarting services') -os.chdir("~/Dev/coursework") -os.system("forever restart;cd NodeAPI;pm2 restart /NodeAPI/index.js") -print('Restarted services') +# print('Restarting services') +# os.chdir("~/Dev/coursework") +# os.system("forever restart;cd NodeAPI;pm2 restart /NodeAPI/index.js") +# print('Restarted services') -- GitLab