Posts

R – Stats, factor count,proportion

  Change to factor: adult$RACEHPR2 <- factor(adult$RACEHPR2, labels = c(“Latino”, “Asian”, “African American”, “White”)) show all factors: levels(v) droplevels(v) to remove unused factors Counts of factors: x <- table(adult$RBMI, adult$SRAGE_P) or count(dataframe, variable) Proportion: prop.table(x ) sum all = 1 prop.table(x,1 ) conditional proportions, sum row = 1 prop.table(x,1 ) conditional proportions, sum column = 1  

Consulting Interview

  Numerical skills – rather simple tips on quick estimation, rounding Top down approach is preferred Hypothesis – Always start with a hypothesis, then reason with the info to either prove it or disprove it. Don’t present info and a bunch of rationales before the conclusion, it’s just less clear to the listeners, especially C-level executives. Synthesis – Let’s do A. Because of B, C and D.

R – Time, lubridate

EXTRACT: month(date, label = TRUE, abbr = TRUE): label showing the names of the month year day yday 1 to 366 wday ROUND floor_date round_date ceiling_date INTERVAL (start time) %–% (end time) int_end int_start int_length %within% int_overlaps as.period() – convert interval to period as.duration() – convert interval to duration TIMEZONE force_tz(time, tzone = “”) with_tz(time, tzone = “”) IMPORT parse_date_time(time, order = “ymd”) fast_strptime(time, order = “%Y-%m-%d”), same format as strptime() fasttime(), fastPOSIXct() stamp(string) return format of time string %Y %d etc.

Jonas - Javascript

  variables – var abc = ”, – data types   Section 3 – How JS works Scoping When refer to a var that is not available in the current scope, the program will look to the outer scope (or even outer outer scope)   Section 4 – DOM Manipulation   classList, .add .remove classes .toggle, turn on/off the “active” class   Section 5 – Objects and Functions Everything is an object, check with  console.log () for __proto__ when we try to access properties or methods of an object it will look in its own scope first, then its proto parents, and so on. call, apply, bind, to change the  this  variable. And to pre-set some arguments of a function  

Bryan Peterson – Learning to See Creatively

  Expanding your vision Try different, new angles, i.e lying and climbing to shoot Close up shooting tells better story and evoke stronger feelings. Elements of Design Line Shape Form Pattern Color Composition Zoom in, fill the frame Rule of Third Frame within frame, another object acts as a frame. Picture within picture, part of the current image can be an image on its own. Just take both horizontal and vertical pics or … not, just break the rules The Magic of Light Front lighting – no notes Sidelighting – most dramatic, contrast between highlights and shadows Backlighting – sihoulette, shadow Digital Photography Using photo retouching software is fine Career Considerations – did not read  

SQL Join

Image
  cross join – match combinations union – stack, unique union all – stack, include duplicates intersect – result in the intersection except – result in the exception semi join – select rows from 1st table that are ALSO present in 2nd table where (field) in (table) anti join – select rows from 1st table that are NOT present in 2nd table where (field) not in (table)   Subclause can be used instead of group by!  

R - Supervised Learning

Image
  knn k nearest neighbors, k library(class) knn(training data, test data, labels), extra args: k = 2. prob = TRUE enables probability of each guess. Primitive bayes nrows(df), count rows subset(df, conditions/ col > 0 etc.), nrows this subset then do divisions Naive bayes model <- naive_bayes(y ~ x1 + x2 + … , data = df) y as explained by x1, x2 etc. predict(model , test_df) + args type = “prob” show posterior probability (instead of priori overall prob) Laplace correction:  add 1 to prevent the 0% probability affects all estimation Logistic Regression model <- glm(y ~ x1 + x2 …, data = df, family = “binomial”) predict(model, test_df, type = “response”) ROC curve to measure how well the model performs, AUC area under curve value from 0 – 1, 1 is best. library(pROC) ROC <- roc(actual var, predicted var) plot(ROC), auc(ROC) Decision Tree library(rpart) model <- rpart(y ~ x1 + x2 + …, data = df, method = “class”, control = rpart.control(cp = 0)) predict(m...