This uses a previous python3 script inside R with reticulate to communicate python code within R. This will classify a wellness or health category based on it being one of either articles pulled from the internet on: physical therapy benefits, massage therapy benefits, chiropractic benefits, massage gun benefits, benefits of mental health services, cold stone therapy benefits, or cupping benefits.
The python packages were sklearn, matplotlib, pandas, numpy, nltk, textBlob, and regex. Some versions that work are later modules, for instance the re package was used that made regex obsolete because it is a build version that replaced regex for my version of python, 3.6.
# knitr::knit_engines$set(python = reticulate::eng_python)
library(reticulate)
## Warning: package 'reticulate' was built under R version 3.6.3
conda_list(conda = "auto")
## name python
## 1 Anaconda2 C:\\Users\\m\\Anaconda2\\python.exe
## 2 djangoenv C:\\Users\\m\\Anaconda2\\envs\\djangoenv\\python.exe
## 3 python36 C:\\Users\\m\\Anaconda2\\envs\\python36\\python.exe
## 4 python37 C:\\Users\\m\\Anaconda2\\envs\\python37\\python.exe
## 5 r-reticulate C:\\Users\\m\\Anaconda2\\envs\\r-reticulate\\python.exe
Without having my python IDE, Anaconda, open in the console I want to use the python36 environment, all the environments in Anaconda for python are listed above.
use_condaenv(condaenv = "python36")
import pandas as pd
import matplotlib.pyplot as plt
from textblob import TextBlob
import sklearn
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import classification_report, f1_score, accuracy_score, confusion_matrix
np.random.seed(47)
The following data table will not show in your Rstudio environment, but python inside your python IDE will store the table.
modalities = pd.read_csv('benefitsContraindications.csv', encoding = 'unicode_escape')
print(modalities.head())
## Document ... InternetSearch
## 0 Chiropractic adjustments and treatments serve ... ... NaN
## 1 \nUnitedHealthcare Combats Opioid Crisis with ... ... NaN
## 2 The Safety of Chiropractic Adjustments\nBy La... ... NaN
## 3 Advanced Chiropractic Relief: 8 Key Benefits o... ... NaN
## 4 Heading to the spa can be a pampering treat, b... ... google
##
## [5 rows x 4 columns]
print(modalities.tail())
## Document ... InternetSearch
## 60 What is Hot & Cold Stone Therapy?\n\nHot & Col... ... google
## 61 \nBenefits of Hot Stone & Cold Stone Therapy\n... ... google
## 62 Benefits Of Hot & Cold Stone Massage\n\nBenefi... ... google
## 63 \nCool Down! Do you need a cold stone massage?... ... google
## 64 \nCool Off Your Summer with Cold Stone Massage... ... google
##
## [5 rows x 4 columns]
print(modalities.shape)
## (65, 4)
import regex
def preprocessor(text):
text = regex.sub('<[^>]*>', '', text)
emoticons = regex.findall('(?::|;|=)(?:-)?(?:\)|\(|D|P)', text)
text = regex.sub('[\W]+', ' ', text.lower()) +\
' '.join(emoticons).replace('-', '')
return text
modalities.tail()
## Document ... InternetSearch
## 60 What is Hot & Cold Stone Therapy?\n\nHot & Col... ... google
## 61 \nBenefits of Hot Stone & Cold Stone Therapy\n... ... google
## 62 Benefits Of Hot & Cold Stone Massage\n\nBenefi... ... google
## 63 \nCool Down! Do you need a cold stone massage?... ... google
## 64 \nCool Off Your Summer with Cold Stone Massage... ... google
##
## [5 rows x 4 columns]
Reorder the observations so that they are mixed and not grouped together as they are in the original file.
import numpy as np
modalities = modalities.reindex(np.random.permutation(modalities.index))
print(modalities.head())
## Document ... InternetSearch
## 44 What Is Cupping Therapy?\n\n Cupping types\... ... google
## 33 \nChiropractic Care for Back Pain\nIn this Art... ... google
## 5 Massage: Get in touch with its many benefits\n... ... google
## 46 ll You Need To Know About Massage Gun\n31 Augu... ... google
## 32 \nChiropractic Care for Back Pain\nIn this Art... ... google
##
## [5 rows x 4 columns]
print(modalities.tail())
## Document ... InternetSearch
## 61 \nBenefits of Hot Stone & Cold Stone Therapy\n... ... google
## 8 BENEFITS OF MASSAGE\n\nYou know that post-mass... ... google
## 64 \nCool Off Your Summer with Cold Stone Massage... ... google
## 6 25 Reasons to Get a Massage\n\nNovember 5, 201... ... google
## 7 7 Benefits of Massage Therapy\n\nMassage thera... ... google
##
## [5 rows x 4 columns]
modalities.columns
## Index(['Document', 'Source', 'Topic', 'InternetSearch'], dtype='object')
modalities.groupby('Topic').describe()
## Document ... InternetSearch
## count unique ... top freq
## Topic ...
## chiropractic benefits 8 8 ... google 4
## cold stone benefits 10 10 ... google 10
## cupping benefits 10 10 ... google 10
## massage benefits 12 12 ... google 12
## massage gun benefits 10 10 ... google 10
## mental health services benefits 6 6 ... google 6
## physical therapy benefits 9 9 ... google 9
##
## [7 rows x 12 columns]
modalities['length'] = modalities['Document'].map(lambda text: len(text))
print(modalities.head())
## Document ... length
## 44 What Is Cupping Therapy?\n\n Cupping types\... ... 7603
## 33 \nChiropractic Care for Back Pain\nIn this Art... ... 1464
## 5 Massage: Get in touch with its many benefits\n... ... 5418
## 46 ll You Need To Know About Massage Gun\n31 Augu... ... 5415
## 32 \nChiropractic Care for Back Pain\nIn this Art... ... 2734
##
## [5 rows x 5 columns]
#%matplotlib inline
modalities.length.plot(bins=20, kind='hist')
plt.show()
modalities.length.describe()
## count 65.000000
## mean 4821.461538
## std 2951.435520
## min 380.000000
## 25% 2476.000000
## 50% 4152.000000
## 75% 6789.000000
## max 12736.000000
## Name: length, dtype: float64
print(list(modalities.Document[modalities.length > 4200].index))
## [44, 5, 46, 54, 29, 38, 30, 3, 35, 40, 59, 25, 27, 42, 17, 2, 34, 28, 9, 53, 41, 1, 26, 50, 49, 45, 55, 58, 23, 16, 51, 7]
print(list(modalities.Topic[modalities.length > 420]))
## ['cupping benefits', 'chiropractic benefits', 'massage benefits', 'massage gun benefits', 'chiropractic benefits', 'cold stone benefits', 'massage gun benefits', 'mental health services benefits', 'cupping benefits', 'cupping benefits', 'cupping benefits', 'massage gun benefits', 'cupping benefits', 'massage benefits', 'physical therapy benefits', 'physical therapy benefits', 'mental health services benefits', 'massage benefits', 'physical therapy benefits', 'chiropractic benefits', 'cupping benefits', 'massage benefits', 'cupping benefits', 'cold stone benefits', 'mental health services benefits', 'massage benefits', 'massage benefits', 'physical therapy benefits', 'physical therapy benefits', 'mental health services benefits', 'massage gun benefits', 'massage benefits', 'physical therapy benefits', 'cold stone benefits', 'cupping benefits', 'massage benefits', 'physical therapy benefits', 'chiropractic benefits', 'chiropractic benefits', 'chiropractic benefits', 'chiropractic benefits', 'mental health services benefits', 'massage benefits', 'massage gun benefits', 'massage gun benefits', 'cupping benefits', 'cold stone benefits', 'cold stone benefits', 'chiropractic benefits', 'cupping benefits', 'mental health services benefits', 'massage gun benefits', 'massage gun benefits', 'massage gun benefits', 'cold stone benefits', 'cold stone benefits', 'cold stone benefits', 'physical therapy benefits', 'physical therapy benefits', 'massage gun benefits', 'cold stone benefits', 'cold stone benefits', 'massage benefits', 'massage benefits']
modalities.hist(column='length', by='Topic', bins=5)
plt.show()
def split_into_tokens(review):
#review = unicode(review, 'iso-8859-1')# in python 3 the default of str() previously python2 as unicode() is utf-8
return TextBlob(review).words
modalities.Document.head().apply(split_into_tokens)
## 44 [What, Is, Cupping, Therapy, Cupping, types, T...
## 33 [Chiropractic, Care, for, Back, Pain, In, this...
## 5 [Massage, Get, in, touch, with, its, many, ben...
## 46 [ll, You, Need, To, Know, About, Massage, Gun,...
## 32 [Chiropractic, Care, for, Back, Pain, In, this...
## Name: Document, dtype: object
TextBlob("hello world, how is it going?").tags # list of (word, POS) pairs
## [('hello', 'JJ'), ('world', 'NN'), ('how', 'WRB'), ('is', 'VBZ'), ('it', 'PRP'), ('going', 'VBG')]
import nltk
nltk.download('stopwords')
## True
##
## [nltk_data] Downloading package stopwords to
## [nltk_data] C:\Users\m\AppData\Roaming\nltk_data...
## [nltk_data] Package stopwords is already up-to-date!
from nltk.corpus import stopwords
stop = stopwords.words('english')
stop = stop + [u'a',u'b',u'c',u'd',u'e',u'f',u'g',u'h',u'i',u'j',u'k',u'l',u'm',u'n',u'o',u'p',u'q',u'r',u's',u't',u'v',u'w',u'x',u'y',u'z']
def split_into_lemmas(review):
#review = unicode(review, 'iso-8859-1')
review = review.lower()
#review = unicode(review, 'utf8').lower()
#review = str(review).lower()
words = TextBlob(review).words
# for each word, take its "base form" = lemma
return [word.lemma for word in words if word not in stop]
modalities.Document.head().apply(split_into_lemmas)
## 44 [cupping, therapy, cupping, type, treatment, c...
## 33 [chiropractic, care, back, pain, article, chir...
## 5 [massage, get, touch, many, benefit, massage, ...
## 46 [need, know, massage, gun, 31, august, 2019, 3...
## 32 [chiropractic, care, back, pain, article, chir...
## Name: Document, dtype: object
bow_transformer = CountVectorizer(analyzer=split_into_lemmas).fit(modalities['Document'])
print(len(bow_transformer.vocabulary_))
## 4769
modality4 = modalities['Document'][42]
print(modality4)
## What to know about cupping therapy
##
## Does it work?
## Pain relief
## Skin conditions
## Sports recovery
## Side effects and risks
## Takeaway
##
## There is some evidence to suggest that cupping therapy may be beneficial for certain health conditions. However, research into cupping therapy tends to be low-quality. More studies are necessary to understand how cupping therapy works, if it works, and in what situations it may help.
##
## Cupping therapy is a traditional Chinese and Middle Eastern practice that people use to treat a variety of conditions.
##
## It involves placing cups at certain points on a person?s skin. A practitioner creates suction in the cups, which pulls against a person?s skin.
##
## Cupping can either be dry or wet. Wet cupping involves puncturing the skin before starting the suction, which removes some of the person?s blood during the procedure.
##
## Cupping typically leaves round bruises on a person?s skin, where their blood vessels burst after exposure to the procedure?s suction effects.
## Does it work?
## Cupping therapy may help increase or decrease blood flow.
##
## According to a study paper in the journal PLoS One, cupping practitioners claim that it works by creating hyperemia or hemostasis around a person?s skin. This means that it either increases or decreases a person?s blood flow under the cups.
##
## Cupping also has links to acupoints on a person?s body, which are central to the practice of acupuncture.
##
## Many doctors consider cupping therapy a complementary therapy, which means that many do not recognize it as part of Western medicine. This does not mean that it is not effective, however.
##
## Complementary therapies with supporting research may be an addition to Western medicine. However, as the National Center for Complementary and Integrative Health (NCCIH) note, there is not yet enough high-quality research to prove cupping?s effectiveness.
##
## Scientists have linked cupping therapy with a variety of health benefits, although there needs to be more research to determine whether it is effective as a treatment.
## Pain relief
##
## People frequently cite cupping therapy as a form of pain relief. However, while there is some evidence for its effectiveness, scientists need to conduct more high-quality studies to demonstrate this fully.
##
## For example, a study paper in the journal Evidence-based Complementary and Alternative Medicine found some evidence to suggest that cupping may reduce pain. However, its authors note that there were limits to the quality of the studies that showed this.
##
## A meta-analysis that appears in the journal Revista Latina-Americano De Enfermagem claims that there may be evidence for cupping being effective in treating back pain. However, again, the researchers note that most studies were low-quality, and that there is a need for more standardization in future studies.
##
## One study paper in the journal BMJ Open came to a similar conclusion for the effectiveness of cupping for neck pain. The researchers note that there is a need for better-quality studies to determine whether cupping therapy is truly effective.
## Medical News Today Newsletter
## Stay in the know. Get our free daily newsletter
##
## Expect in-depth, science-backed toplines of our best stories every day. Tap in and keep your curiosity satisfied.
##
## Your privacy is important to us
## Skin conditions
##
## A study paper in the journal PLoS One found that there was some evidence for cupping therapy being effective at treating herpes zoster and acne.
##
## However, it notes that the studies that supported these findings were at a high risk of bias. So, more rigorous, high-quality studies are necessary to verify the findings.
## Sports recovery
##
## A study paper in the Journal of Alternative and Complementary Medicine notes that professional athletes are increasingly using cupping therapy as part of their recovery practices.
##
## However, the study found no consistent evidence to show that it was effective for anything related to sports recovery.
## Side effects and risks
## Cupping can cause irritation or damage to the skin.
##
## According to the NCCIH, the side effects of cupping can include:
##
## lasting skin discoloration
## scarring
## burns
## infection
##
## If a person has a skin condition such as eczema or psoriasis, cupping may make it worse on the area where the practitioner applies the cups.
##
## In rare instances, a person may experience more significant internal bleeding or anemia if the practitioner takes too much blood during wet cupping.
##
## According to a study paper that appears in the Journal of Acupuncture and Meridian Studies, cupping can also cause:
##
## headaches
## tiredness
## dizziness
## fainting
## nausea
## insomnia
##
## Due to the poor quality of studies investigating cupping, it is difficult to know how common these side effects are.
##
## If a person has any of these side effects following cupping therapy, they should speak to a medical professional. Some people may have health conditions, such as problems with blood clotting, that making cupping less than ideal.
## Takeaway
##
## There is some evidence to suggest that cupping therapy may be able to help a person with certain health issues. However, there are not enough high-quality studies to support this.
##
## To understand whether cupping therapy is effective, how it works, and what issues it is best for, scientists need to conduct and publish more high-quality research.
##
## If a person finds that cupping therapy relieves their pain or helps their health in another way, and if they do not experience any adverse side effects, cupping may be a very good choice. However, some therapies have better evidence for their effectiveness. Doctors may advise that people consider these first.
##
## A person may choose to use cupping therapy alongside better-evidenced therapies. If this is the case, it is important that they let a medical professional know.
bow4 = bow_transformer.transform([modality4])
print(bow4)
## (0, 182) 1
## (0, 207) 3
## (0, 228) 1
## (0, 242) 1
## (0, 244) 2
## (0, 254) 1
## (0, 281) 1
## (0, 286) 1
## (0, 342) 1
## (0, 345) 2
## (0, 351) 2
## (0, 353) 1
## (0, 375) 1
## (0, 395) 1
## (0, 411) 1
## (0, 419) 2
## (0, 426) 1
## (0, 441) 1
## (0, 448) 1
## (0, 486) 1
## (0, 504) 1
## (0, 528) 1
## (0, 579) 1
## (0, 580) 1
## (0, 588) 2
## : :
## (0, 4310) 21
## (0, 4358) 1
## (0, 4363) 1
## (0, 4378) 1
## (0, 4399) 1
## (0, 4418) 1
## (0, 4421) 2
## (0, 4422) 1
## (0, 4444) 1
## (0, 4469) 1
## (0, 4470) 1
## (0, 4495) 2
## (0, 4545) 2
## (0, 4549) 1
## (0, 4569) 2
## (0, 4579) 1
## (0, 4589) 1
## (0, 4648) 1
## (0, 4678) 2
## (0, 4679) 3
## (0, 4684) 3
## (0, 4711) 6
## (0, 4720) 1
## (0, 4749) 1
## (0, 4764) 1
modalities_bow = bow_transformer.transform(modalities['Document'])
print('sparse matrix shape:', modalities_bow.shape)
## sparse matrix shape: (65, 4769)
print('number of non-zeros:', modalities_bow.nnz)
## number of non-zeros: 16570
print('sparsity: %.2f%%' % (100.0 * modalities_bow.nnz / (modalities_bow.shape[0] * modalities_bow.shape[1])))
## sparsity: 5.35%
modalities_bow
## <65x4769 sparse matrix of type '<class 'numpy.int64'>'
## with 16570 stored elements in Compressed Sparse Row format>
Indexing is different in python compared to R. Python includes zero and when indicating a slice, the last value is ignored, so only up to the value. So it is used to slice, so that the next can start and include that number up to the empty slice which indicates the last value.
# Split/splice into training ~ 80% and testing ~ 20%
modalities_bow_train = modalities_bow[:53]
modalities_bow_test = modalities_bow[53:]
modalities_sentiment_train = modalities['Topic'][:53]
modalities_sentiment_test = modalities['Topic'][53:]
print(modalities_bow_train.shape)
## (53, 4769)
print(modalities_bow_test.shape)
## (12, 4769)
modalities_sentiment = MultinomialNB().fit(modalities_bow_train, modalities_sentiment_train)
print('predicted:', modalities_sentiment.predict(bow4)[0])
## predicted: cupping benefits
print('expected:', modalities.Topic[42])
## expected: cupping benefits
predictions = modalities_sentiment.predict(modalities_bow_test)
print(predictions)
## ['massage gun benefits' 'massage benefits' 'cold stone benefits'
## 'cold stone benefits' 'physical therapy benefits'
## 'physical therapy benefits' 'massage gun benefits' 'cold stone benefits'
## 'massage benefits' 'cold stone benefits' 'massage benefits'
## 'massage benefits']
print('accuracy', accuracy_score(modalities_sentiment_test, predictions))
## accuracy 0.9166666666666666
print('confusion matrix\n', confusion_matrix(modalities_sentiment_test, predictions))
## confusion matrix
## [[4 1 0 0]
## [0 3 0 0]
## [0 0 2 0]
## [0 0 0 2]]
print('(row=expected, col=predicted)')
## (row=expected, col=predicted)
This model generated a 92% accuracy using multinomial naive bayes.
print(classification_report(modalities_sentiment_test, predictions))
## precision recall f1-score support
##
## cold stone benefits 1.00 0.80 0.89 5
## massage benefits 0.75 1.00 0.86 3
## massage gun benefits 1.00 1.00 1.00 2
## physical therapy benefits 1.00 1.00 1.00 2
##
## accuracy 0.92 12
## macro avg 0.94 0.95 0.94 12
## weighted avg 0.94 0.92 0.92 12
From the above, precision accounts for type 1 errors (how many real negatives classified as positives-False Positives: TP/(TP+FP)) and type 2 errors (how many real posiives classified as negatives-False Negatives: TP/(TP+FN)) are part of recall.
modalitiesu = modalities.Topic.unique()
mus = np.sort(modalitiesu)
mus
## array(['chiropractic benefits', 'cold stone benefits', 'cupping benefits',
## 'massage benefits', 'massage gun benefits',
## 'mental health services benefits', 'physical therapy benefits'],
## dtype=object)
def predict_modality(new_review):
new_sample = bow_transformer.transform([new_review])
pr = np.around(modalities_sentiment.predict_proba(new_sample),2)
print(new_review,'\n\n', pr)
print('\n\nThe respective order:\n 1-chiropractic therapy\n 2-cold stone therapy\n 3-cupping therapy\n 4-massage therapy\n 5-massage gun therapy\n 6-mental health therapy\n 7-physical therapy\n\n')
if (pr[0][0] == max(pr[0])):
print('The max probability is chiropractic therapy for this recommendation with ', pr[0][0]*100,'%')
elif (pr[0][1] == max(pr[0])):
print('The max probability is cold stone massage for this recommendation with ', pr[0][1]*100,'%')
elif (pr[0][2] == max(pr[0])):
print('The max probability is cupping therapy for this recommendation with ', pr[0][2]*100,'%')
elif (pr[0][3] == max(pr[0])):
print('The max probability is massage therapy for this recommendation with ', pr[0][3]*100,'%')
elif (pr[0][4] == max(pr[0])):
print('The max probability is massage gun therapy for this recommendation with ', pr[0][4]*100,'%')
elif (pr[0][5] == max(pr[0])):
print('The max probability is mental health therapy for this recommendation with ', pr[0][5]*100,'%')
else:
print('The max probability is physical therapy for this recommendation with ', pr[0][6]*100,'%')
print('-----------------------------------------\n\n')
predict_modality('Headaches, body sweats, depressed.')
## Headaches, body sweats, depressed.
##
## [[0.36 0.07 0.03 0.5 0.02 0.01 0.01]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is massage therapy for this recommendation with 50.0 %
## -----------------------------------------
predict_modality('sleepless, energy depraved, cold, tension')
## sleepless, energy depraved, cold, tension
##
## [[0.02 0.79 0.17 0.02 0.01 0. 0. ]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is cold stone massage for this recommendation with 79.0 %
## -----------------------------------------
predict_modality('body aches from working out')
## body aches from working out
##
## [[0.05 0.06 0.12 0.24 0.36 0.07 0.09]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is massage gun therapy for this recommendation with 36.0 %
## -----------------------------------------
predict_modality('can\'t move my arm. stuck at home. worried about my neck.')
## can't move my arm. stuck at home. worried about my neck.
##
## [[0.35 0. 0.06 0.28 0.12 0. 0.18]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is chiropractic therapy for this recommendation with 35.0 %
## -----------------------------------------
predict_modality('breathing ragged, tired, headaches, dizzy, nausious ')
## breathing ragged, tired, headaches, dizzy, nausious
##
## [[0.36 0.07 0.11 0.42 0.01 0.01 0.02]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is massage therapy for this recommendation with 42.0 %
## -----------------------------------------
predict_modality("relief from this pain. can't sleep. feet hurt. chills.")
## relief from this pain. can't sleep. feet hurt. chills.
##
## [[0.35 0. 0.05 0.46 0.03 0. 0.11]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is massage therapy for this recommendation with 46.0 %
## -----------------------------------------
The above shows that this sentiment put into the function predicted the sentiment to be a 1 rating by 57%, and next best was a 4 rating with 15%
predict_modality('love this place better than others')
## love this place better than others
##
## [[0.09 0.02 0.33 0.02 0.05 0.44 0.05]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is mental health therapy for this recommendation with 44.0 %
## -----------------------------------------
predict_modality('massage guns and cupping are great for my post workout aches')
## massage guns and cupping are great for my post workout aches
##
## [[0. 0. 0. 0. 1. 0. 0.]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is massage gun therapy for this recommendation with 100.0 %
## -----------------------------------------
predict_modality('It looks like bruises on my back. Paranoid somebody will tease me about them. I feel better, but still some aches and pains.')
## It looks like bruises on my back. Paranoid somebody will tease me about them. I feel better, but still some aches and pains.
##
## [[0.04 0. 0.92 0. 0.04 0. 0. ]]
##
##
## The respective order:
## 1-chiropractic therapy
## 2-cold stone therapy
## 3-cupping therapy
## 4-massage therapy
## 5-massage gun therapy
## 6-mental health therapy
## 7-physical therapy
##
##
## The max probability is cupping therapy for this recommendation with 92.0 %
## -----------------------------------------
This was a quick python 3 recommender based on google searched results for those ten topics. The underlying data only used 65 articles online. When entering a phrase for possible reasons customers could have to want a massage or describe a massage or their health and wellness afterwards, the results mostly recommended massage therapy. The one phrase,“I love this place better than others.” recommended mental health therapy and another complaining about not moving his or her arm and having pain in the neck recommended chiropractic therapy. This is based entirely on the tokenized and lemmatized words of the selected articles. Some articles included image descriptions and sponsored ads. It would be helpful to see the word clouds of these articles by topic to visualize the results.
library(tidytext)
library(tm)
library(dplyr)
library(ggplot2)
library(tidyr)
library(wordcloud)
Lets read in the csv file if you don’t have it stored as Reviews15_results.
modalities <- read.csv('benefitsContraindications.csv',
sep=',', header=TRUE, na.strings=c('',' ','NA'))
colnames(modalities)
## [1] "Document" "Source" "Topic" "InternetSearch"
Lets just use the userReviewOnlyContent and the userRatingValue columns.
modalities1 <- modalities[,c(1,3)]
head(modalities1)
## Document
## 1 Chiropractic adjustments and treatments serve the needs of millions of people around the world.\n\n \n\nAdjustments offer effective, non-invasive and cost-effective solutions to neck and back pain, as well as a myriad of other medical issues.\n\nHave you ever stopped to wonder how many of us suffer from neck and back stiffness or pain?\n\nApart from the obvious discomfort, simple daily tasks such as driving a car, crossing a busy street and picking things up from the floor can become all too challenging for individuals experiencing such pain.\n\nAs anyone who has experienced pain would know, having restricted movement can be debilitating and unfortunately, our busy world doesn?t allow for us to stop.\n\n \nSome of the benefits of long-term chiropractic care include:\n\n Chiropractors can identify mechanical issues that cause spine-related pain and offer a series of adjustments that provide near immediate relief. Following appointments, patients often report feeling their symptoms noticeably better.\n When a chiropractor performs an adjustment, they can help restore movement in joints that have ?locked up?. This becomes possible as treatment allows muscles surrounding joints to relax, thereby reducing joint stiffness.\n Many factors affect health, including exercise patterns, nutrition, sleep, heredity and the environment in which we live. Rather than just treat symptoms of the disease, chiropractic care focuses on a holistic approach to naturally maintain health and resist disease.\n Chiropractic adjustments help restore normal function and movement to the entire body. Many patients report an improvement in their ability to move with efficiency and strength.\n Many patients find delight in the results chiropractic adjustments have on old and chronic injuries. Whether an injury is, in fact, new or old, chiropractic care can help reduce pain, restore mobility and provide quick pain relief to all joints in the body. Such care can help maintain better overall health and thus faster recovery time.\n\nHave you ever noticed that when you are in pain and unable to perform regular or favorite activities, it can put a strain on emotional and mental well-being?\n\nFor example, the increased stress from not being able to properly perform a paid job. This, in turn, can have a negative impact on physical health with increases in heart rate and blood pressure. The domino effect often continues with sleep becoming disturbed, with resulting lethargy and tiredness during the day. Does anyone really feel up to exercising in this state?\n\nChiropractic care is a natural method of healing the body?s communication system and never relies on the use of pharmaceutical drugs or invasive surgery.\n\nDoctors of Chiropractic work collaboratively with other healthcare professionals. Should your condition require the attention of another healthcare profession, that recommendation or referral will be made.\n\n
## 2 \nUnitedHealthcare Combats Opioid Crisis with Non-Opioid Benefits\nPhysical therapy and chiropractic care can prevent or reduce expensive, invasive spinal procedures, such as imaging or surgery, to reduce opioid use and cut costs.\nUnitedHealthcare, opioid, physical therapy, healthcare spending\n\nSource: Thinkstock\nShare on Twitter\n\nBy Kelsey Waddill\n\nOctober 29, 2019 - UnitedHealthcare (UHC) is combatting the opioid epidemic and high healthcare costs with new physical therapy and chiropractic care benefits to prevent, delay, or in some cases substitute for invasive spinal procedures.\n\n?With millions of Americans experiencing low back pain currently or at some point during their lifetimes, we believe this benefit design will help make a meaningful difference by improving health outcomes while reducing costs,? said Anne Docimo, MD, UnitedHealthcare chief medical officer.\n\nLower back pain is in part responsible for sustaining the opioid epidemic and also increases healthcare costs.\nDig Deeper\n\n How Major Payers Provide Substance Abuse Care for Opioid Misuse\n Opioid Overdoses Fall by 2% from 2017 to 2018, CDC Reports\n Physical Therapy, Chiropractic Back Care Cut Opioid Use, Costs\n\nAlthough opioid overdoses fell by two percent from 2017 to 2018 and a legal battles aim to hold pharmaceutical companies accountable, there is no end in sight for the opioid epidemic. Industry professionals are still grappling with the balance between cutting opioid prescriptions will working to reduce patient pain.\n\nCommon conditions such as low back pain bolster the epidemic?s presence, with clinicians still prescribing the opioids against best practice recommendations. According to a recent OptumLabs study, 9 percent of patients with newly diagnosed low back pain are prescribed opioids and lower back pain currently contributes 52 percent to the overall opioid prescription rate.\n\nIn addition to boosting opioids distribution, alternative, invasive lower back pain treatments can significantly impact healthcare spending.\n\nIt is not new information that physical therapy and chiropractic care are effective, lower cost alternatives to spinal imaging or surgery. However, payers are still in the process of adopting the method.\n\nTo counteract the high-cost, high-risk potential of using opioids to treat back pain, UHC created a benefit that does not rely on medication or technology but rather on physical therapy and chiropractic care.\n\nThe benefit allows eligible employers to offer physical therapist and chiropractor visits with no out-of-pocket costs. Members who already receive physical therapist and chiropractic care benefits under UHC?s employer-sponsored health plans and who have maxed out their visits will not receive additional visits under this benefit.\n\nHowever, for those who still have visits to use and who choose physical therapy or chiropractic care over other forms of treatment, the copay or deductible for those visits will be waived and they will receive three visits at no cost.\n\nUHC has high expectations for the fiscal and physical impacts of this benefit.\n\nAccording to UHC?s analysis, the health payer expects that by 2021, opioid use will decrease by 19 percent. Spinal imaging test frequency and spinal surgeries will be reduced by 22 percent and 21 percent, respectively. In addition to these specific goals, UHC hopes to see a decrease in the overall cost of spinal care.\n\nThe same OptumLabs study demonstrated that UHC?s expectations are not without precedent.\n\nThe study looked at the correlation between out-of-pocket costs and patient utilization of noninvasive treatments. Researchers discovered that members whose copay was over $30 were a little under 30 percent less likely to choose physical therapy as opposed to more invasive treatments.\n\nAn American Journal of Managed Care study in June 2019 found that patients with high deductibles, typically over $1,000, were less likely to visit physical therapy.\n\nEligible employers may be brand new or renewing their membership. They must be fully insured and over 51 or more employees strong. The benefit is currently available in Connecticut, Florida, Georgia, New York, and North Carolina.\n\nHowever, UHC plans to expand the benefit from 2020 into 2021. By the end of this expansion period, the benefit will also be available to self-funded employers and organizations with an employee population between 2 and 50. The benefit will span ten states, primarily in the southeast.\n\n?This new benefit design may help encourage people with low back pain to get the right care at the right time and in the right setting, helping expand access to evidence-based and more affordable treatments,? said Docimo.
## 3 The Safety of Chiropractic Adjustments\nBy Lana Barhum\nMedically reviewed by Richard N. Fogoros, MD\nUpdated on January 31, 2020\nOrthopedics\nMore in Orthopedics\n\n Home Office Ergonomics\n Sprains & Strains\n Fractures & Broken Bones\n Physical Therapy\n Orthopedic Surgery\n Osteoporosis\n Pediatric Orthopedics\n Sports Injuries\n\nView All\nIn This Article\n\n Chiropractic Adjustment\n What Research Shows\n Safety\n\nChiropractic adjustment, also called spinal manipulation, is a procedure done by a chiropractor using the hands or small instruments to apply controlled force to a spinal joint. The goal is to improve spinal motion and physical function of the entire body. Chiropractic adjustment is safe when performed by someone who is properly trained and licensed to practice chiropractic care. Complications are rare, but they are possible. Learn more about both the benefits and risks.\nChiropractic adjustment\nVerywell / Brianna Gilmartin \nChiropractic Adjustment\n\nOne of the most important reasons people seek chiropractic care is because it is a completely drug-free therapy. Someone dealing with joint pain, back pain, or headaches might consider visiting a chiropractor.\n\nThe goal of chiropractic adjustment is to place the body into a proper position so the body can heal itself. Treatments are believed to reduce stress on the immune system, reducing the potential for disease. Chiropractic care aims to address the entire body, including a person?s ability to move, perform, and even think.\nWhat Research Shows\n\nMany people wonder how helpful chiropractic care is in treating years of trauma and poor posture. There have been numerous studies showing the therapeutic benefits of chiropractic care.\nSciatica\n\nSciatica is a type of pain affecting the sciatic nerve, the large nerve extending from the low back down the back of the legs. Other natural therapies don?t always offer relief and most people want to avoid steroid injections and surgery, so they turn to chiropractic care.\n\nA double-blind trial reported in the Spine Journal compared active and simulated chiropractic manipulations in people with sciatic nerve pain. Active manipulations involved the patient laying down and receiving treatment from a chiropractor. Stimulated manipulations involved electrical muscle stimulation with electrodes placed on the skin to send electrical pulses to different parts of the body.\n\nThe researchers determined active manipulation offered more benefits than stimulated. The people who received active manipulations experienced fewer days of moderate or severe pain and other sciatica symptoms. They also reported no adverse effects.\nNeck Pain\n\nOne study reported in the Annals of Internal Medicine looked at different therapies for treating neck pain. They divided 272 study participants into three groups: one that received spinal manipulation from a chiropractic doctor, a second group given over-the-counter (OTC) pain relievers, narcotics, and muscle relaxers, and a third group who did at-home exercises. \n\nAfter 12 weeks, patients reported a 75% pain reduction, with the chiropractic treatment group achieving the most improvement. About 57% of the chiropractic group achieved pain reduction, while 48% received pain reduction from exercising, and 33% from medication.\n\nAfter one year, 53% of the drug-free groups continued to report pain relief compared to only 38% of those taking pain medications. \nHeadaches\n\nCervicogenic headaches and migraines are commonly treated by chiropractors. Cervicogenic headaches are often called secondary headaches because pain is usually referred from another source, usually the neck. Migraine headaches cause severe, throbbing pain and are generally experienced on one side of the head. There are few non-medicinal options for managing both types of chronic headaches.\n\nResearch reported in the Journal of Manipulative and Physiological Therapeutics suggests chiropractic care, specifically spinal manipulation, can improve migraines and cervicogenic headaches. \nFrozen Shoulder\n\nFrozen shoulder affects the shoulder joint and involves pain and stiffness that develops gradually and gets worse. Frozen shoulder can be quite painful, and treatment involves preserving as much range of motion in the shoulder as possible and managing pain.\n\nA clinical trial reported in the Journal of Chiropractic Medicine described how patients suffering from frozen shoulder responded to chiropractic treatment. Of the 50 patients, 16 completely recovered, 25 showed a 75 to 90% improvement, and eight showed a 50 to 75% improvement. Only one person showed zero to 50% improvement. The researchers concluded most people can get improvement by treating frozen shoulder with chiropractic treatment.\nPreventing Need for Surgery\n\nChiropractic care may reduce the need for back surgery. Guidelines reported in the Journal of the American Medical Association suggest that it's reasonable for people suffering from back pain to try spinal manipulation before deciding on surgical intervention.\nLow Back Pain\n\nStudies have shown chiropractic care, including spinal manipulation, can provide relief from mild to moderate low back pain. In fact, spinal manipulation may work as well as other standard treatments, including pain-relief medications.\n\nA 2011 review of 26 clinical trials looked at the effectiveness of different treatments for chronic low back pain. What they found was that spinal manipulation is just as effective as other treatments for reducing back pain and improving function.\nSafety\n\nRisks and side effects associated with chiropractic adjustments may include:\n\n temporary headaches\n fatigue after treatment\n discomfort in parts of the body that were treated\n\nRare but serious risks associated with chiropractic adjustment include:\n\n stroke\n cauda equina syndrome, a condition involving pinched nerves in the lower part of the spinal canal\n worsening of herniated disks (although research isn't conclusive)\n\nIn addition to effectiveness, research has focused on the safety of chiropractic treatments, mainly spinal manipulation. \n\nOne 2017 review of 250 articles looked at serious adverse events and benign events associated with chiropractic care. Based on the evidence the researchers reviewed, serious adverse events accounted for one out of every two million spinal manipulations to 13 per 10,00 patients. Serious adverse events included spinal or neurological problems and cervical arterial strokes (dissection of any of the arteries in the neck).\n\nBenign events were more common and included more pain and higher levels of neck problems, but most were short-term problems.\n\nThe researchers confirmed serious adverse events were rare and often related to other preexisting conditions, while benign events are more common. However, the reasons for any types of adverse events are unknown.\n\nA second 2017 review looked 118 articles and found frequently described adverse events include stroke, headache and vertebral artery dissection (cervical arterial stroke). Forty-six percent of the reviews determined that spinal manipulation was safe, while 13% expressed concern of harm. The remaining studies were unclear or neutral. While the researchers did not offer an overall conclusion, they determined spinal manipulation can significantly be helpful, and some risk does exist.\nA Word From Verywell\n\nWhen chiropractors are correctly trained and licensed, chiropractic care is safe. Mild side effects are to be expected and include temporary soreness, stiffness, and tenderness in the treated area. However, you still want to do your research. Ask for a referral from your doctor. Look at the chiropractor?s website, including patient reviews. Meet with the chiropractor to discuss his or her treatment practices and ask about possible adverse effects related to treatment.\n\nIf you decide a chiropractor isn?t for you, consider seeing an osteopathic doctor. Osteopaths are fully licensed doctors who can practice all areas of medicine. They have received special training on the musculoskeletal system, which includes manual readjustments, myofascial release and other physical manipulation of bones and muscle tissues.
## 4 Advanced Chiropractic Relief: 8 Key Benefits of Chiropractor Care\n\nAre you one of the 50 million Americans who suffer from chronic pain? If so you?re probably intimately familiar with the feeling of pure desperation that can arise from an inability to find relief.\n\nIn addition to physical issues, chronic pain can cause anxiety, depression, and more. However, there could be a light at the end of the tunnel. Many people are finding advanced chiropractic relief that is completely changing their lives.\n\nYour body is a world in itself. At this very moment, more than a million chemical reactions are taking place in your body. It manufactures energy, it regulates your heartbeat, your breathing and it regenerates and heals itself. Everything takes place without your conscious knowledge, without you controlling it voluntarily. The master system that controls it all is your nervous system.\n\nThe nervous system is made out of your brain, spinal cord and all your nerves.\n\nThe energy that flows through your nervous system in your body is like electricity. In order to have that electric flow normally and freely, we need to have a well functioning spine. Whenever you have disruption of that flow, disease happens. That would be the case when your spine is misaligned or is not moving properly.\n\nDid you know that 90% of stimulation and nutrition to the brain is generated by the movement of the spine?\n\nThe more mechanically distorted a person is, the less energy is available for thinking, metabolism and healing.\n\nThis is why it is so important to have a healthy spine, a proper posture, to exercise, to eat properly ? all of it truly matters for your quality of life.\nChiropractors localize the areas of your spine that do not move properly ? referred to as vertebral subluxations ? and adjust them with a specific high speed, but yet gentle, thrust to improve spinal motion.\n\nWant to learn about some of the ways chiropractic care can help you? Keep reading for insight into some of the key benefits of seeing a chiropractor.\n\nThe benefits of chiropractic care are numerous:\n\n1. Lower Blood Pressure\n\nStudies show that chiropractic treatment can lower your blood pressure. Sometimes, this works just as well as a prescription blood pressure medication! This benefit can also last for as long as six months after treatment.\n\nHigh blood pressure can cause an array of serious side effects like nausea, fatigue, dizziness, and anxiety. Sufferers who haven?t found relief should consider consulting with a chiropractor. A chiropractic adjustment may be the solution.\n\nSome studies have shown that chiropractic adjustments can also help patients who are suffering from low blood pressure.\n\n2. Reduced Inflammation\n\nIn many cases, joint issues, pain, and tension are caused by inflammation in the body. Chiropractic adjustments can reduce inflammation.\n\nThis leads to relief of muscle tension, chronic back pain, and joint pain. These adjustments can sometimes also slow the progression of inflammation-related diseases, like arthritis.\n\n3. Better Sleep\n\nPatients who receive chiropractic adjustments report a significant improvement in their sleep patterns. If you regularly suffer from insomnia, visiting a chiropractor regularly may help. Also, when you experience pain relief, this will help you get a restful night?s sleep.\n\n4. Digestive Relief\n\nChiropractors often give nutritional advice as part of their services. However, this isn?t the only way that they provide patients with digestive relief.\n\nAdjusting the thoraco-lumbar spine restores the neurological function of your digestive system. Regular adjustments can help with chronic digestive issues.\n\n5. Stress Release\n\nEveryday life can cause muscle cramping, inflammation, and more. When you?re sore from working at a computer, heavy lifting, or just dealing with emotional stress, a chiropractic adjustment can help. This leads to greater comfort and advanced pain relief.\n\n6. Improvement of Neurological Conditions\n\nA chiropractic adjustment can also increase blood flow to the brain and increase the flow of cerebral spinal fluid. This means that patients suffering from neurological conditions like epilepsy and multiple sclerosis can significantly benefit from regular adjustments.\n\nThis is a relatively new area of study, but the potential is huge. Those suffering from these conditions will want to do some research. It?s important to find the best chiropractor in their area with experience dealing with these specific types of cases.\n\n7. Chiropractic care can improve communication from your brain to your muscles\n\nResearch seems to show that chiropractic care can improve your brain-body communication, helping your brain to be more aware of what is going on in the body so it can control your body better.\n\nBetter health, more energy and vitality are some of the positive effects of getting your spine adjusted. It sets your vertebrae back into motion freeing up the energy that travels through your nerves.\n\nChiropractic care is a partnership. The results patients want is a combination of what the chiropractor does and what the patient does.\n\nThere are many good things that can be changed and improved for a better lifestyle: exercise, good nutrition, good mental attitude and spinal adjustments.\n\nYour whole body will work better by having your nervous system free of interference. That is the essence of chiropractic care and is designed for you and your family.\n\n8. Pain Relief\n\nPerhaps the most well-known benefit of going to a chiropractor is pain relief. Adjustments can help with a huge array of painful conditions including the following.\n\nNeck and Lower Back Pain\n\nAdjustments are the most effective non-invasive pain relief method for this type of pain. They may help patients avoid having to take prescription pain management drugs.\n\nSciatica\n\nTreatments help relieve pressure on the nerve. This results in less severe pain that lasts for a fewer number of days.\n\nHeadaches\n\nChiropractic adjustments help headaches and migraines. They do this by treating back misalignment, muscle tension, and stress. Cervical spine manipulation was associated with significant improvement in headache outcomes in trials involving patients with neck pain and/or neck dysfunction and headache.\n\nChronic headaches can result from the abnormal positioning of the head and can be worsened from neck pressure and movement. Chiropractic removes the interference whether it may be from the distant muscle tightness in the back causing strain on your spine or an abnormal lordotic cervical curve and moving vertebrae.\nChiropractic care can reduce the duration of headaches, lower their intensity when they do occur and limit the frequency of their occurrence all together.\n\nMenstrual cramps\n\nChiropractic treatment removes tension from the pelvis and sacrum. It also regulates the neurological function communicating with the reproductive organs. Adjustments can also relieve the bloating, cramping, and pain associated with menstrual cramps\n\nAnyone who has tried traditional medical treatments and has been unable to find pain relief should experiment with chiropractic care. More often than not, you?ll be pleasantly surprised!\n\nBonus: Advanced Chiropractic Relief\n\nIn addition to the benefits listed above, adjustments can bring advanced chiropractic relief for a wide variety of other conditions as well as overall life improvement. A few examples include:\n\nScoliosis ? adjustments have shown to help with the pain, reduced range of motion, abnormal posture, and even difficulty breathing caused by this abnormal curvature of the spine\n\nVertigo ? an adjustment can help realign and balance the spine, thereby reducing the dizziness, nausea, and disorientation caused by vertigo\n\nSinus and allergy relief ? adjusting the upper cervical spine can help drain the sinuses and provide immediate and lasting relief from both long-term and seasonal allergies\n\nExpectant mothers ? women can experience relief from pain and morning sickness and are better able to maintain proper posture during and after pregnancy\n\nChildren?s issues ? treatments have been shown to help children with acid reflux, cholic, and ear infections\nAthletic performance ? the reduction in pain and inflammation is particularly beneficial for professional and amateur athletes\n\nStimulates the immune system ? chiropractic care helps to boost the immune system, speeding up the healing process following illnesses or injuries. One of the most important studies showing the positive effect chiropractic care can have on the immune system and general health was performed by Ronald Pero, Ph.D., chief of cancer prevention research at New York?s Preventive Medicine Institute and professor of medicine at New York University. Dr. Pero measured the immune systems of people under chiropractic care as compared to those in the general population and those with cancer and other serious diseases.\n\nIn his initial three-year study of 107 individuals who had been under chiropractic care for five years or more, the chiropractic patients were found to have a 200% greater immune competence than people who had not received chiropractic care, and 400% greater immune competence than people with cancer and other serious diseases. The immune system superiority of those under chiropractic care did not diminish with age.\n\nDr. Pero stated: ?When applied in a clinical framework, I have never seen a group other than this chiropractic group to experience a 200% increase over the normal patients. This is why it is so dramatically important. We have never seen such a positive improvement in a group.?\n\nAs you can see, there are almost limitless benefits to seeking chiropractic treatment. If you haven?t tried it yet, what are you waiting for?\n\nThere?s no need to accept pain and discomfort as a normal part of life. You have nothing to lose and everything to gain, so it only makes sense to find out more about this possibly life-changing approach to improving your health and wellness.
## 5 Heading to the spa can be a pampering treat, but it can also be a huge boost to your health and wellness! Massage therapy can relieve all sorts of ailments ? from physical pain, to stress and anxiety. People who choose to supplement their healthcare regimen with regular massages will not only enjoy a relaxing hour or two at the spa, but they will see the benefits carry through the days and weeks after the appointment!\n\n1\n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\nThese are the 10 most common benefits reported from massage therapy:\n\n1. Reduce Stress\n\nA relaxing day at the spa is a great way to unwind and de-stress. However, clients are sure to notice themselves feeling relaxed and at ease for days and even weeks after their appointments!\n\n \n\n2. Improve Circulation\n\nLoosening muscles and tendons allows increased blood flow throughout the body. Improving your circulation can have a number of positive effects on the rest of your body, including reduced fatigue and pain management!\n\n \n\n3. Reduce Pain\n\nMassage therapy is great for working out problem areas like lower back pain and chronic stiffness. A professional therapist will be able to accurately target the source of your pain and help achieve the perfect massage regimen.\n\n \n\n3\n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n4. Eliminate Toxins\n\nStimulating the soft tissues of your body will help to release toxins through your blood and lymphatic systems.\n\n \n\n5. Improve Flexibility\n\nMassage therapy will loosen and relax your muscles, helping your body to achieve its full range of movement potential.\n\n \n\n6. Improve Sleep\n\nA massage will encourage relaxation and boost your mood. Going to bed with relaxed and loosened muscles promotes more restful sleep, and you?ll feel less tired in the morning!\n\n \n\n7. Enhance Immunity\n\nStimulation of the lymph nodes re-charges the body?s natural defense system.\n\n \n\n8. Reduce Fatigue\n\nMassage therapy is known to boost mood and promote better quality sleep, thus making you feel more rested and less worn-out at the end of the day.\n\n \n\n2\n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n9. Alleviate Depression and Anxiety\n\nMassage therapy can help to release endorphins in your body, helping you to feel happy, energized, and at ease.\n\n \n\n10. Reduce post-surgery and post-injury swelling\n\nA professional massage is a great way to safely deal with a sports injury or post-surgery rehabilitation.\n\nDo you think that massage therapy could help you find relief in any of these areas? What improvements would you like to see in your health? Contact us today with your questions about massage therapy and see how we can help you get on the path to improved health and wellness!
## 6 Massage: Get in touch with its many benefits\n\nMassage can be a powerful tool to help you take charge of your health and well-being. See if it's right for you.\nBy Mayo Clinic Staff\n\nMassage is no longer available only through luxury spas and upscale health clubs. Today, massage therapy is offered in businesses, clinics, hospitals and even airports. If you've never tried massage, learn about its possible health benefits and what to expect during a massage therapy session.\nWhat is massage?\n\nMassage is a general term for pressing, rubbing and manipulating your skin, muscles, tendons and ligaments. Massage may range from light stroking to deep pressure. There are many different types of massage, including these common types:\n\n Swedish massage. This is a gentle form of massage that uses long strokes, kneading, deep circular movements, vibration and tapping to help relax and energize you.\n Deep massage. This massage technique uses slower, more-forceful strokes to target the deeper layers of muscle and connective tissue, commonly to help with muscle damage from injuries.\n Sports massage. This is similar to Swedish massage, but it's geared toward people involved in sport activities to help prevent or treat injuries.\n Trigger point massage. This massage focuses on areas of tight muscle fibers that can form in your muscles after injuries or overuse.\n\nBenefits of massage\n\nMassage is generally considered part of complementary and integrative medicine. It's increasingly being offered along with standard treatment for a wide range of medical conditions and situations.\n\nStudies of the benefits of massage demonstrate that it is an effective treatment for reducing stress, pain and muscle tension.\n\nWhile more research is needed to confirm the benefits of massage, some studies have found massage may also be helpful for:\n\n Anxiety\n Digestive disorders\n Fibromyalgia\n Headaches\n Insomnia related to stress\n Myofascial pain syndrome\n Soft tissue strains or injuries\n Sports injuries\n Temporomandibular joint pain\n\nBeyond the benefits for specific conditions or diseases, some people enjoy massage because it often produces feelings of caring, comfort and connection.\n\nDespite its benefits, massage isn't meant as a replacement for regular medical care. Let your doctor know you're trying massage and be sure to follow any standard treatment plans you have.\nRisks of massage\n\nMost people can benefit from massage. However, massage may not be appropriate if you have:\n\n Bleeding disorders or take blood-thinning medication\n Burns or healing wounds\n Deep vein thrombosis\n Fractures\n Severe osteoporosis\n Severe thrombocytopenia\n\nDiscuss the pros and cons of massage with your doctor, especially if you are pregnant or you have cancer or unexplained pain.\n\nSome forms of massage can leave you feeling a bit sore the next day. But massage shouldn't ordinarily be painful or uncomfortable. If any part of your massage doesn't feel right or is painful, speak up right away. Most serious problems come from too much pressure during massage.\nWhat you can expect during a massage\n\nYou don't need any special preparation for massage. Before a massage therapy session starts, your massage therapist should ask you about any symptoms, your medical history and what you're hoping to get out of massage. Your massage therapist should explain the kind of massage and techniques he or she will use.\n\nIn a typical massage therapy session, you undress or wear loose-fitting clothing. Undress only to the point that you're comfortable. You generally lie on a table and cover yourself with a sheet. You can also have a massage while sitting in a chair, fully clothed. Your massage therapist should perform an evaluation through touch to locate painful or tense areas and to determine how much pressure to apply.\n\nDepending on preference, your massage therapist may use oil or lotion to reduce friction on your skin. Tell your massage therapist if you might be allergic to any ingredients.\n\nA massage session may last from 10 to 90 minutes, depending on the type of massage and how much time you have. No matter what kind of massage you choose, you should feel calm and relaxed during and after your massage.\n\nIf a massage therapist is pushing too hard, ask for lighter pressure. Occasionally you may have a sensitive spot in a muscle that feels like a knot. It's likely to be uncomfortable while your massage therapist works it out. But if it becomes painful, speak up.\nFinding a massage therapist\n\nAsk your doctor or someone else you trust for a recommendation. Most states regulate massage therapists through licensing, registration or certification requirements.\n\nDon't be afraid to ask a potential massage therapist such questions as:\n\n Are you licensed, certified or registered?\n What is your training and experience?\n How many massage therapy sessions do you think I'll need?\n What's the cost, and is it covered by health insurance?\n\nThe take-home message about massage\n\nBrush aside any thoughts that massage is only a feel-good way to indulge or pamper yourself. To the contrary, massage can be a powerful tool to help you take charge of your health and well-being, whether you have a specific health condition or are just looking for another stress reliever. You can even learn how to do self-massage or how to engage in massage with a partner at home.
## Topic
## 1 chiropractic benefits
## 2 chiropractic benefits
## 3 chiropractic benefits
## 4 chiropractic benefits
## 5 massage benefits
## 6 massage benefits
We are to make our data table into a dplyr tibble.
text_df <- tibble(line=1:65, text=modalities1$Document,
Recommend=modalities1$Topic)
head(text_df)
## # A tibble: 6 x 3
## line text Recommend
## <int> <fct> <fct>
## 1 1 "Chiropractic adjustments and treatments serve the ne~ chiropractic ben~
## 2 2 "\nUnitedHealthcare Combats Opioid Crisis with Non-Op~ chiropractic ben~
## 3 3 " The Safety of Chiropractic Adjustments\nBy Lana Bar~ chiropractic ben~
## 4 4 "Advanced Chiropractic Relief: 8 Key Benefits of Chir~ chiropractic ben~
## 5 5 "Heading to the spa can be a pampering treat, but it ~ massage benefits
## 6 6 "Massage: Get in touch with its many benefits\n\nMass~ massage benefits
Now for the word counts by line or in our case by review which is line.This uses the tidytext package to unnest the words as tokens from each review. We will use the ngrams method of tokenizing to get the sequential groups of threes for words used in combination. This will be very useful to us in predicting our ratings accurately. As we have seen that using a word like ‘like’ or ‘good’ has very similar word counts in ratings of 1 and ratings of 5 but not so much in the 2-4 range. This is because some of those likes are in ngrams of 2-3 with word pairings such as ‘don’t like’, ‘not as good’, etc.
text_df$text <- as.character(paste(text_df$text))
fills <- as.data.frame(c('of','the','a','an','in','by','it','as','or','go','goes','am','and','to'))
colnames(fills) <- 'fillers'
text_df0 <- text_df %>% unnest_tokens(bigram,text,token='ngrams',n=2) %>%
separate(bigram, c('word1','word2'), sep=' ')
text_df01 <- anti_join(text_df0,fills, by=c("word1"="fillers"))
text_df02 <- anti_join(text_df01,fills, by=c("word2"="fillers"))
text_df02$bigram <- paste(text_df02$word1,text_df02$word2,sep=' ')
text_df03 <- text_df02[,-c(2:4)]
text_df1 <- text_df %>% unnest_tokens(bigram,text, token='ngrams',n=2)
text_df2 <- merge(text_df1,text_df03, by.x='bigram', by.y='bigram', all.y=FALSE)
text_df3 <- text_df2[,-4]
colnames(text_df3)[2] <- 'line'
head(text_df3,30)
## bigram
## 1 _______________________________________________________________________________ damkee
## 2 _______________________________________________________________________________ mebak
## 3 _______________________________________________________________________________ sylphim
## 4 0 6
## 5 0 comments
## 6 01 03pm
## 7 02 2013
## 8 02 2019
## 9 02 2020
## 10 02 futuristic
## 11 03 02
## 12 03 2020
## 13 03pm edt
## 14 04 30
## 15 05 02
## 16 1 2019
## 17 1 5
## 18 1 8
## 19 1 800
## 20 1 877
## 21 1 diabetes
## 22 1 lower
## 23 1 million
## 24 1 move
## 25 1 questions
## 26 1 reduce
## 27 1 several
## 28 1 share
## 29 1 sports
## 30 1 stretching
## line Recommend
## 1 54 massage gun benefits
## 2 54 massage gun benefits
## 3 54 massage gun benefits
## 4 27 mental health services benefits
## 5 27 mental health services benefits
## 6 49 massage gun benefits
## 7 62 cold stone benefits
## 8 36 cupping benefits
## 9 28 mental health services benefits
## 10 51 massage gun benefits
## 11 62 cold stone benefits
## 12 31 mental health services benefits
## 13 49 massage gun benefits
## 14 49 massage gun benefits
## 15 51 massage gun benefits
## 16 50 massage gun benefits
## 17 51 massage gun benefits
## 18 27 mental health services benefits
## 19 30 mental health services benefits
## 20 30 mental health services benefits
## 21 10 massage benefits
## 22 4 chiropractic benefits
## 23 35 chiropractic benefits
## 24 28 mental health services benefits
## 25 27 mental health services benefits
## 26 5 massage benefits
## 27 27 mental health services benefits
## 28 39 cupping benefits
## 29 46 massage gun benefits
## 30 23 physical therapy benefits
We see from the above it basically goes along every string word and counts each white space to separate a character from a non-character and get each word, but it also does it for any three combinations, so that almost every word is part of the beginning of one trigram (as we set n to 3 for the number of ngrams, thus trigram), the middle of one trigram, or the end of a trigram. Look at ‘wonderful’ above and see what I am referring to.
text_df4 <- text_df3 %>% group_by(bigram) %>% count(bigram, sort=TRUE) %>% ungroup
head(text_df4,30)
## # A tibble: 30 x 2
## bigram n
## <chr> <int>
## 1 mental health 24964
## 2 physical therapy 11236
## 3 massage gun 9409
## 4 massage therapy 7921
## 5 massage guns 6241
## 6 if you 5625
## 7 can be 4900
## 8 can help 4900
## 9 stone massage 3249
## 10 you can 3136
## # ... with 20 more rows
The above shows all documents bigram occurences of word pairs.
We want the recommended modality or health care option for each category counts of bigrams.
chiropractor <- subset(text_df3, text_df3$Recommend=='chiropractic benefits')
massage <- subset(text_df3, text_df3$Recommend=='massage benefits')
physicalTherapy <- subset(text_df3, text_df3$Recommend=='physical therapy benefits')
mental <- subset(text_df3, text_df3$Recommend=='mental health services benefits')
cupping <- subset(text_df3, text_df3$Recommend=='cupping benefits')
massageGun <- subset(text_df3, text_df3$Recommend=='massage gun benefits')
coldStone <- subset(text_df3, text_df3$Recommend=='cold stone benefits')
Group each category into bigram counts.
chiropractor2 <- chiropractor %>% group_by(bigram) %>% count(bigram, sort=TRUE)
chiropractor3 <- spread(chiropractor2,bigram,n)
freqChiropractor <- colSums(chiropractor3)
massage2 <- massage %>% group_by(bigram) %>% count(bigram, sort=TRUE)
massage3 <- spread(massage2,bigram,n)
freqMassage <- colSums(massage3)
physical2 <- physicalTherapy %>% group_by(bigram) %>% count(bigram, sort=TRUE)
physical3 <- spread(physical2,bigram,n)
freqPhysical <- colSums(physical3)
mental2 <- mental %>% group_by(bigram) %>% count(bigram, sort=TRUE)
mental3 <- spread(mental2,bigram,n)
freqMental <- colSums(mental3)
cupping2 <- cupping %>% group_by(bigram) %>% count(bigram, sort=TRUE)
cupping3 <- spread(cupping2,bigram,n)
freqCupping <- colSums(cupping3)
massageGun2 <- massageGun %>% group_by(bigram) %>% count(bigram, sort=TRUE)
massageGun3 <- spread(massageGun2,bigram,n)
freqMassageGun <- colSums(massageGun3)
coldStone2 <- coldStone %>% group_by(bigram) %>% count(bigram, sort=TRUE)
coldStone3 <- spread(coldStone2,bigram,n)
freqColdStone <- colSums(coldStone3)
wordcloud(names(freqChiropractor), freqChiropractor,
min.freq=80,colors=brewer.pal(3,'Dark2'))
## Warning in wordcloud(names(freqChiropractor), freqChiropractor, min.freq = 80, :
## chiropractic care could not be fit on page. It will not be plotted.
wordcloud(names(freqMassage), freqMassage, min.freq=80,colors=brewer.pal(3,'Dark2'))
## Warning in wordcloud(names(freqMassage), freqMassage, min.freq = 80, colors
## = brewer.pal(3, : massage therapy could not be fit on page. It will not be
## plotted.
wordcloud(names(freqPhysical), freqPhysical,
min.freq=80,colors=brewer.pal(3,'Dark2'))
## Warning in wordcloud(names(freqPhysical), freqPhysical, min.freq = 80, colors
## = brewer.pal(3, : physical therapy could not be fit on page. It will not be
## plotted.
wordcloud(names(freqMental), freqMental,
min.freq=80,colors=brewer.pal(3,'Dark2'))
wordcloud(names(freqCupping), freqCupping,
min.freq=80,colors=brewer.pal(3,'Dark2'))
## Warning in wordcloud(names(freqCupping), freqCupping, min.freq = 80, colors
## = brewer.pal(3, : cupping therapy could not be fit on page. It will not be
## plotted.
wordcloud(names(freqMassageGun), freqMassageGun,
min.freq=80,colors=brewer.pal(3,'Dark2'))
wordcloud(names(freqColdStone), freqColdStone,
min.freq=80,colors=brewer.pal(3,'Dark2'))