YouTube2Text

Q5: Good Uses of Machine Learning in Finance · Max Margenot — Transcript

by Chat With Traders · 10,429 words · 1,450 segments · language en · Watch on YouTube

Full transcript

  1. 0:00chat with Traders collaboration with
  2. 0:02quantopian episode
  3. 0:05[Music]
  4. 0:125 hey how's it going folks Aaron ffield
  5. 0:15here of chatwi Traders podcast what
  6. 0:18you're listening to right now is part
  7. 0:20five in a special six- part series which
  8. 0:23is of course a collaboration with the
  9. 0:26good people at quantopian in this
  10. 0:29episode we explore machine learning in
  11. 0:31trading and in finance we talk about
  12. 0:34what is machine learning where it's
  13. 0:35commonly used in everyday life and what
  14. 0:39are some of the good and not so good
  15. 0:41ways that quants may use machine
  16. 0:43learning joining myself and Delaney is
  17. 0:47Max margut Max is a data scientist at
  18. 0:51quantopian and needless to say he knows
  19. 0:53a lot about the subject matter uh just
  20. 0:56to run through a few things real quick
  21. 0:58if you have any questions please go to
  22. 1:01quantopian
  23. 1:14docomo
  24. 1:16and.com chatwi Traders you'll find
  25. 1:19everything there all in one place and
  26. 1:22also props to datacamp for sponsoring
  27. 1:26this series as I've been preaching datac
  28. 1:28camp.com in my opinion is probably the
  29. 1:32best place you could go to learn how to
  30. 1:35program particularly for working with
  31. 1:37data in languages Python and R they
  32. 1:41courses some of which are entirely free
  33. 1:43and talked by talented data scientist uh
  34. 1:46very interactive there's videos there's
  35. 1:49coding tasks and much more all of which
  36. 1:52you can complete online using their
  37. 1:54portal really good stuff so visit datac
  38. 1:57camp.com today sign up for a free
  39. 1:59account and get stuck into one of their
  40. 2:02online courses which cater for
  41. 2:04programmers of all levels beginner
  42. 2:06through to intermediate again that's
  43. 2:09datac
  44. 2:10camp.com last thing I should point out
  45. 2:12to you is the next episode and the final
  46. 2:15episode in the series is the Q&A episode
  47. 2:18so these episodes have been coming out
  48. 2:21weekly but I'm not exactly sure when
  49. 2:23this next episode will be released it's
  50. 2:26likely to be in January sometime though
  51. 2:29but if you follow me on Twitter I'll of
  52. 2:31course keep you posted anyway let's get
  53. 2:34to it haris Delaney and Max margut to
  54. 2:37talk all things machine learning and
  55. 2:42trading Delaney here we are episode 5 um
  56. 2:45I'm excited to be doing this we're
  57. 2:47discussing something very interesting
  58. 2:48today machine learning we're also joined
  59. 2:51by Max Max I'm not even going to attempt
  60. 2:54to pronounce your last name because I
  61. 2:56know uh even Delaney struggles with that
  62. 2:58one so Ma I'll leave that part up to you
  63. 3:01but I mean tell us a little bit about
  64. 3:02your story give us a quick introduction
  65. 3:04and um you know just bring us up to
  66. 3:06speed with who you are and your
  67. 3:07experience in the
  68. 3:09field yeah so I'm a Max margut it's a
  69. 3:12tough one but I'm a I'm a data scientist
  70. 3:14at quantopian I also help to manage the
  71. 3:16lecture series I've done a lot of math
  72. 3:20and statistics in the past I've messed
  73. 3:22around with uh a lot of like
  74. 3:23cryptocurrency stuff uh a lot of trading
  75. 3:26bots on bitcoin uh some of them
  76. 3:28involving machine learning uh some of
  77. 3:30them uh not involving machine learning
  78. 3:33but generally stuff that I found
  79. 3:35interesting that other people may or may
  80. 3:36not find interesting so a lot of math a
  81. 3:38lot of statistic stuff that's awesome no
  82. 3:41I think that's very cool What attracted
  83. 3:43you to to cryptocurrencies so you still
  84. 3:45do you still Mark around with that sort
  85. 3:46of thing currently I'm actually not
  86. 3:48allowed to but what uh what mainly drew
  87. 3:52me to them in the first place was I was
  88. 3:53a little involved with Bitcoin when like
  89. 3:55they first started happening like I
  90. 3:57heard about it years and years ago and I
  91. 3:59was like right I I'll mine some of this
  92. 4:01on my own computer so I got into it then
  93. 4:03and then I got back into it uh when I
  94. 4:05realized that the um the apis for the
  95. 4:09online exchanges uh the ways that I
  96. 4:11could get like my Bots and everything to
  97. 4:13communicate with them were very
  98. 4:15simplistic compared to like actual
  99. 4:18trading uh like stocks or anything uh
  100. 4:21apis so I would just like all right I'm
  101. 4:24going to build bots on cryptocurrencies
  102. 4:26because it's easier okay okay awesome so
  103. 4:29you actually got involved in the mining
  104. 4:31side of it as well yeah not super into
  105. 4:34it because this was back when I was
  106. 4:37still pretty terrible at computers I
  107. 4:39guess so I didn't really have a proper
  108. 4:42setup for it it was just mining on my uh
  109. 4:45just on my desktop computer nothing
  110. 4:47special okay so what part do you play at
  111. 4:50quantopian today tell us a little bit
  112. 4:51about that yeah so as part of the
  113. 4:55academic team I am R and Delaney I run a
  114. 4:58quantitative fin lecture Series so we
  115. 5:02basically have this curriculum of just
  116. 5:05curated IPython notebooks in our
  117. 5:07research environment and we just kind of
  118. 5:10while we have a bunch of individual
  119. 5:12lectures on statistical Concepts and
  120. 5:14financial Concepts building up from like
  121. 5:16the very most basic stuff like how do we
  122. 5:19even use Python how do we even use um
  123. 5:22some very basic uh python packages and
  124. 5:25what is a mean or a variance or a
  125. 5:28standard deviation up through uh like
  126. 5:31actual examples of building trading
  127. 5:33algorithms like pairs trading algorithms
  128. 5:34or long short Equity algorithms so it's
  129. 5:36a pretty wide range of content yeah yeah
  130. 5:39delane's referenced it many times during
  131. 5:41the series so you know anyone who's
  132. 5:43listening is is aware that those
  133. 5:44lectures are all available I think it's
  134. 5:46at quantopian
  135. 5:51docomo this sort of thing yeah so I have
  136. 5:54a uh Bachelor's in math minor and
  137. 5:57computer science and then I have a
  138. 5:59master's in mathematical Finance very
  139. 6:01impressive man all right cool well let's
  140. 6:04get let's get stuck into it so I mean
  141. 6:06first things first at a very high level
  142. 6:09what is machine learning you know many
  143. 6:11people have probably heard the term but
  144. 6:14many people probably don't fully
  145. 6:17understand it as well so yeah let's
  146. 6:19start right there what is machine
  147. 6:21learning I mean machine learning is a
  148. 6:25really really broad field and uh it's
  149. 6:28also something that means many different
  150. 6:30things to many different people right
  151. 6:31now I think cuz it's such a young field
  152. 6:34it's to an extent in its infancy and um
  153. 6:37there's so much excitement and you know
  154. 6:39what's called you know I call it a hype
  155. 6:41cycle around machine learning that
  156. 6:43everybody's excited about it now and so
  157. 6:45there's tons of people trying to get
  158. 6:47into it and you have all the people who
  159. 6:49have kind of been doing this forever
  160. 6:51being like I don't understand what's
  161. 6:53going on I have all these people I've
  162. 6:54never seen before in my house and
  163. 6:56they're trying to do all the same things
  164. 6:58I usually do but they're not doing it
  165. 7:00right so it's kind of it's it's really
  166. 7:02it's crazy right now what's going on in
  167. 7:03machine learning at its core and kind of
  168. 7:06I'll give kind of my very broad
  169. 7:07definition of it um I'm sure Max will
  170. 7:09also have a different angle on it but
  171. 7:11like at its core I view machine learning
  172. 7:14as any kind of um kind of automated
  173. 7:18statistical process uh that attempts to
  174. 7:22find patterns in data so when you talk
  175. 7:25about the work that statisticians do on
  176. 7:28a day-to-day basis a lot of machine
  177. 7:31learning is really just an attempt to
  178. 7:33actually automate that work itself and
  179. 7:36have the machine run tests the machine
  180. 7:38find patterns the machine fit models and
  181. 7:41there's like a ton of different ways you
  182. 7:43can do that but you think that's like
  183. 7:46about about right or yeah I I definitely
  184. 7:49agree with that I think like the
  185. 7:50patterns is definitely the biggest thing
  186. 7:53uh it's just like a class of algorithms
  187. 7:55and how people actually Implement them
  188. 7:56is going to vary okay sure so while
  189. 8:00we're talking about this at a very high
  190. 8:01level right now in what areas outside of
  191. 8:04Finance are machine learning techniques
  192. 8:07applied I mean it might be helpful for
  193. 8:09you know people listening to this who
  194. 8:11are unfamiliar with machine learning to
  195. 8:13think about how it's used in sort of
  196. 8:16almost everyday life I mean a good
  197. 8:19example of this is probably talking
  198. 8:22about credit card fraud
  199. 8:24detection um and that's not frog not
  200. 8:27frog is in the animal which which I
  201. 8:29always I always say by accident but
  202. 8:31credit card fraud is in someone stealing
  203. 8:33your credit card and using it for their
  204. 8:35nefarious purposes and um obviously this
  205. 8:38is like a huge industry uh detecting
  206. 8:41credit card fraud uh and obviously um
  207. 8:45because oftentimes Banks or or credit
  208. 8:47card companies have to take the hit if
  209. 8:50someone uses a a card improperly because
  210. 8:52a lot of them will have guarantees you
  211. 8:54know generally if someone steals your
  212. 8:56card and uses it for an improper purpose
  213. 8:59purchase generally you can get that
  214. 9:01canell at least in the states I'm not
  215. 9:03sure about you know other regions of the
  216. 9:05world so as a result um credit card
  217. 9:08companies have a very large Financial
  218. 9:11incentive to reduce the amount of fraud
  219. 9:14that goes on and one of the first ways
  220. 9:16to do that and kind of a very kind of
  221. 9:18lowcost algorithmic way to do that is
  222. 9:21just to monitor the transactions that
  223. 9:23are made on the credit card and try to
  224. 9:26pick out which transactions might be
  225. 9:29fraud and so for people who have been
  226. 9:32listening to the previous podcast um you
  227. 9:35might actually remember that we talked
  228. 9:36about classifiers a few different times
  229. 9:39and so we're actually going to return to
  230. 9:41that notion because What's Happening
  231. 9:43Here is a classification problem you
  232. 9:46have in front of you a credit card
  233. 9:49transaction and you would like to
  234. 9:51classify it as fraud or not fraud and so
  235. 9:56in fact this is actually a special case
  236. 9:58of binary classification I think we also
  237. 10:00mentioned this notion of binary
  238. 10:02classification being a very simple form
  239. 10:04of classification in which you only can
  240. 10:05classify into one of two buckets or
  241. 10:08outcomes um and so there's a lot of
  242. 10:11different machine learning algorithms
  243. 10:13that are used for this and again it's
  244. 10:16all about trying to find what patterns
  245. 10:19represent normal use so you might have a
  246. 10:22machine learning algorithm that tells
  247. 10:23you oh well the patterns that represent
  248. 10:26normal use are transactions with a mean
  249. 10:29amount of
  250. 10:31$20 and a standard deviation of
  251. 10:35$30 and they generally happen between
  252. 10:39the hours of 9:00 a.m. and 9:00 p.m. uh
  253. 10:43eastern time for this user and then you
  254. 10:45have all sorts of other details right in
  255. 10:47each transaction you have the amount you
  256. 10:50have where it was made from How It Was
  257. 10:52Made uh you know online or in person you
  258. 10:56have the time it was made um assuming
  259. 10:59usually also have the time zone in which
  260. 11:00it was made probably one or two other
  261. 11:02things like whether it was swiped or or
  262. 11:04on chip and so you have basically for
  263. 11:06each
  264. 11:07transaction a bunch of little
  265. 11:09measurements and the algorithms look
  266. 11:12through those measurements and they try
  267. 11:13to assign a likelihood to the overall
  268. 11:16transaction based on like how weird
  269. 11:18those measurements are and so this is
  270. 11:21there are many different machine
  271. 11:22learning algorithms that could do
  272. 11:24something like this but this General
  273. 11:26notion of classification is a core to a
  274. 11:30lot of machine learning and I think that
  275. 11:32this is a good illustration of one of
  276. 11:34the common uses do you have anything to
  277. 11:35add to that yeah I mean so it sounds
  278. 11:37like what you're talking about is
  279. 11:39definitely like an example of what we'd
  280. 11:41call supervised machine learning uh be
  281. 11:44because you can usually break out
  282. 11:45machine learning methods all these
  283. 11:46different algorithms into a couple
  284. 11:48different classes themselves uh this is
  285. 11:52supervised and unsupervised machine
  286. 11:54learning so in supervised machine
  287. 11:57learning what you do is you essentially
  288. 12:00hold the algorithm's hand you'll show it
  289. 12:02hey here's all this data and this is
  290. 12:05what it is it's like I I have this
  291. 12:08transaction at this time and all this
  292. 12:10and this is fraud or I have this
  293. 12:12transaction at this time from this
  294. 12:14vendor and this is not fraud so you're
  295. 12:17you're in essence teaching it what is
  296. 12:20and isn't fraud by holding its hand
  297. 12:23through a bunch of different examples
  298. 12:25and then you use that trained model to
  299. 12:28predict stuff in the future
  300. 12:30okay so what is unsupervised learning
  301. 12:32just you know going to the other side of
  302. 12:34the spectrum so that's more uh when you
  303. 12:37just take all this data and you let the
  304. 12:39machine go ham like you just have an
  305. 12:42algorithm and it looks for patterns it
  306. 12:44doesn't know what it's looking for
  307. 12:45nothing's really particularly labeled
  308. 12:48this could be something like using the
  309. 12:51semi Central example of credit card
  310. 12:52fraud right there's some whole
  311. 12:55collection of behavior right and at some
  312. 12:58point in this Behavior there's a
  313. 13:00shift so someone and and would basically
  314. 13:04hypothesize that there are two people uh
  315. 13:06or multiple people using the same credit
  316. 13:08card right where we have this initial
  317. 13:11person with their initial behavior and
  318. 13:12at some point the behavior changes and
  319. 13:15that would be kind of a warning thing
  320. 13:17and that's not really looking at what is
  321. 13:20or isn't fraud that's looking for some
  322. 13:22sudden burst in purchases or some sudden
  323. 13:26uh new information that we haven't
  324. 13:29really experienced before that is
  325. 13:30outside the wealth of what we've already
  326. 13:32had to deal with so that would be
  327. 13:34another way to Market fraud instead of
  328. 13:36looking at individual transactions and
  329. 13:38marking them fraud or not I think a good
  330. 13:40like very simple intuitive example of
  331. 13:42this might be that an unsupervised
  332. 13:44machine learning model might look at
  333. 13:46your credit card transactions and say
  334. 13:4995% of your credit card transactions
  335. 13:53have a value of between and
  336. 13:56$200 right and so if you look at the
  337. 13:59value of a credit card transaction and
  338. 14:02it's outside of you know it's above 100
  339. 14:04it's above
  340. 14:05$200 um that represents you know kind of
  341. 14:09an uncommon event it's a rare event and
  342. 14:12that's some evidence towards the fact
  343. 14:14that it might be fraud you probably
  344. 14:16wouldn't immediately flag it as fraud
  345. 14:18just because of that one occurrence and
  346. 14:20so um what another big thing that
  347. 14:23machine learning algorithms do is they
  348. 14:24usually try to kind of com find patterns
  349. 14:27across multiple different variables so
  350. 14:30in this case one variable is the price
  351. 14:33you know of the transaction another
  352. 14:35variable is the time at which it's made
  353. 14:37and let's say in our for our purposes a
  354. 14:38third variable is the location at which
  355. 14:41it's made and so for each one you know a
  356. 14:44machine learning algorithm might say
  357. 14:45okay well 95% of transactions are
  358. 14:47between $1 and
  359. 14:48$200 um 95% of them are made within 10
  360. 14:52miles of this location probably your
  361. 14:54home uh and 95% of them are made between
  362. 14:589:00 a.m. and 9 p.m uh your time zone
  363. 15:01and so if you see a transaction which is
  364. 15:02$300 but within 10 miles of your home
  365. 15:05and within 9:00 a.m. and 9:00 p.m. in
  366. 15:07your time zone Pro you know maybe that's
  367. 15:09not enough evidence to flag it um but
  368. 15:10then if you see a transaction which is
  369. 15:13$1,000 and it's 50 miles away from your
  370. 15:15T from your hometown and it's 3:00 a.m.
  371. 15:19your time that's a good amount of
  372. 15:21evidence that you want to flag it so
  373. 15:22really what machine learning algorithms
  374. 15:24will do is try to find these patterns
  375. 15:26try to figure out what is kind of normal
  376. 15:28behavior variables and then look for
  377. 15:30examples which fall outside of those
  378. 15:32bounds yeah no I think that's a really
  379. 15:34good summary and I I really do like the
  380. 15:37example of you know credit card fraud
  381. 15:39detection while we're talking about
  382. 15:42supervised and unsupervised machine
  383. 15:44learning I don't know if this is maybe
  384. 15:45getting a little bit ahead of ourselves
  385. 15:47for where we want to be right now in
  386. 15:48this episode but when is it right to use
  387. 15:52supervised versus unsupervised machine
  388. 15:55learning algorithms well it really
  389. 15:57depends on what you're going for right
  390. 16:00so if if you have an idea of how things
  391. 16:04are if you have an idea of the different
  392. 16:06classes that you're looking at uh in
  393. 16:08credit card fraud still you have fraud
  394. 16:10or not fraud uh so if you know what your
  395. 16:14classes are going to be then well
  396. 16:17there's really no harm in using a super
  397. 16:18supervised algorithm where you're
  398. 16:20basically providing the inputs and
  399. 16:22you're providing the outputs at the same
  400. 16:24time and using this in order to train
  401. 16:25the model but but if you're looking for
  402. 16:27something uh if you just have a bunch of
  403. 16:29unlabeled data and you want to learn
  404. 16:31something interesting about it uh look
  405. 16:33for any particular clusters or um uh
  406. 16:37different uh groups of behavior within
  407. 16:40this big data set uh that's more of an
  408. 16:42unsupervised learning problem so I I
  409. 16:44alluded a bit to uh this kind of shift
  410. 16:48um in uh in Behavior so that that's one
  411. 16:52what that's one uh thing that we could
  412. 16:56learn uh about a data set just by
  413. 16:58running it through like uh something
  414. 17:00called a mixture model right uh if we
  415. 17:02don't know how many classes there are
  416. 17:04but we suspect that there may be uh a
  417. 17:08few different things going on what we
  418. 17:09would do is we would try to run it
  419. 17:10through a mixture model uh uh which is
  420. 17:13an unsupervised learning algorithm and
  421. 17:14see if it will group things into
  422. 17:16particular sections okay yeah that makes
  423. 17:19sense now Delaney right at the beginning
  424. 17:22you described um you said there's a lot
  425. 17:24of a hype around uh machine learning at
  426. 17:27the moment you I think you just
  427. 17:28described it as being a hype Circle um
  428. 17:31hype cycle hype cycle um why are people
  429. 17:34so excited about machine learning right
  430. 17:37now particularly in the trading and
  431. 17:39investing
  432. 17:40space well I think there's a lot of
  433. 17:42reasons I think um machine learning is
  434. 17:44something that has been being developed
  435. 17:46in the computer science math and stats
  436. 17:49academic disciplines for I don't know
  437. 17:51maybe 30 to 60 years now seriously a lot
  438. 17:55of it has really just been enabled by
  439. 17:56modern Computing um there's a lot of
  440. 17:59techniques that just would not be
  441. 18:01possible without kind of chips that were
  442. 18:04fast and because you know a lot of these
  443. 18:06machine learning methods have take a lot
  444. 18:08of computational power they require many
  445. 18:10iterations many training Cycles so as a
  446. 18:13result you know it's only kind of
  447. 18:14recently that it's really started to
  448. 18:16take off because uh consumer Hardware
  449. 18:19has gotten fast enough to support um
  450. 18:21machine learning algorithms um on the
  451. 18:24other hand we're also in this I believe
  452. 18:26a hype cycle around uh kind of data
  453. 18:29science in general in which uh there's
  454. 18:31just a lot of interest in data science a
  455. 18:33lot of companies are trying to turn to
  456. 18:35data science to understand what's going
  457. 18:37on at the company they're collecting
  458. 18:39tons of data now like pretty much every
  459. 18:41every electronic device is spewing out
  460. 18:43data at this point and so a lot of
  461. 18:46people are trying to use it to make
  462. 18:47their lives better to make better
  463. 18:49decisions um and you know machine
  464. 18:51learning is just kind of a really key
  465. 18:53component of what is known as modern
  466. 18:56data science and so lot of people also
  467. 19:00gravitate towards it because it's just
  468. 19:01kind of it's it's the flashiest part of
  469. 19:05statistics and data science to a lot of
  470. 19:07people um nobody wants to go and learn
  471. 19:11how to uh you know check their standard
  472. 19:14errors on a regression model accurately
  473. 19:16in the presence of something boring like
  474. 19:18heteroscedasticity but you know if
  475. 19:20someone talk comes and tells you that
  476. 19:22they have this crazy new algorithm which
  477. 19:24mimics the way that the human brain
  478. 19:26works and can detect any pattern you
  479. 19:29want in an unsupervised learning like
  480. 19:31there's just there's there's there's so
  481. 19:33much more flash factor with machine
  482. 19:36learning than kind of traditional
  483. 19:37statistics that I think a lot of people
  484. 19:39are just drawn to it and so a lot of
  485. 19:41people even who haven't like really done
  486. 19:43the core of Statistics that you need to
  487. 19:46validate these models that are put out
  488. 19:47by Machine learning algorithms are
  489. 19:49jumping into the field and it can be a
  490. 19:51little dangerous because you have people
  491. 19:52who are using it who might not be as
  492. 19:54familiar with the techniques to know
  493. 19:56whether it makes any sense or not um
  494. 19:59something else I just wanted to say is
  495. 20:02uh with the uh unsupervised learning
  496. 20:04example I think another uh important
  497. 20:06distinction is if you're dealing with
  498. 20:07data for which you don't know the answer
  499. 20:11um that's a case in which you usually
  500. 20:12want to use unsupervised learning uh so
  501. 20:15for example if you had a bunch of credit
  502. 20:18card transactions but you actually
  503. 20:19didn't know which ones were fraud and
  504. 20:22you wanted to Look Backwards um
  505. 20:24sometimes you need because you just
  506. 20:25don't know the answer you have to you
  507. 20:28there's no way to supervise it you can't
  508. 20:30say this is fraud this is not fraud this
  509. 20:32is fraud this is not fraud um but if you
  510. 20:35had examples of uh credit card
  511. 20:38transactions which were uh grouped into
  512. 20:41stuff you knew was fraud historically
  513. 20:42and stuff you knew you know you you knew
  514. 20:44was not fraud um then that's a different
  515. 20:47situation and you can do different types
  516. 20:48of stuff with that okay sure so even
  517. 20:52with the flash Factor does machine
  518. 20:54learning bring anything new compared to
  519. 20:57uh traditional statistics
  520. 21:00methods I think it absolutely does and
  521. 21:03and the way I view machine learning is
  522. 21:04it's like machine learning is really
  523. 21:06kind of like a gun it's like it's really
  524. 21:09powerful when used correctly um but it's
  525. 21:13also really easy to to do serious harm
  526. 21:15to yourself if used improperly and the
  527. 21:18serious harm of course is if you have a
  528. 21:20machine learning algorithm and it spits
  529. 21:21out something that looks really good
  530. 21:23which machine learning algorithms will
  531. 21:25tend to do and and we can go into this a
  532. 21:27bit more later but
  533. 21:29machine learning algorithms are really
  534. 21:31really good at fitting data and so
  535. 21:33they're really really good at
  536. 21:34overfitting if you're if you're not
  537. 21:35careful and there was a result
  538. 21:37oftentimes if you apply machine learning
  539. 21:38to something you'll get models that look
  540. 21:41so good on the data set you train them
  541. 21:43on they look like perfect they can
  542. 21:45predict everything that happened um and
  543. 21:47as a result you get this amazing
  544. 21:49confidence in your ability to predict
  545. 21:51things going forward uh and of course
  546. 21:53like just like any other statistical
  547. 21:55method if you haven't done your proper
  548. 21:57validation um you know you could
  549. 21:58completely fall apart out of sample and
  550. 22:01and and blow up and of course in finance
  551. 22:02that's a particularly big risk because
  552. 22:04it could be that you lose a substantial
  553. 22:06amount of money um but that said uh the
  554. 22:10kind of broad uh Power that machine
  555. 22:12learning algorithms have to deal with
  556. 22:15new types of data um do bring a lot of
  557. 22:19new things to the table in in in finance
  558. 22:22and I think that there are some really
  559. 22:23good uses of machine learning and
  560. 22:25finance and some dangerous uses so like
  561. 22:28uh you know some of the stuff we're
  562. 22:29going to talk about as we go on today is
  563. 22:31what some of the broad good cases are um
  564. 22:34and some of the broad maybe you don't
  565. 22:37really want to use it this way cases are
  566. 22:39um and so maybe we can just start with
  567. 22:42an example um which I I have a fun I
  568. 22:44have a fun uh a fun metaphor all ready
  569. 22:47to go and talking about unstructured
  570. 22:49data go for it yeah well let's let's go
  571. 22:51into some of those good usages and poor
  572. 22:54usages of machine learning like when is
  573. 22:56it powerful and when is it not so much
  574. 23:00yeah so I'm going to give a shout out
  575. 23:02here uh so one of the first um
  576. 23:05professors that uh we ever worked with
  577. 23:07at quantopian his name is Andre keno and
  578. 23:10if you Google search him you'll actually
  579. 23:12find a Russian professional basketball
  580. 23:14player so you have to like Google search
  581. 23:16Andre koleno Finance um or or or
  582. 23:20something uh but he's a he's actually he
  583. 23:23a really smart guy um he uh used to be
  584. 23:27the chief economist at the Commodities
  585. 23:29and Futures Trading commission uh here
  586. 23:31in the US um and and was teaching at MIT
  587. 23:34when uh when we met him he's now
  588. 23:37actually um running a new program I
  589. 23:39believe at uh Imperial College London
  590. 23:43which I recommend if any of your
  591. 23:44listeners are are are in London
  592. 23:46interested in some kind of um Finance
  593. 23:49program I definitely recommend you check
  594. 23:50it out he's he's he he really knows this
  595. 23:52stuff well and and one of the things
  596. 23:54that most impressed me uh was just like
  597. 23:56how much he focused on this statistical
  598. 23:59rigor when he was teaching because he
  599. 24:01was teaching a lot of people who had
  600. 24:02heard about these crazy new techniques
  601. 24:04who did want to do this stuff um and and
  602. 24:06he was really good about making sure
  603. 24:08that you know they came away with with
  604. 24:10good and bad examples and he had some
  605. 24:12good like kind of very visual stories of
  606. 24:15uh explaining some of these Concepts and
  607. 24:17so I'm going to use one of his right now
  608. 24:19which is um there's a preponderance now
  609. 24:23of what I call unstructured data and
  610. 24:27what that means is you get data that
  611. 24:29really has no well no structure to it
  612. 24:32you're you're getting data let's an
  613. 24:34example might be headlines news
  614. 24:35headlines right there's no structure of
  615. 24:38a news headline every reporter writes
  616. 24:41theirs differently um yeah there's going
  617. 24:43to be structure in the the language you
  618. 24:45know let's say that you're looking at
  619. 24:46just English news headlines well there's
  620. 24:48going to be structure because English
  621. 24:50has a structure but beyond that that
  622. 24:52even might be pretty weak because news
  623. 24:54headlines use a lot of slang they use a
  624. 24:56lot of shortening like headlines have
  625. 24:57their own language right they kind of
  626. 24:59drop words as appropriate to fit the
  627. 25:00headline onto the page um and so you're
  628. 25:04looking at a headline and you're trying
  629. 25:06to learn information from those
  630. 25:08headlines the the the metaphor that that
  631. 25:11uh Andre Keno likes to use for this is
  632. 25:14um imagine that your data source um is
  633. 25:18the garbage that's coming out of a of a
  634. 25:21of a coffee shop right so you're you're
  635. 25:23in the back alley and every time they
  636. 25:26dump their garbage out you you take
  637. 25:27their garbage and you're trying to learn
  638. 25:29as much as you can about the workings of
  639. 25:31the coffee shop from the garbage and and
  640. 25:33this is actually a really good metaphor
  641. 25:35to understand how not only unstructured
  642. 25:38data often is but kind of how um machine
  643. 25:42learning algorithms can oftentimes be
  644. 25:44powerful because what you have there is
  645. 25:46you have well what are you trying to
  646. 25:47learn about well let's let's kind of try
  647. 25:49to get a sense of what data you might
  648. 25:51have you're going to have obviously like
  649. 25:53coffee cups and maybe you have different
  650. 25:55coffee cups because they have different
  651. 25:57types of cups for different drinks you
  652. 25:58know they might have paper cups and
  653. 26:00plastic cups and they have different
  654. 26:02sizes of Cups and some of the cups will
  655. 26:04have a name written on them and some of
  656. 26:06the cups will not have a name written on
  657. 26:08them um some drinks are served in two
  658. 26:10cups and some drinks are served in one
  659. 26:12cup you know they'll double up the cup
  660. 26:13sometimes um some cups come with one of
  661. 26:16the cup holders so you don't get burned
  662. 26:19uh some you'll you'll have sometimes
  663. 26:21you'll have a lid attached to the cup
  664. 26:22sometimes you'll have free floating Lids
  665. 26:24sometimes you won't have a lid at all
  666. 26:25for cups so you can get a sense and then
  667. 26:27and of that's all floating in a whole
  668. 26:30like other garbage right so there even
  669. 26:32even like information you might want to
  670. 26:34get at like stuff like what type of Cups
  671. 26:35you're looking at trying to reverse
  672. 26:36engineer what type of drinks the coffee
  673. 26:38shop is serving let's say that's all
  674. 26:41floating in like a whole bunch of other
  675. 26:42garbage from like food or or or napkins
  676. 26:46or whatever so you're sitting there and
  677. 26:48and this is actually really close to
  678. 26:50when um quantitative professionals
  679. 26:52whether they be in finance or other
  680. 26:53fields are looking at unstructured data
  681. 26:55that's flowing in from The Real World
  682. 26:57often times you need to do a data
  683. 26:59processing step and so a huge part of
  684. 27:01modern kind of data science and and
  685. 27:03oftentimes what will set apart someone
  686. 27:06who has data science on the resume from
  687. 27:07like someone who says statistics is this
  688. 27:09notion of cleaning the data and and
  689. 27:11getting the data into a usable format um
  690. 27:14and that would involve like you know
  691. 27:16sorting out your garbage and okay now
  692. 27:17you have a pile of Cups and then you
  693. 27:19start counting the cups and you you make
  694. 27:21notes of this cup came with another cup
  695. 27:23this cup came with a lid this cup came
  696. 27:25with a name and then that kind of dat
  697. 27:28which isn't necessarily all the same
  698. 27:31format you're going to have a lot of
  699. 27:33null values in there lots of different
  700. 27:35weird stuff this is where machine
  701. 27:38learning can be really powerful in
  702. 27:40getting you somewhere useful because
  703. 27:42what machine learning methods will do
  704. 27:44especially the unsupervised ones that
  705. 27:46Max was talking about is they will kind
  706. 27:49of from that be able to start giving you
  707. 27:52initial ideas about the broad trends
  708. 27:55that might be present uh and they might
  709. 27:57what you can do is you can start saying
  710. 27:59uh look at each individual K piece of
  711. 28:01garbage and try to classify it as one
  712. 28:04thing or another based on this you know
  713. 28:06learning that you're doing um and and
  714. 28:09and this is the type of situation often
  715. 28:11times that machine learning is very
  716. 28:13powerful at um because a lot of the
  717. 28:15algorithms are actually designed to work
  718. 28:18in these kind of unstructured data
  719. 28:20scenarios okay is there anything you
  720. 28:21want to add on to that Max or should we
  721. 28:23keep moving yeah I think that's a
  722. 28:26delightful example
  723. 28:28sometimes your cups are actually
  724. 28:31Forks so let's continue on this point
  725. 28:34what are some good usages and also some
  726. 28:36poor usages of machine learning like in
  727. 28:39a trading sense in a finance sense I'll
  728. 28:42quickly give one more kind of follow on
  729. 28:45so I think we actually probably talked
  730. 28:47about this before but like the the
  731. 28:49favorite uh the favorite example and and
  732. 28:52and I'm pretty sure we've talked about
  733. 28:54this briefly in one of the one of the
  734. 28:55previous episodes is using um computer
  735. 28:59vision uh to analyze images uh namely
  736. 29:03satellite images right and so if you
  737. 29:07have satellite images of parking lots
  738. 29:10and you use uh computer vision which is
  739. 29:13often times models that are trained
  740. 29:15using some form of machine learning
  741. 29:17you'll have like these classifiers that
  742. 29:19look at these images and they attempt to
  743. 29:22like first of all catalog okay split the
  744. 29:24image into objects that's one of the
  745. 29:26problems and then the next is for each
  746. 29:28object classify it as a thing um and
  747. 29:31this is actually a problem that we've
  748. 29:32gotten pretty good at um Google
  749. 29:35especially has been one of the companies
  750. 29:36that's like really I think been ahead of
  751. 29:39the curve and in designing um computer
  752. 29:42computer vision Technologies and so as a
  753. 29:44result nowadays we actually have
  754. 29:46open-source computer vision libraries um
  755. 29:49that actually work pretty well for just
  756. 29:51saying this is a car this is a cat this
  757. 29:55is a person and it's because they've
  758. 29:57just trained these models on like so
  759. 30:00many tens of thousands of examples of
  760. 30:02things that are people and things that
  761. 30:04are close to looking like people but are
  762. 30:06not people and the algorithm has learned
  763. 30:08the rules for differentiating the two
  764. 30:10and so what you can do is you can take
  765. 30:11these models that have been developed
  766. 30:13and apply them to these images and count
  767. 30:15how many cars are in the parking lots
  768. 30:17and then use that to try to forecast
  769. 30:18sales figures for for retail chains so
  770. 30:22that's an example of taking you know
  771. 30:23unstructured data which is in the form
  772. 30:25of images and turning it into an actual
  773. 30:28score which is like cars outside each
  774. 30:31retail chain for each
  775. 30:32quarter okay so what would be a poor
  776. 30:35usage of machine learning in a in a
  777. 30:37trading sense we mentioned a little bit
  778. 30:40about how it's really easy to overfit
  779. 30:42with machine learning and one of the
  780. 30:45very fun things about financial data
  781. 30:47especially like price data is that it's
  782. 30:50really really noisy it's Jagged it's
  783. 30:54ugly it's contorted it doesn't follow
  784. 30:56any nice assumptions so
  785. 30:58why why not just forego the assumptions
  786. 31:00entirely and use a machine learning
  787. 31:01model in order to predict prices uh the
  788. 31:04issue with this is because machine
  789. 31:05learning models are so flexible and
  790. 31:07because they're so good at fitting the
  791. 31:08data they'll contort exactly to fit this
  792. 31:12noise and then going forward you're just
  793. 31:16you're there whenever you have any sort
  794. 31:18of process in real life
  795. 31:22um yes so whenever you have any sort of
  796. 31:24process in real life there's always some
  797. 31:26true underlying
  798. 31:28thing driving it there there's some
  799. 31:31underlying process that makes it all
  800. 31:33work together and whenever you build a
  801. 31:34model you're trying to infer that
  802. 31:37underlying process from the data at
  803. 31:40large but if you fit perfectly to the
  804. 31:44data since it's real life data there's
  805. 31:46going to be a lot of noise involved so
  806. 31:48you're just contorting it to fit what
  807. 31:50you actually see instead of getting any
  808. 31:51actual information about what's actually
  809. 31:53there so when you then go out of sample
  810. 31:56and try to use this in order to predict
  811. 31:59any sort of future prices it's just
  812. 32:01going to be garbage okay is there any
  813. 32:03way you can use it to predict or attempt
  814. 32:06to predict future prices without it
  815. 32:09being garbage like are
  816. 32:10there is there a way that it can be used
  817. 32:14uh for for forecasting prices or is it
  818. 32:16best used in you know the examples we've
  819. 32:19talked about like you know if you want
  820. 32:21to use satellite imagery as an example
  821. 32:24like actually using it to read images so
  822. 32:28there's I think that um it certainly can
  823. 32:31I I think that that would probably be
  824. 32:33considered like the most advanced use
  825. 32:35case of of machine learning in in in
  826. 32:37finance it would be actually using it
  827. 32:39directly as a price forecasting model um
  828. 32:44and that's just because again I think
  829. 32:45that that given like the problem you're
  830. 32:48trying to solve and the nature of the
  831. 32:49data and the system producing the data
  832. 32:51that's just the riskiest application and
  833. 32:54so you need to have kind of the the best
  834. 32:57experience and and steadiest hand to be
  835. 32:59able to do something like that so I
  836. 33:01would say that would not be my
  837. 33:02recommendation as the first place to
  838. 33:04start playing with machine learning and
  839. 33:06finance um although for I think for a
  840. 33:09lot of people it's the first like
  841. 33:10intuitive it's the most intuitive place
  842. 33:12to try to use it is just to predict
  843. 33:14prices because that's you know that's
  844. 33:16kind of it's that seems like the best
  845. 33:17idea off the bat but I would actually
  846. 33:19say that's kind of probably the LA one
  847. 33:21of the one of the last places you want
  848. 33:22to try using it and not in the sense
  849. 33:24that it's not going to work but um I
  850. 33:27mean I don't in any individual case I
  851. 33:29don't know if it's going to work I don't
  852. 33:31want to tell you that these things are
  853. 33:32going to be like definitely bad or
  854. 33:34definitely good what I do want to say is
  855. 33:36just like you want to apply the same
  856. 33:39model validation principles to whatever
  857. 33:41the machine learning algorithm is
  858. 33:43spitting out as you would to anything
  859. 33:45else so a lot of the stuff that we
  860. 33:46talked about in the first episode when
  861. 33:48we talked about biases and ways to be
  862. 33:50wrong without knowing you're wrong um
  863. 33:52you want to watch out for those same
  864. 33:54things with machine learning and for
  865. 33:56machine and and for machine learning
  866. 33:57some of those are especially especially
  867. 33:59common so um I'll give you an example of
  868. 34:02something that I might do here which is
  869. 34:04let's say that I had a data file of uh
  870. 34:09let's say I had a data file of um 60
  871. 34:13variables that I was recording all the
  872. 34:15time and I wanted to use these 60
  873. 34:17variables to uh predict the price of
  874. 34:21some stock some asset and so what I
  875. 34:24might do is I might um use machine
  876. 34:28learning to basically try to guess some
  877. 34:32variables that might be good variables
  878. 34:34to use in a model to predict price of
  879. 34:37this asset so the machine learning
  880. 34:38algorithm would look at um my you know
  881. 34:41data set of 60 variables going back in
  882. 34:43time it would look at the price of the
  883. 34:45asset that I wanted to predict and it
  884. 34:46would try to come up with some set of
  885. 34:49variables hopefully a smaller set you
  886. 34:51know it try to come up with maybe like
  887. 34:52five variables two to five variables
  888. 34:55that predict the price of my asset uh
  889. 34:58well and and this use of machine
  890. 35:00learning is is known as dimensionality
  891. 35:02reduction um in in uh in data science
  892. 35:05and it's especially common in a field
  893. 35:07where I used to work which is
  894. 35:09bioinformatics uh in which you have um
  895. 35:12millions of genes and you want to figure
  896. 35:15out which genes are associated with
  897. 35:17diseases and so you can't of you just
  898. 35:20can't look at all the genes at once so
  899. 35:22you need to use filtering methods to
  900. 35:25filter down to small sets of genes for
  901. 35:27kind of more in-depth analysis and yeah
  902. 35:29you might throw the good ones out when
  903. 35:32you're using the filtering method but
  904. 35:33that's just a risk that you're going to
  905. 35:34have to take because if you're the
  906. 35:37amount of analysis you can really do is
  907. 35:39in maybe like 20 genes maximum at a time
  908. 35:42um for variety of reasons statistical
  909. 35:44and computational limitations so if I
  910. 35:46have like 60 variables and I'm trying to
  911. 35:48predict the price of some asset I might
  912. 35:50use a machine learning algorithm to
  913. 35:52filter myself down to a set of say five
  914. 35:54variables and then construct a simple
  915. 35:57model based on those five variables and
  916. 36:00from there on just validate it the same
  917. 36:02way I would anything else so in this
  918. 36:04case I'm using machine learning to try
  919. 36:05of inform my model selection but the
  920. 36:07model itself is still a very simple uh
  921. 36:11model probably just like a linear
  922. 36:12regression a linear combination model or
  923. 36:14something like that so that that's an
  924. 36:16example of how I might go about um using
  925. 36:20uh machine learning to try to forecast
  926. 36:23price although obviously like in any
  927. 36:25individual case I have no idea if it's
  928. 36:27going to work okay now you said
  929. 36:29something towards the end there which I
  930. 36:31think might be key and I just I'd love
  931. 36:34it if you could expand on that a little
  932. 36:35bit how important is it to try and keep
  933. 36:38the model itself simple like even when
  934. 36:40using machine learning techniques is it
  935. 36:43like like how important is it to keep
  936. 36:45things
  937. 36:46simple so Simplicity is kind of like the
  938. 36:50Crux of everything that you're trying to
  939. 36:51get out with a model because you want it
  940. 36:53to be General is the idea like you want
  941. 36:57it to trained well on the data that you
  942. 37:00already have the things that you know
  943. 37:01about but you want that model to be
  944. 37:04General enough to still be extensible to
  945. 37:06any sorts of new information like this
  946. 37:09is part of the issue uh with like
  947. 37:10fitting to noise that I was talking
  948. 37:12about before like if you're fitting to
  949. 37:13the noise of a very particular data set
  950. 37:16uh of data that you already have that
  951. 37:19noise is going to be different in the
  952. 37:21future it's it's going to change so if
  953. 37:23you're incorporating the noise as an
  954. 37:25integral part of the model if you're
  955. 37:26making it more complex
  956. 37:28as a result of the noise you're making
  957. 37:30your model less General so there's
  958. 37:32actually a bunch of different methods in
  959. 37:34order to kind of determine whether your
  960. 37:37model is too complex or uh as simple as
  961. 37:42it could be and it comes down to a lot
  962. 37:44of the same things that we use in like
  963. 37:45normal statistical models um because
  964. 37:48this is something that we want to look
  965. 37:49at with normal statistical models as
  966. 37:51well we generally want General models
  967. 37:53that are relatively simple and explain
  968. 37:55as much information as possible with as
  969. 37:57few terms as we can so we'll we'll
  970. 38:00conduct a lot of testing with our
  971. 38:02machine learning models in order to kind
  972. 38:04of penalize any sort of complexity to
  973. 38:06rein in any sort of extra complexity so
  974. 38:09that they don't go off the rails or do
  975. 38:11anything weird okay I was just going to
  976. 38:14say like kind of two points one just to
  977. 38:16Circle back to points we made before out
  978. 38:18of sample testing is is really important
  979. 38:22because without like if you if you come
  980. 38:25up with some model even if it's seems
  981. 38:27simple unless you have saved some of the
  982. 38:30data to test on like your model is going
  983. 38:33to be built on the data you've already
  984. 38:34seen so of course it's going to work
  985. 38:36well on the data you've already seen you
  986. 38:37know it's it's like uh if you teach
  987. 38:40someone to drive on a small section of
  988. 38:42roads in in some one small town yeah
  989. 38:45they maybe they'll get good at those
  990. 38:46roads but then when you let them loose
  991. 38:48on like a highway it's it's not going to
  992. 38:50work very well so um you know you you
  993. 38:53generally want to to make sure that when
  994. 38:55you're actually evaluating your model
  995. 38:56you want to use data you have not seen
  996. 38:58before preferably new data data that
  997. 38:59You' kept separate purely for the
  998. 39:01purpose of testing your model and then
  999. 39:03as soon as you see it it stops being out
  1000. 39:05of sample data anymore now you know
  1001. 39:06you've seen it it's done it's it's it's
  1002. 39:08used so that's just an important
  1003. 39:09principle that that I think uh is still
  1004. 39:12required when you're doing um you know
  1005. 39:15any kind of Statistics especially
  1006. 39:17machine learning and uh you know there
  1007. 39:20are some people who might argue that AOS
  1008. 39:22sample testing is not always strictly
  1009. 39:24necessary and I would say that if you're
  1010. 39:26at a point in your sta iCal knowledge
  1011. 39:28when you can argue that with me I you
  1012. 39:30don't need my help you can go off and do
  1013. 39:32whatever you want um so uh but and then
  1014. 39:36the other thing is just really like yeah
  1015. 39:38in terms of like model Simplicity again
  1016. 39:41like the goal of models is really to be
  1017. 39:42as simple as possible because if you
  1018. 39:44look at what physicists are trying to do
  1019. 39:46when they're trying to explain the
  1020. 39:47universe right they're looking for like
  1021. 39:49very simple broad explanations that
  1022. 39:52capture large amounts of behavior and
  1023. 39:55all like basically like no body in
  1024. 39:57physics um tries to come up with uh a
  1025. 40:01model which is based on 300 variables
  1026. 40:03and precisely explains the motion of
  1027. 40:05some asteroid because most likely that
  1028. 40:07model is going to be wrong for reasons
  1029. 40:08of of overfitting you just can't check
  1030. 40:10it um you have so much you have so
  1031. 40:13limited data in general the more
  1032. 40:14variables you have in the model the more
  1033. 40:16complexity you actually need
  1034. 40:17exponentially more data to check whether
  1035. 40:20that model makes sense so as a result
  1036. 40:22physicists always try to come up with
  1037. 40:23models that have like one or two
  1038. 40:25variables very simple effects um and and
  1039. 40:28explain a wide variety of phenomena and
  1040. 40:30then you can explain very complex
  1041. 40:32phenomena by building together multiple
  1042. 40:34simple models um into into complex
  1043. 40:37systems um so that's just like a really
  1044. 40:40important point that I I think is
  1045. 40:41important to remember with all this
  1046. 40:42stuff whenever you're trying to think
  1047. 40:44about ways in which you might know more
  1048. 40:46than the Market and Test those you
  1049. 40:48always want to be finding kind of broad
  1050. 40:50behaviors that are expressed by some
  1051. 40:52simple rules and and the opposite of
  1052. 40:55this is what's known as blackbox models
  1053. 40:57which is something we can talk about a
  1054. 40:58little bit more later but um a blackbox
  1055. 41:01model is just a model in which you don't
  1056. 41:03actually understand what's going on
  1057. 41:04inside uh and you know kind of could be
  1058. 41:07anything but you can see the input and
  1059. 41:08output um and those models tend to be
  1060. 41:11very risky and a lot of machine learning
  1061. 41:13algorithms actually put out kind of like
  1062. 41:15spit out blackbox models that really
  1063. 41:17can't be comprehended in any way they
  1064. 41:19just have inputs and outputs and and
  1065. 41:21those those models are very risky
  1066. 41:22because you just have no idea what's
  1067. 41:24going on inside there you don't know how
  1068. 41:25many how many variables they operate on
  1069. 41:28you don't know why they're making the
  1070. 41:29decisions they do and there's just no
  1071. 41:31way to validate it so do you want to
  1072. 41:33talk about why that's an issue with
  1073. 41:35blackbox quote unquote systems like it
  1074. 41:39it probably seems quite obvious to you
  1075. 41:41know you guys but like to for someone
  1076. 41:43who might be sort of new to this sort of
  1077. 41:45thing why why is that dangerous to not
  1078. 41:47really know what's going on inside your
  1079. 41:50black
  1080. 41:50box so part of having a model is you
  1081. 41:54want it to tell a story about your data
  1082. 41:59um so you want it to be in some way
  1083. 42:03understandable by the people that are
  1084. 42:05trying to use the model because that
  1085. 42:06makes it comprehensible if if you can
  1086. 42:08explain the model it means the model
  1087. 42:10likely isn't doing anything bizarre or
  1088. 42:14weird or UNC that you wouldn't
  1089. 42:15necessarily want a model to do so if you
  1090. 42:18have this black box that you're just
  1091. 42:20putting stuff in and putting stuff out
  1092. 42:23uh again it goes back to the same idea
  1093. 42:24of overfitting uh where
  1094. 42:28uh even if you're doing well uh in your
  1095. 42:31out of sample uh in your out of sample
  1096. 42:33data you may not necessarily know why
  1097. 42:35and a lot of times when we're dealing
  1098. 42:36with these models we want to know what's
  1099. 42:39the most important stuff what are the
  1100. 42:41key driving factors and if you can't
  1101. 42:43explain what the key driving factors are
  1102. 42:45in a model uh then it just makes the
  1103. 42:47model just kind of fundamentally less
  1104. 42:49helpful even if you do get the correct
  1105. 42:51answers in the end now Max you've spoken
  1106. 42:55about there being a lot of noise
  1107. 42:58especially in price data you've bought
  1108. 43:00it up a few times I'm just wondering is
  1109. 43:02there any way that you can sort of
  1110. 43:04separate noise from signal if that's the
  1111. 43:07right term when you're looking at data
  1112. 43:10like are there any methods you can use
  1113. 43:12to uh kind of separate the two so it's
  1114. 43:15hard to separate the two directly um
  1115. 43:19basically how we kind of immunize
  1116. 43:21ourselves against these mistakes of
  1117. 43:23dealing with overfitting uh and dealing
  1118. 43:26with uh
  1119. 43:27too much noise is like we have our
  1120. 43:30um we have our out of sample testing but
  1121. 43:33in some cases if we have like too few
  1122. 43:36data points to do out of sample testing
  1123. 43:39like machine learning models tend to use
  1124. 43:41they tend to require a lot of training a
  1125. 43:43lot of data in order to inform them so
  1126. 43:46we can't really break it into like an
  1127. 43:4880% 20% split where we're testing and
  1128. 43:52building our model on 80% of our data
  1129. 43:55and then we're
  1130. 43:57then taking that model and then using it
  1131. 43:59on the out of sample hold out 20%
  1132. 44:02sometimes we just don't have enough data
  1133. 44:03for that kind of stuff so what we'll do
  1134. 44:05in this case is something that we call
  1135. 44:07cross validation which is instead of
  1136. 44:09doing one split we'll do two splits or
  1137. 44:12three splits or four splits or five
  1138. 44:14splits uh or just however so many splits
  1139. 44:17as we desire depending on how uh
  1140. 44:19uncomfortable we are with our small
  1141. 44:21amount of data and what what I mean by a
  1142. 44:23split is we just like say we have 100
  1143. 44:25data points right and that's all we have
  1144. 44:27to work with then what we' do is we'
  1145. 44:29train our we'd say hey we want to do
  1146. 44:33five uh rounds of cross validation so we
  1147. 44:37would in turn take 20% of our data and
  1148. 44:41then take 80% of our data and train that
  1149. 44:44and then test it on the hold out 20%
  1150. 44:46then we'd pick a different 20% of our
  1151. 44:48data and we just keep shifting this
  1152. 44:51block of data that we're training and
  1153. 44:53then testing on in order to kind of
  1154. 44:56simulate a larger amount of data and try
  1155. 44:59to go from there to try to alleviate any
  1156. 45:00effects of particularly noisy data uh
  1157. 45:03which can only be aggravated when you
  1158. 45:05have fewer data points because when you
  1159. 45:07have more data it tends to smooth out
  1160. 45:09this
  1161. 45:10noise and and and what you're looking
  1162. 45:12for there is consistency you want your
  1163. 45:14model to consistently explain what's
  1164. 45:16going on through all the different
  1165. 45:18rounds of training testing training
  1166. 45:20testing because if it stops being able
  1167. 45:22to explain stuff consistently if it
  1168. 45:24picks kind of different patterns each
  1169. 45:26time that's an indication that it's not
  1170. 45:28really picking up on anything consistent
  1171. 45:29in your data set and therefore all it's
  1172. 45:31picking up on is no is noise I I I view
  1173. 45:35kind of cross validation um a little bit
  1174. 45:37as kind of like Poor Man's out of sample
  1175. 45:39testing and that you know it's it's not
  1176. 45:40optimal in many cases but it will help
  1177. 45:43in in in reducing the risk of
  1178. 45:45overfitting I think in general it's
  1179. 45:47really hard to split noise from signal
  1180. 45:50um because if you could split noise from
  1181. 45:52signal you'd know exactly what the
  1182. 45:53signal was and therefore you'd have the
  1183. 45:55answer already uh if you were able to do
  1184. 45:57that I mean one of the simplest ways you
  1185. 45:59can try to get rid of noise is by
  1186. 46:01increasing your sample size uh and then
  1187. 46:04you know averaging everything together
  1188. 46:06you know because if if if the noise is
  1189. 46:08kind of going in both directions
  1190. 46:10randomly and then you average two things
  1191. 46:13together uh you know there's a higher
  1192. 46:15chance that noise will cancel out and if
  1193. 46:16you have a hundred things and you
  1194. 46:17average them all together there's a
  1195. 46:18higher chance that noise will cancel out
  1196. 46:20so often times um just looking at more
  1197. 46:23data is usually a way to try to get rid
  1198. 46:26of noise sometimes though you're
  1199. 46:28constrained into systems in which you
  1200. 46:30have a fixed size there's only a fixed
  1201. 46:32number of of assets on the US market you
  1202. 46:35can't like get more data you know you
  1203. 46:38can't really get more assets per se in
  1204. 46:41that so um you don't always have that
  1205. 46:44luxury yeah yeah now that's a really
  1206. 46:47good point so I think this has been a
  1207. 46:48really good overview of machine learning
  1208. 46:51I'd just like to spend a few minutes and
  1209. 46:52maybe talk a little bit more about how
  1210. 46:54to actually uh go about learning and and
  1211. 46:56maybe implementing some of these things
  1212. 46:59uh does the quantopian platform support
  1213. 47:01machine learning I know you mentioned
  1214. 47:03earlier that it it does take quite a lot
  1215. 47:05of computational uh Power are there any
  1216. 47:08limitations um on the quantopian
  1217. 47:10platform in regard to the use of machine
  1218. 47:13learning certainly I mean we currently
  1219. 47:15have some limitations on the platform um
  1220. 47:18however and and we we'll link to these
  1221. 47:21uh examples uh quantopian dcom chatwi
  1222. 47:25Traders we'll have for all the episodes
  1223. 47:27listed out um and and and for the
  1224. 47:30machine learning episode we're going to
  1225. 47:31link to some examples of actual
  1226. 47:34implementations of machine learning um
  1227. 47:38for I believe Factor aggregation which
  1228. 47:42is something we talked about in the
  1229. 47:43previous episode so using machine
  1230. 47:45learning algorithm to try to construct
  1231. 47:48one overall factor from a variety of
  1232. 47:50input Alpha factors uh and I I'm
  1233. 47:54actually not sure of the second I think
  1234. 47:55the second one is actually using it as a
  1235. 47:57a factor itself as a as a price
  1236. 47:59forecasting model so the thing I said
  1237. 48:01was the hardest kind of most dangerous
  1238. 48:03thing to do so those were both uh
  1239. 48:05examples made by um mostly Thomas I
  1240. 48:09believe uh I'm not sure did you take a
  1241. 48:11look at those Max or is that mostly
  1242. 48:12Thomas in his cave who pump pumped those
  1243. 48:14out yeah that was Thomas and James
  1244. 48:16Thomas and James so Thomas and James
  1245. 48:18Christopher um but so we'll have
  1246. 48:20examples uh listed for actually like how
  1247. 48:23you would do that in the quantopian
  1248. 48:24platform um currently it's kind of hard
  1249. 48:27to actually put the uh machine learning
  1250. 48:31methodology into a trading algorithm but
  1251. 48:33within our research environment which is
  1252. 48:35kind of offline analysis and hypothesis
  1253. 48:38testing and statistics uh you can do
  1254. 48:40actually quite a wide variety of um
  1255. 48:43machine learning stuff nothing that's
  1256. 48:45going to take like there's some
  1257. 48:46algorithms that just take like huge
  1258. 48:48amounts of memory and computational time
  1259. 48:50and and those currently you you you
  1260. 48:52can't use but a lot of the machine
  1261. 48:54learning algorithms just because
  1262. 48:55consumer Hardware is gotten so fast
  1263. 48:57these days actually run fairly quickly
  1264. 49:00um and so you can do some pretty
  1265. 49:01advanced stuff um as far as you know a
  1266. 49:05lot of the cases that I was talking
  1267. 49:06about like you know looking at trying to
  1268. 49:08parse unstructured data or select
  1269. 49:11factors for your model or aggregate um
  1270. 49:14Alpha factors that kind of stuff and
  1271. 49:16we're working constantly on trying to
  1272. 49:18enable more support for more types of of
  1273. 49:21machine learning and just other use
  1274. 49:23cases on the platform yeah I I know I'm
  1275. 49:25going to be working on a
  1276. 49:27lectures teaching machine learning at
  1277. 49:29some point uh and just as part of our
  1278. 49:31research environment we allow you to use
  1279. 49:34uh psyit learn which is a very popular
  1280. 49:36uh uh package in Python which has just a
  1281. 49:40very large number of classifiers
  1282. 49:43estimators and their documentation is
  1283. 49:45really fantastic and it's a good place
  1284. 49:46to get started with learning how to
  1285. 49:48actually use the methods yeah I was
  1286. 49:49going to ask you about that actually
  1287. 49:51because psyit learn is the main library
  1288. 49:54or or package uh for python for machine
  1289. 49:57learning right are there any other uh
  1290. 49:59packages or libraries that that you'd
  1291. 50:00suggest for this as well or is that
  1292. 50:04probably enough to get started at least
  1293. 50:07I mean I know there are I don't know off
  1294. 50:09the top of my head um like I'm not
  1295. 50:12someone who uh like i' I've done I've
  1296. 50:16done my I've done my time in the machine
  1297. 50:18learning minds but I'm not currently
  1298. 50:20using this dayto day and and and python
  1299. 50:22moves so fast that I'm sure that since
  1300. 50:24I've touched it there are many libraries
  1301. 50:27that have popped up which do tons of
  1302. 50:28interesting stuff with machine learning
  1303. 50:30tons of forks of various other libraries
  1304. 50:33and and you know it there's so much work
  1305. 50:36going on right now in Python so I
  1306. 50:38couldn't tell you right off the top of
  1307. 50:40my head if there other libraries Max
  1308. 50:41might know a few others that are that
  1309. 50:43are good but um I think uh scikit learn
  1310. 50:46also NN what is it what's the the modu
  1311. 50:49module is actually SK learn it's like
  1312. 50:51yeah so I think some some people
  1313. 50:53probably know as like sklearn I think
  1314. 50:55it's like the flagship uh library in
  1315. 50:57Python that really will will get like
  1316. 51:00you know 80 to 90% of your use cases
  1317. 51:02done out of the box yeah there's tensor
  1318. 51:06flow but that's a little weirder yeah
  1319. 51:07there's tensor flow which is like a
  1320. 51:09whole new like a whole new world we're
  1321. 51:11talking about hype Cycles there's this
  1322. 51:12little like mini hype cycle going on
  1323. 51:14around tensor computations which are
  1324. 51:17used I believe for calculating
  1325. 51:18covariance matrices which I'm not even
  1326. 51:20going to get into right now but that's
  1327. 51:22like a whole a whole little subfield of
  1328. 51:24machine learning that has popped up
  1329. 51:26especially in finance because
  1330. 51:28co-variance is so important especially
  1331. 51:30for portfolio construction right right
  1332. 51:32okay we'll um we'll save that for
  1333. 51:34another day um there's also a course by
  1334. 51:39Andrew I'm not going to attempt to
  1335. 51:41pronounce his last name either NG yes
  1336. 51:45yeah that's how it's spelled is that how
  1337. 51:46you pronounce it uh well you pronounce
  1338. 51:48it I think but I'm doing a very poor job
  1339. 51:51at that so please don't write me hate
  1340. 51:53mail so that's that's like that's my
  1341. 51:55pronunciation I use in Singapore and
  1342. 51:58like it's close enough that they've
  1343. 52:00given up correcting me on it so that's
  1344. 52:03CLE yeah yeah I know his course is very
  1345. 52:06sort of highly rated um in the field of
  1346. 52:08machine learning is that something you
  1347. 52:10guys would recommend uh people check out
  1348. 52:12if they're interested in um you know
  1349. 52:14learning more about this would that be a
  1350. 52:15good place to start also I don't know
  1351. 52:18the course I don't know Max do you know
  1352. 52:20the course I uh started looking into it
  1353. 52:21you started looking into it yeah I I
  1354. 52:23don't know the course I know he's very
  1355. 52:25highly regarded and and he is kind of
  1356. 52:27the go-to name right now for for machine
  1357. 52:30learning um so you know I would say my
  1358. 52:35my my basian prior on this my is is
  1359. 52:38quite strong that it would be a good
  1360. 52:40course but I I cannot actually endorse
  1361. 52:42the course having never seen it myself I
  1362. 52:46like stuff that I did read sure okay
  1363. 52:48cool you've got a you've got a small
  1364. 52:50sample very small data sample from Max
  1365. 52:52very
  1366. 52:54partial that's funny so is there
  1367. 52:56anything else you guys would like to add
  1368. 52:58on machine learning before we wind
  1369. 53:00things down here um I mean honestly like
  1370. 53:04if this stuff fascinates you just like
  1371. 53:07try messing with it in Python um or your
  1372. 53:09language of choice I I say python just
  1373. 53:11because obviously that's what works on
  1374. 53:13quantopian and and I think in kind of
  1375. 53:15also in a more objective sense it's the
  1376. 53:16easiest one to get started in learn
  1377. 53:19makes it really easy yeah and and also
  1378. 53:21python is so good at in ingesting data
  1379. 53:25whether it be unstructured scraping web
  1380. 53:27pages parsing text files whatever you're
  1381. 53:29trying to do python actually makes it
  1382. 53:31pretty easy um and uh so it's generally
  1383. 53:34a good place to start but like obviously
  1384. 53:37if you're if you're experienced and and
  1385. 53:38you have some programming knowledge some
  1386. 53:40math or stats knowledge just just try it
  1387. 53:42because this stuff is cool and and and
  1388. 53:44the reason it's cool is why makes it so
  1389. 53:46dangerous because you you want to try
  1390. 53:48all these complicated models and then
  1391. 53:49you're like oh my gosh this thing
  1392. 53:50actually works I'm going to make
  1393. 53:52billions of dollars and it doesn't um
  1394. 53:55but but just go try it and and we'll
  1395. 53:57have links to a lot of the the related
  1396. 53:59content for stuff we talked about at
  1397. 54:02quantopian dcom chatwi Traders under the
  1398. 54:05under the section for this episode so
  1399. 54:07like you can actually start trying to
  1400. 54:08play with it a bit awesome so the next
  1401. 54:10episode is going to be a Q&A episode and
  1402. 54:13that's going to be part six of the
  1403. 54:15series which will be the the final
  1404. 54:17episode so uh for that we're obviously
  1405. 54:20answering uh any of the listeners
  1406. 54:22questions so guys if you do have a
  1407. 54:24question and I just want to emphasize
  1408. 54:26that there's no such thing as a dumb
  1409. 54:28question so no matter how how basic it
  1410. 54:31may seem uh don't be shy please do ask
  1411. 54:33it where is the best place Delany to
  1412. 54:36submit those
  1413. 54:37questions uh yeah so we'll have a link
  1414. 54:40set up by the time this episode uh goes
  1415. 54:42out if you go to quantopian
  1416. 54:46dcoms uh we'll have a form there you can
  1417. 54:49put in any question you want uh and you
  1418. 54:52can just kind of we'll we'll take a look
  1419. 54:54at them and and answer as as many as
  1420. 54:56possible especially if we find ones that
  1421. 54:59have you know the same question as many
  1422. 55:00other people um you know because that we
  1423. 55:03get the most bang for buck but um if we
  1424. 55:06don't get to your question um I I'll
  1425. 55:08I'll try as hard as I can to kind of um
  1426. 55:11also even if we can't get to it on the
  1427. 55:12podcast maybe like make a For Thread and
  1428. 55:15respond to it in the Forum thread or
  1429. 55:17something like that so I will I you know
  1430. 55:19really will try to get to everybody who
  1431. 55:22asked a question which I know the
  1432. 55:24listenership of this podcast is quite
  1433. 55:26Broad so uh I may be um biting off a
  1434. 55:29little bit more than I can chew here but
  1435. 55:31uh but hopefully we'll get some good
  1436. 55:33questions yeah so guys please go to
  1437. 55:36quantopian
  1438. 55:37tocom questions the idea of this is that
  1439. 55:40we can just collect all the questions in
  1440. 55:42one place so you know we're not
  1441. 55:44collecting some on Twitter some in
  1442. 55:45forums some in comments um if you do
  1443. 55:48have questions go to quantopian Doom
  1444. 55:51questions we can collect them all in one
  1445. 55:53place and make sure that none get lost
  1446. 55:55so yeah I think uh that brings us to a
  1447. 55:58close for this episode Max thanks very
  1448. 56:00much for joining us man it was a lot of
  1449. 56:01fun yeah thank you for having me
  1450. 56:04[Music]

About this transcript

This page contains the full transcript of Q5: Good Uses of Machine Learning in Finance · Max Margenot by Chat With Traders, generated from the public captions YouTube serves with the video. The transcript has 10,429 words across 1,450 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.