Skip to content

Commit

Permalink
Changed TherapyNow to PeerSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSteenstra committed Aug 17, 2020
1 parent fcc1b69 commit 98cddad
Show file tree
Hide file tree
Showing 40 changed files with 234 additions and 315 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ dmypy.json
*.code-workspace
.vs/PythonSettings.json
.vs/slnx.sqlite
.vs/TherapyNow/v16/.suo
.vs/PeerSupport/v16/.suo
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
![text](https://github.com/IanSteenstra/TherapyNow/blob/master/frontend/src/images/logo-hori.jpg)
![text](https://github.com/IanSteenstra/PeerSupport/blob/master/frontend/src/images/logo-hori.jpg)

# TherapyNow
# PeerSupport

## Summary

TherapyNow is an anonymous peer-support web application that provides easy access for college students to get the help they need in a safe and reliable manner.
PeerSupport is an anonymous peer-support web application that provides easy access for college students to get the help they need in a safe and reliable manner.

## Run Codebase

Expand All @@ -18,7 +18,7 @@ TherapyNow is an anonymous peer-support web application that provides easy acces
## Issue Running Codebase / Servers Not Working

1. In another terminal while the servers are still running, enter `docker ps`
1. Find the Container ID for the therapynow_django server (ex: db54a724e9a4)
1. Find the Container ID for the peersupport_django server (ex: db54a724e9a4)
1. Run `docker exec -it <container ID> bash`
1. `python manage.py migrate`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

df[cat_columns] = df[cat_columns].apply(lambda x: x.cat.codes)

df.to_csv(r'C:\Users\steeni\Documents\Github\TherapyNow\research\training\processed_personality_quiz_responses.csv')
df.to_csv(r'C:\Users\steeni\Documents\Github\PeerSupport\research\training\processed_personality_quiz_responses.csv')
32 changes: 8 additions & 24 deletions archive/research/suicidal_ideation_detection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,12 @@
},
{
"cell_type": "code",
"execution_count": 92,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\steen\\Anaconda3\\lib\\site-packages\\sklearn\\externals\\joblib\\__init__.py:15: DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.\n",
" warnings.warn(msg, category=DeprecationWarning)\n"
]
}
],
"outputs": [],
"source": [
"import pandas as pd\n",
"import joblib\n",
"import numpy as np\n",
"from textblob import TextBlob as tb\n",
"import nltk\n",
Expand All @@ -38,21 +30,13 @@
"from sklearn.metrics import accuracy_score, confusion_matrix, classification_report, r2_score\n",
"from nltk.corpus import wordnet as wn\n",
"from sklearn import preprocessing\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"# import matplotlib.pyplot as plt\n",
"# import seaborn as sns\n",
"from sklearn.model_selection import GridSearchCV\n",
"import pickle\n",
"from sklearn.externals import joblib\n",
"from gensim.models import FastText"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Data Preprocessing"
]
},
{
"cell_type": "code",
"execution_count": 3,
Expand All @@ -63,7 +47,7 @@
"source": [
"data = pd.DataFrame(columns=('text', 'suicidal_ideation'))\n",
"for i in range(10):\n",
" data = pd.concat([data, pd.read_csv('annotated_data'+str(i)+'.csv')], sort=False)"
" data = pd.concat([data, pd.read_csv('suicidal-ideation-datasets/annotated_data'+str(i)+'.csv')], sort=False)"
]
},
{
Expand Down Expand Up @@ -743,9 +727,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.7-final"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}
8 changes: 4 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ FROM python:3.7.7

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-client \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /therapynow/backend
WORKDIR /peersupport/backend
RUN pip install --upgrade pip
COPY requirements.txt /therapynow/backend
COPY requirements.txt /peersupport/backend
RUN pip install -r requirements.txt

COPY . /therapynow/backend/
COPY . /peersupport/backend/

EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
44 changes: 40 additions & 4 deletions backend/NLP-models/suicidal-ideation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
import pandas as pd
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn import preprocessing
import re
import joblib
import os


class SuicidalIdeationModel:
def __init__(self, content):
self.content = content

def __init__(self, text):
dir_path = os.path.dirname(os.path.realpath(__file__))

self.text = text
self.model = joblib.load(dir_path + '\\suicidal_classifier.pkl')

def predict(self):
return len(self.content)
dir_path = os.path.dirname(os.path.realpath(__file__))

data = pd.DataFrame(columns=('text', 'suicidal_ideation'))
for i in range(10):
data = pd.concat(
[data, pd.read_csv(dir_path + '\\datasets\\annotated_data'+str(i)+'.csv')], sort=False)

X = data['text']
X = X.apply(lambda text: re.sub(r"http\S+", "", text).lower())

text = pd.DataFrame({'text': [self.text]})

print(text)
# tfidf = TfidfVectorizer(analyzer='word', ngram_range=(1, 2))
# features = pd.DataFrame(tfidf.fit_transform([self.text]).toarray())
# print(features)
# features = features.values
# min_max_scaler = preprocessing.MinMaxScaler()
# features_scaled = min_max_scaler.fit_transform(features)
# features = pd.DataFrame(features_scaled)
# prediction = self.model.predict(features)
# return prediction


if __name__ == '__main__':
content = 'I want to die'
s = SuicidalIdeationModel(content)
print(s.predict())
File renamed without changes.
4 changes: 2 additions & 2 deletions backend/TherapyNow/asgi.py → backend/PeerSupport/asgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
ASGI config for TherapyNow project.
ASGI config for PeerSupport project.
It exposes the ASGI callable as a module-level variable named ``application``.
Expand All @@ -12,6 +12,6 @@
from django.core.asgi import get_asgi_application
from channels.routing import get_default_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TherapyNow.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PeerSupport.settings')
django.setup()
application = get_default_application()
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Django settings for TherapyNow project.
Django settings for PeerSupport project.
Generated by 'django-admin startproject' using Django 3.0.2.
Expand Down Expand Up @@ -44,7 +44,7 @@
'chat',
'message',
'events',
'Profile',
'profile',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -79,7 +79,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'TherapyNow.urls'
ROOT_URLCONF = 'PeerSupport.urls'
TEMPLATES_ROOT = os.path.join(BASE_DIR, "templates")
TEMPLATES = [
{
Expand All @@ -97,7 +97,7 @@
},
]

ASGI_APPLICATION = 'TherapyNow.routing.application'
ASGI_APPLICATION = 'PeerSupport.routing.application'

CHANNEL_LAYERS = {
'default': {
Expand Down
2 changes: 1 addition & 1 deletion backend/TherapyNow/urls.py → backend/PeerSupport/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rest_framework import routers
from allauth.account.views import ConfirmEmailView
from rest_framework.authtoken.views import obtain_auth_token
from Profile.views import null_view, getUserEmail, complete_view, ProfileViewSet, PreStudyQuizViewSet, PostStudyQuizViewSet, WeekPostStudyQuizViewSet, UserQuizViewSet, CounselorQuizViewSet, ResearchQuizViewSet, get_chats, get_friends, validate_user_group
from profile.views import null_view, getUserEmail, complete_view, ProfileViewSet, PreStudyQuizViewSet, PostStudyQuizViewSet, WeekPostStudyQuizViewSet, UserQuizViewSet, CounselorQuizViewSet, ResearchQuizViewSet, get_chats, get_friends, validate_user_group
from events.views import EventViewSet
from chat.views import ChatViewSet
from message.views import MessageFlagViewSet
Expand Down
4 changes: 2 additions & 2 deletions backend/TherapyNow/wsgi.py → backend/PeerSupport/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
WSGI config for TherapyNow project.
WSGI config for PeerSupport project.
It exposes the WSGI callable as a module-level variable named ``application``.
Expand All @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TherapyNow.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PeerSupport.settings')

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion backend/Profile/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default_app_config = 'Profile.apps.ProfileConfig'
default_app_config = 'profile.apps.ProfileConfig'
6 changes: 3 additions & 3 deletions backend/Profile/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class ProfileConfig(AppConfig):
name = 'Profile'
name = 'profile'

def ready(self):
import Profile.signals
def ready(self):
import profile.signals
Loading

0 comments on commit 98cddad

Please sign in to comment.