
Domopalooza 2019
Thanks for checking out our presentation at Domopalooza! Grab our sample code here, and make sure to stop by our booth in the pavilion to learn more.
DomoR: An R package for interacting with Domo data sources
Machine Learning in SQL: Interest Rate Example
-------------------------------
-- RXA_Domopalooza_ML_in_SQL --
-- Created: 012019 --
-- Author: JPrantner--
-------------------------------
-- Because of the way Redshift is coded in Domo the query is broken into separate steps --
-- The step names are indicated below --
-- Step1--
select * from "domopalooza_econ"
where Month > 'January 01, 2010'
--Step2--
select month
from step1
group by month
order by random()
limit 80
--Step3--
select t1.month
,ln(t1."unemployment") as "unemployment"
,ln(t1."consumer sentiment") as "consumer sentiment"
from
step1 t1 inner join step2 t2 on t1."month"=t2."month"
--Step4--
SELECT
((N * Sxy) - (Sx * Sy)) / ((N * Sxx) - (Sx * Sx)) AS SPEND_ELASTICITY
FROM ( SELECT SUM(unemployment) AS Sx,
SUM("consumer sentiment") AS Sy, SUM(unemployment * unemployment) AS Sxx,
SUM(unemployment * "consumer sentiment") AS Sxy, SUM("consumer sentiment" * "consumer sentiment") AS Syy, COUNT(*) AS N FROM step3 ) sums;
-- Output File --
Select * from step4
Sentiment in Python for Domo

###############################
## RXA_Domopalooza_Sentiment ##
## Created: 012019 ##
## Author: JPrantner ##
###############################
# Import the domomagic, nltk, pandas & numpy packages into the script
from domomagic import *
from nltk import *
from nltk.sentiment.vader import SentimentIntensityAnalyzer
import pandas as pd
import numpy as np
# read data from inputs into a data frame
input1 = read_dataframe('Select Columns')
# check the dataframe
input1.info()
# transform comments to a list
comment_list = input1['Text'].tolist()
# initializes the sentiment engine
sia = SentimentIntensityAnalyzer()
# create an empty polarity_scores list as results
results = []
#append pol_score to the list results
for line in comment_list:
pol_score = sia.polarity_scores(line)
pol_score['Text'] = line
results.append(pol_score)
#create new dataframe df pass in with results
df = pd.DataFrame.from_records(results)
#add features: label 1 positive & -1 negative
df['label'] = 0
df.loc[df['compound'] > 0.2, 'label'] = 1
df.loc[df['compound'] < -0.2, 'label'] = -1
df.info()
#merge two dataframe together as input1
input1 = pd.merge(input1,df, on='Text', how='outer')
input1.info()
#writes the data back to domo
write_dataframe(input1)
Want to discover how machine learning can help your business?









