Commit 44e162df authored by Christian Marius Lillelund's avatar Christian Marius Lillelund
Browse files

Merge branch 'master' of https://gitlab.au.dk/cfp/air

parents 604e98ad fe6c1c90
Pipeline #100680 passed with stage
in 4 minutes and 9 seconds
......@@ -53,9 +53,12 @@ In the root project directory there is a client which can create datasets. It's
As an example, to run the client and encode the categorial features as one-hot-encoded columns:
$ python .\client.py --dataset-version 'ohe'
You can generate source code documentation by running Sphinx:
$ sphinx-build docs docs/_build -b html
Contact
==============================
......
# Air
AIR is an open-source machine learning project to improve rehabilitation for danish citizens.
## Installation
To run the application it is recommended to firstly install visual studio code.\
Get it from: https://code.visualstudio.com/
When it is install open Visual Studio Code and select 'File' followed by 'Open Folder'.
Select the web folder in the air project.
Now open a terminal by selecting 'Terminal' followed by 'New Terminal' in the top toolbar in Visual Studio Code.
A window in the bottom should now appear, and it is recommended to split the terminal into two.
Click with your mouse on the created terminal and enter CTRL+SHIFT+5.
Enter the following in one of the two terminals:
```bash
cd vue-app
```
And the following in the other terminal:
```bash
cd api
```
In both terminals, enter 'npm install' to install all necessary dependencies.
When that is done, enter the following in the presented order:\
├──'node server.js' - In the terminal associated with the api.\
├──'npm run serve' - In the terminal associated with the vue-app.
When the latter has finished a window should now open in a browser with the application running.
Enjoy!
\ No newline at end of file
......@@ -10,7 +10,7 @@ const app = express();
app.use(express.static(path));
const prisma = new PrismaClient()
const prisma = new PrismaClient();
app.use(cors(corsOptions));
app.use(express.json());
......@@ -25,8 +25,8 @@ app.use(express.urlencoded({ extended: true }));
};*/
const log = bunyan.createLogger({ name: "AIR_UI_Backend: " });
const predictionURL_training = 'https://air-fastapi.azurewebsites.net/predict_training'
const predictionURL_alarm = 'https://air-fastapi.azurewebsites.net/predict_alarm'
const predictionURL_training = 'https://air-fastapi.azurewebsites.net/predict_training';
const predictionURL_alarm = 'https://air-fastapi.azurewebsites.net/predict_alarm';
async function deleteVariable(variablesMarkedForDeletion) {
variablesMarkedForDeletion.forEach(element => {
......@@ -36,15 +36,15 @@ async function deleteVariable(variablesMarkedForDeletion) {
}
function convertDataSizeToKb(logMessage, data) {
const datasizeInKb = (new TextEncoder().encode(JSON.stringify(data)).length) / 1024
console.log(logMessage, datasizeInKb)
const datasizeInKb = (new TextEncoder().encode(JSON.stringify(data)).length) / 1024;
console.log(logMessage, datasizeInKb);
}
function dataPreparationForML(age, gender, assistiveAids, loanPeriod) {
const Gender = gender == 'Mand' ? 1 : 0
const BirthYear = (new Date().getFullYear() - age)
const LoanPeriod = loanPeriod
const Ats = assistiveAids
const Gender = gender == 'Mand' ? 1 : 0;
const BirthYear = (new Date().getFullYear() - age);
const LoanPeriod = loanPeriod;
const Ats = assistiveAids;
return {
"Gender": Gender,
......@@ -58,18 +58,18 @@ async function getCompleteTrainingPrediction(inputForCompleteTrainingPrediction)
predictionResult = axios.post(predictionURL_training, inputForCompleteTrainingPrediction).then(result => {
return result.data;
}).catch(error => {
log.error("getCompleteTrainingPrediction() threw an exception: ", error)
log.error("getCompleteTrainingPrediction() threw an exception: ", error);
})
return predictionResult
return predictionResult;
}
async function getAlarmPrediction(inputForAlarmPrediction) {
predictionResult = axios.post(predictionURL_alarm, inputForAlarmPrediction).then(result => {
return result.data;
}).catch(error => {
log.error("getAlarmPrediction() threw an exception: ", error)
log.error("getAlarmPrediction() threw an exception: ", error);
})
return predictionResult
return predictionResult;
}
async function getCitizenInformation(citizenSSN) {
......@@ -121,13 +121,13 @@ app.get('/', function (req, res) {
app.post("/home/:ssn", async (req, res) => {
var citizenData = await getCitizenInformation(req.body.citizenSSN);
if (!citizenData || citizenData.Assistive_Aids.length == 0) {
await deleteVariable([citizenData])
res.send(false)
await deleteVariable([citizenData]);
res.send(false);
} else {
//Format and sort assistive aids data from Database
var assistiveAidsWithCorrectDateFormat = changeLendDateFormat(citizenData.Assistive_Aids)
var sortedAssistiveAids = sortAssistiveAidsByDate(assistiveAidsWithCorrectDateFormat)
//Format and Sort Assistive Aids Data from Database
var assistiveAidsWithCorrectDateFormat = changeLendDateFormat(citizenData.Assistive_Aids);
var sortedAssistiveAids = sortAssistiveAidsByDate(assistiveAidsWithCorrectDateFormat);
//Case Complete Training
var assistiveAidsTraining = appendAssistiveAidsISO(sortedAssistiveAids);
......@@ -144,10 +144,10 @@ app.post("/home/:ssn", async (req, res) => {
//Result from ML model for both cases
var citizenCompleteTrainingPrediction = await getCompleteTrainingPrediction(inputForCompleteTrainingPrediction);
var citizenAlarmPrediction = await getAlarmPrediction(inputForAlarmPrediction);
convertDataSizeToKb("Combined datasize from both the ML Model and Database in Kb: ", { citizenData, citizenCompleteTrainingPrediction, citizenAlarmPrediction })
convertDataSizeToKb("Combined datasize from both the ML Model and Database in Kb: ", { citizenData, citizenCompleteTrainingPrediction, citizenAlarmPrediction });
res.json({ citizenData, citizenCompleteTrainingPrediction, citizenAlarmPrediction })
res.json({ citizenData, citizenCompleteTrainingPrediction, citizenAlarmPrediction });
await deleteVariable([
citizenData,
......@@ -159,23 +159,23 @@ app.post("/home/:ssn", async (req, res) => {
inputForAlarmPrediction,
citizenCompleteTrainingPrediction,
citizenAlarmPrediction
])
]);
}
});
function changeLendDateFormat(assistiveAids) {
assistiveAids.forEach(function(assistiveAid) {
assistiveAid.lend_date = rearrangeDateFormat(assistiveAid.lend_date)
assistiveAid.lend_date = rearrangeDateFormat(assistiveAid.lend_date);
});
return assistiveAids;
}
function rearrangeDateFormat(date) {
var dateInArray = date.split('/');
var day = dateInArray[0]
var month = dateInArray[1]
var year = dateInArray[2]
var rearrangedDateFormat = month + '/' + day + '/' + '20' + year
var day = dateInArray[0];
var month = dateInArray[1];
var year = dateInArray[2];
var rearrangedDateFormat = month + '/' + day + '/' + '20' + year;
return rearrangedDateFormat;
}
......@@ -183,8 +183,8 @@ function sortAssistiveAidsByDate(assistiveAids){
if(assistiveAids.length == 1) {
return sortedAssistiveAids;
} else {
var sortedAssistiveAids = assistiveAids.sort((a, b) => new Date(b.lend_date) - new Date(a.lend_date))
sortedAssistiveAids.reverse()
var sortedAssistiveAids = assistiveAids.sort((a, b) => new Date(b.lend_date) - new Date(a.lend_date));
sortedAssistiveAids.reverse();
return sortedAssistiveAids;
}
}
......@@ -215,17 +215,17 @@ function appendAssistiveAidsISO(assistiveAids) {
function calculateMeanLoanPeriod(assistiveAids){
var assistiveAidsLoanPeriod = 0;
assistiveAids.forEach(function(assistiveAid) {
assistiveAidsLoanPeriod += dateDifferenceInDays(assistiveAid.lend_date)
assistiveAidsLoanPeriod += dateDifferenceInDays(assistiveAid.lend_date);
});
var assistiveAidsMeanLoanPeriod = (assistiveAidsLoanPeriod / assistiveAids.length)
var assistiveAidsMeanLoanPeriod = (assistiveAidsLoanPeriod / assistiveAids.length);
return Math.round(assistiveAidsMeanLoanPeriod);
}
function dateDifferenceInDays(assistiveAidLendDate) {
var nowDate = new Date();
var lendDate = new Date(assistiveAidLendDate);
var differenceInTime = nowDate.getTime() - lendDate.getTime()
var oneDayInMilliseconds = 1000*3600*24
var differenceInTime = nowDate.getTime() - lendDate.getTime();
var oneDayInMilliseconds = 1000*3600*24;
return Math.round(((differenceInTime))/(oneDayInMilliseconds) - 1);
}
......
......@@ -4,7 +4,7 @@
<v-row>
<v-col cols="12" xl="6" lg="6" md="12" sm="12">
<v-card class="pa-2" outlined rounded="15px" elevation="5">
<div class="header-text">Sandsynlighed for ikke at en nødalarm</div>
<div class="header-text">Sandsynlighed for ikke at modtage en nødalarm</div>
<apexchart height="400" type="area" :options="$_chart_options" :series="$_chart_series" />
<explainer :alarm="true" />
</v-card>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment