FileNotFoundError: [Errno 2] No such file or directory: 'static/data/cleanHeart.csv
I receive this error when attempting to access my csv file in my models.py
file within a model named Patient and a method named perform_prediction. My intent is to, with the use of some attributes available within Patient, to generate a prediction with the help of the data.
import pandas as pd
def perform_prediction(self):
main_df = pd.read_csv('static/data/cleanHeart.csv')
regu = linReg.fit(main_df[['Age','Sex', 'ChestPainType', 'RestingBP', 'Cholesterol', 'FastingBS', 'RestingECG', 'MaxHR', 'ExerciseAngina', 'Oldpeak', 'ST_Slope']],main_df['HeartDisease'])
tester = regu.predict([[65,0,3,140,306,1,0,87,1,1.5,0]])
return tester
To ensure my relative path is correct, I created an acceptablepath.py in the exact same location with the method code, and was successfully able to access cleanHeart.csv.
I am calling this function from a template. To ensure that was not the issue, I created a simple ping_me method which has no problems returning to the template.
def ping_me(self):
return 'ping!'
Is this issue related to the settings.py in anyway? I even placed the cleanHeart.csv in the same directory with models.py and I still am unable to access it.
There are no pending migrations.