Speaker: Gary Short
Repo for presentation/samples: https://github.com/garyshort/kcdc2023
For more, see the table of contents.
Data science overview/rules
- Applied data science – solving business problems
- Curiosity is most important
- The universe does random stuff so you haven’t discovered anything until you prove you’ve discovered something
- Only qualitative and quantitative data – people lie, Can’t trust what you ask
- Can only do math with numbers. Some things will pretend to be numbers when they are not. Also, can’t add different things (dollars vs killograms)
- If you can’t explain it to a six year old, you don’t really understand it
- Only have to be more than 51% accurate to do better than guessing
- True random data has some clusters. The cluster will not last forever. Gambler’s paradox. 27 blacks doesn’t mean due a red.
- If it’s not in production, it doesn’t exist. Can’t just be on your laptop. Most data scientists need to give to someone else to get it to prod. Cultural difference between data scientist and person who is building/deploying.
- % chance of hypothesis being right or wrong doesn’t have to sum up to 100%. ex: grass is wet. Could be rain or a dog peeing or something else
Types of data
- Relational data
- Get connection, create cursor, fill cursor, close connection
- Schema is important on data write.
- ex: JSON/MongoDB.
- Get connection, name collection, fill cursor, close connection
- Schema important when read data
- Blob (binary large object)
- Stored in pages/blocks
- Access via URL
- Degrees of separation – can you deliver a message directly
- People in room now more closely connected because in this session (and would stay so if shared contact info)
- Wide network effect
- Nodes tend to be nouns
- Edges tend to be verbs. Can be unidirectional or bidirectional
- Get connection, state query, fill cursor, close connection
AI/ML works on data types
- Categorical – segregate data by category where category is not important (ex: blue eyes)
- Ordinal – order is important but distance between is not important (ex: position in a race)
- Numeric – order is important but distance is the same (ex: counting)
- Ratio – numeric but with positive numbers
Can only do math with ordinal and ratio types. A survey on a scale of 1-5 (likert scale) is ordinal, not numeric/ratio. Can’t do average. This is categorical data (ex: very happy, pissed off). Can do math with counts of categorical data but not single items.
Exploratory Data analysis
- Need to understand the variables. Ex: is it really a number
- Handle missing values – depends on scenario. Ex: use mean or median (if not looking for that particular thing), delete row with incomplete data
- Outlier detection – sometimes genuinely an outlier (ex: someone who is 8 feet tall), sometimes it is the important piece of data (ex: which exits people use in a fire; one person went the other way and want to know why). Need to determine why outlier and if care so don’t delete data need
- Univariate analysis – ex: histogram for categorical data
- Bivariate analysis – correlated data; could be hidden variable. Don’t need both of them since one predicts the other. Want minimal variables in model so chose the one that brings in the most info.
- Preprocess the data
- Normalize data – units have to be the same. Using variance doesn’t help because unit is now original unit squared. Can use Z-score so everything on scale 0-1 using mean and divisor
- Encode the categories – make so can do math
- Booleans are numbers (0 and 1)
- Word vector – can use math to represent a word. Complicated. Ok to have to look up every time.
- Bi/multivariate analysis – high correlation means redundant info
- Feature importance – check coefficients from regressions and scores from gradient boosting
- People have a favorite model
- Use one or more models. See which gives best result before making any changes to the model.
- Good to use a linear and non linear one. Normal the linear model is enough because normally dealing with people (directly or indirectly). Linear equations work for a normal distrobution.
- Make sure to find global minimum, not local/current one
- Compete with yourself. Try to have your second best model beat your current best model. Once something in prod, start again
- 80/20 split
- 80% data for training
- 20% data real
- Model never sees training data because can’t grade own homework
- Outcome – model + error
- Error is difference between predicted and observed values.
- Sample of population can be model. Get error because of sampling bias
Hyper Parameter Tuning
- Every models have parameters to govern how works.
- Hyper param tuning is fiddling with these
- Will be an optional value for each of these parameters for your particular use case
- Need to make sure model doesn’t work by chance
- K-Fold Cross Validation – after do 80/20 split, can feed data back in and do again
- Stratified Cross Validation – same as K-Fold but unbalanced classes
Bayesian inference in Real Life
- P(h|e) = P(e|h) * P(h) / P(e)
- In English: current belief = new evidence
- Important to be able to estimate values when have no data
- Dumb questions like “how many piano tuners are there in Chicago” was testing this. So few people could do it that pulled question. [I suspect the ridicule and people memorizing the answer was a factor too]
- Easier to estimate a range than an actual value
- Pick a minimum that it couldn’t possibly be below. You’d be surprised and skeptical if less than that.
- Pick a maximum that it couldn’t possible be above.
- Pick value spits range in two so that the possibility of being above/below has equal probability. Call this the medium. Resist temptation to pick the mean.
- Repeat finding the minimum to median. Call this Q1
- Then repeat finding the median to maximum to get Q3.
- This gets you a five point description of a distribution
- Use sampling to get mean of distribution
The lab was to predict something you want to predict and make a model and/or predict a probability. Can do individually or in groups. He also gave the option to leave. I chose leave because there was a little over an hour left when he finished explaining the lab. I need to go over the material for my own workshop so doing that instead of the lab.
This was a good intro and Gary is a good, engaging speaker. I learned (and re-learned) a bunch of stuff. Both concepts and terms. Having a bunch of rules and getting into them made it fun. (ex: math needs numbers). I like that the concept part was longer (except for the lack of a break), but it would hav been better if it was advertised that way in the intro.
I disagree with Gary’s philosophy on not having a bathroom break. He started by saying there would be 60-90 minutes of lecture and then a lab. [wound up to being just over 2.5 hours] And that we are all adults and can go to the bathroom whenever. Someone asked at the 90 minute mark if there would be a bathroom break and he repeated the all adults thing expanding that you’ll catch up and the slides will be online later. He also said people feel compelled to hold it until break or go when told it is break. However, the tradeoff is that you don’t want to go to the bathroom lest you miss something that will wind up being important during the session. It’s super frustrating to miss stuff and then struggle to understand later. It may be that this workshop isn’t cumulative but there’s no way to know. Also, by not having a break, you aren’t giving people’s brain a break. It’s not just about the bathroom.
Gary stated he puts the materials online after so people don’t read it during the session. That I agree with!