Commit 2b96c6c9 authored by Christian Marius Lillelund's avatar Christian Marius Lillelund
Browse files

moved ml project to new folder

parent d8df40b7
......@@ -7,8 +7,8 @@ setup(
setup_requires=["pytest-runner"],
tests_require=["pytest"],
version='0.0.1',
description='AIR is an open-source ML project to model and find patterns in health care data.',
author='Christian Marius Lillelund, Christian Fischer Pedersen',
description='AIR is an open-source ML project to improve rehabilitation.',
author='Christian Marius Lillelund',
author_email='cl@ece.au.dk',
license='MIT',
)
\ No newline at end of file
import pandas as pd
import numpy as np
from tools import preprocessor, file_reader
import paths as pt
import os
import csv
import joblib
from pathlib import Path
def main():
model = file_reader.read_joblib(pt.FALL_TEST_XGB_DIR,
'fall_test_xgboost.joblib')
for gender in range(0, 2):
input_data = {"Gender": [gender],
"BirthYear": [72],
"Cluster": [10],
"LoanPeriod": [360],
"NumberSplit": [0],
"NumberScreening": [2],
"NumberWeeks": [3],
"MeanEvaluation": [4],
"NumberFalls": [1],
"NumberTraining": [8],
"NumberTrainingWeek": [1],
"TimeBetweenTraining": [3.5],
"NumberWeeksNoTraining": [1],
"Needs": [40],
"Physics": [43],
"Ex": ["8058,8062,8066"],
"Ats": ["222718,093307,181210"]}
new_data_df = pd.DataFrame.from_dict(input_data)
new_data_df['NumberAts'] = len(new_data_df['Ats'][0].split(","))
new_data_df['NumberEx'] = len(new_data_df['Ex'][0].split(","))
df = preprocessor.split_cat_columns(new_data_df, col_to_split='Ats',
tag='Ats',
resolution=10)
df = preprocessor.split_cat_columns(df, col_to_split='Ex',
tag='Ex',
resolution=10)
cols_ats = [str(i)+'Ats' for i in range(1, 10+1)]
cols_ex = [str(i)+'Ex' for i in range(1, 9+1)]
header_list = ['Gender', 'BirthYear', "Cluster",
"LoanPeriod", "NumberSplit", "NumberScreening",
"NumberWeeks", "MeanEvaluation", "NumberFalls",
"NumberTraining", "NumberTrainingWeek", "TimeBetweenTraining",
"NumberWeeksNoTraining", "NumberCancels", "NumberCancelsWeek",
"Needs", "Physics", "NumberAts", "NumberEx"] + cols_ats + cols_ex
df = df.reindex(columns=header_list)
df = df.fillna('0')
for i in range(1, 10+1):
path = Path.joinpath(pt.PROCESSED_DATA_DIR, 'embeddings')
embedding = file_reader.read_embedding(path, f'fall_test_{i}Ats.csv')
column = f'{i}Ats'
df[column] = df[column].replace(to_replace=embedding)
df[column] = pd.to_numeric(df[column])
for i in range(1, 9+1):
path = Path.joinpath(pt.PROCESSED_DATA_DIR, 'embeddings')
embedding = file_reader.read_embedding(path, f'fall_test_{i}Ex.csv')
column = f'{i}Ex'
df[column] = df[column].replace(to_replace=embedding)
df[column] = pd.to_numeric(df[column])
prediction = model.predict(df)
probability = model.predict_proba(df).max()
print(f"Using gender {gender}, predicted " +
f"{int(prediction[0])} with probability {round(float(probability), 3)*100}%")
if __name__ == "__main__":
main()
\ No newline at end of file
Supports Markdown
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