This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: "Ryan Wesslen" | |
| title: "cfpb complaints/reticulate" | |
| output: html_document | |
| --- | |
| ```{r setup, include=FALSE} | |
| knitr::opts_chunk$set(echo = TRUE) | |
| library(reticulate); library(tidyverse) | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: "LDA vs CTM Experiment" | |
| author: "Ryan Wesslen" | |
| date: "Aug 28, 2019" | |
| output: html_document | |
| --- | |
| ```{r setup, include=FALSE} | |
| knitr::opts_chunk$set(echo=TRUE, warning=FALSE, message=FALSE) | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import spacy | |
| from spacy import displacy | |
| path = "en_core_web_sm" | |
| nlp = spacy.load(path) | |
| path_folder = "/path/to/file/" | |
| import pandas as pd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # step 1: create 4 new columns in by_country (get freq stats) | |
| # *Mean = donors_mean | |
| # *Lower = donors_mean - 2*donors_stdev | |
| # *Upper = donors_mean + 2*donors_stdev | |
| # *Type = "Std Dev" | |
| freq_df <- by_country %>% | |
| mutate(Lower = donors_mean - 2*donors_stdev, | |
| Upper = donors_mean + 2*donors_stdev, | |
| Mean = donors_mean) %>% | |
| select(-donors_mean, -donors_stdev) %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # for more on keras/tf for R, see https://blogs.rstudio.com/tensorflow/ | |
| library(keras) | |
| mnist <- dataset_mnist() | |
| x_train <- mnist$train$x | |
| y_train <- mnist$train$y | |
| x_test <- mnist$test$x | |
| y_test <- mnist$test$y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import spacy | |
| import textacy | |
| import pandas as pd | |
| # load flat file | |
| df = pd.read_csv("data/vispapers.csv", engine = "python") | |
| # texts + metadata | |
| texts = { | |
| "text": df.Abstract, | |
| "Conference": df.Conference, | |
| "Year": df.Year |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import spacy | |
| import numpy as np | |
| import pandas as pd | |
| import altair as alt | |
| #alt.renderers.enable('default') # if in jupyter, need to activate | |
| def cos_sim(t1, t2): | |
| return np.dot(t1.vector, t2.vector) / (t1.vector_norm * t2.vector_norm) | |
| nlp = spacy.load("en_core_web_lg") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| df = pd.read_csv("vispapers.csv", engine = "python") | |
| df.shape | |
| # count keywords | |
| df['AuthorKeywords'] = df['AuthorKeywords'].apply(str) | |
| raw = [_.lower() for _ in df['AuthorKeywords'] if _ != 'nan'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM python:3.7 | |
| EXPOSE 8501 | |
| WORKDIR /app | |
| COPY requirements.txt ./requirements.txt | |
| RUN pip3 install -r requirements.txt | |
| COPY . . | |
| CMD streamlit run app.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| returns <- read_csv("data/returns.csv") %>% | |
| select(Year, equities_sp, treasury_10yr) %>% | |
| gather(key = "Asset", value = "Returns", -Year) %>% | |
| mutate(Asset = ifelse(Asset=="equities_sp", | |
| "Asset A: High risk, high return", | |
| "Asset B: Low risk, low return")) | |
| set.seed(123) |