Machine Learning with F#
This is a modal window.
Das Video konnte nicht geladen werden, da entweder ein Server- oder Netzwerkfehler auftrat oder das Format nicht unterstützt wird.
Formale Metadaten
Titel |
| |
Alternativer Titel |
| |
Serientitel | ||
Anzahl der Teile | 170 | |
Autor | ||
Lizenz | CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported: Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben | |
Identifikatoren | 10.5446/50819 (DOI) | |
Herausgeber | ||
Erscheinungsjahr | ||
Sprache |
Inhaltliche Metadaten
Fachgebiet | ||
Genre | ||
Abstract |
|
00:00
Operations ResearchGewicht <Ausgleichsrechnung>SoftwareentwicklerMaschinelles LernenFunktionalProgrammierungVollständiger VerbandVirtuelle MaschineFormale SpracheTypentheorieTwitter <Softwareplattform>TaskMathematikStatistikComputerSoftwareGruppenoperationOpen SourceInformatikMultiplikationsoperatorWort <Informatik>Endliche ModelltheorieWellenpaketSpeicherbereichsnetzwerkGeradeEntscheidungstheorieMathematikStatistikOffene MengeSoftwarePunktSchlüsselverwaltungBildgebendes VerfahrenProzess <Informatik>Web logBitTaskRechter WinkelMeterStörungstheorieGüte der AnpassungMaschinencodeTwitter <Softwareplattform>SoundverarbeitungAlgorithmische LerntheorieMailing-ListeVirtuelle MaschineBeobachtungsstudiePortabilitätCASE <Informatik>Formale SpracheNeuroinformatikDifferenteInformationFitnessfunktionLineare RegressionBildschirmfensterPaarvergleichTypentheorieAbstandProgrammierungTranslation <Mathematik>QuellcodeQuick-SortHilfesystemAggregatzustandGewicht <Ausgleichsrechnung>ThreadArithmetische FolgeAutomatische HandlungsplanungRationale ZahlMereologieOperations ResearchProgrammbibliothekFunktionale ProgrammierspracheGarbentheorieSoftware EngineeringRechenzentrumVisualisierungQuaderNichtlinearer OperatorObjekt <Kategorie>FunktionalVersionsverwaltungEinflussgrößeComputeranimation
08:25
Maschinelles LernenGewicht <Ausgleichsrechnung>DatentypLineare RegressionVirtuelle MaschineMustererkennungPrognoseverfahrenAttributierte GrammatikDatenmodellKlasse <Mathematik>AlgorithmusImplementierungSupport-Vektor-MaschineVersionsverwaltungInteraktives FernsehenPixelMachsches PrinzipStatistikZahlzeichenMathematikPhysikalisches SystemRechenwerkZustandsmaschineSpeicherabzugWurzel <Mathematik>GeradeZeichenketteFlip-FlopPunktProzess <Informatik>Umsetzung <Informatik>Innerer PunktEin-AusgabeStrategisches SpielKernel <Informatik>ImplementierungAlgorithmusEndliche ModelltheorieLineare RegressionDigitalisierungZustandsmaschineVisualisierungBildgebendes VerfahrenE-MailBasis <Mathematik>Luenberger-BeobachterPrototypingElektronische PublikationMomentenproblemTypentheorieVirtuelle MaschineAuswahlaxiomElement <Gruppentheorie>Gewicht <Ausgleichsrechnung>Kernel <Informatik>SchnittmengeZahlenbereichProgrammbibliothekQuaderRandwertFormation <Mathematik>GrenzschichtablösungBitGruppenoperationSoftwarePixelVorhersagbarkeitAlgorithmische LerntheorieMultiplikationsoperatorTropfenGeradeKategorie <Mathematik>Heegaard-ZerlegungOrtsoperatorHyperbelverfahrenCASE <Informatik>Lesezeichen <Internet>RichtungPunktSpeicherbereichsnetzwerkFitnessfunktionGarbentheorieKlasse <Mathematik>Algebraisches ModellKontrast <Statistik>VererbungshierarchieZweiÜberwachtes LernenKonfigurationsraumSchriftzeichenerkennungSupport-Vektor-MaschineOrdnung <Mathematik>DivisionSoftware EngineeringPartikelsystemGüte der AnpassungMAPDigitaltechnikSelbst organisierendes SystemFunktionalDatensatzFlächeninhaltWechselsprungWellenpaketTransformation <Mathematik>Mailing-ListeSchreib-Lese-KopfProdukt <Mathematik>Physikalisches SystemProgrammierumgebungUmwandlungsenthalpieInteraktives FernsehenBildverstehenInstantiierungComputeranimation
16:51
Kernel <Informatik>RechenwerkFehlermeldungFluss <Mathematik>Strategisches SpielEin-AusgabeLineare AbbildungKlasse <Mathematik>BeweistheorieSchlussregelVektorraumMachsches PrinzipStatistikZahlzeichenMathematikPhysikalisches SystemModallogikSichtenkonzeptPrognoseverfahrenDatenmodellZufallszahlenPixelWiederkehrender ZustandInteraktives FernsehenVersionsverwaltungMailing-ListeMaschinencodeAlgebraisches ModellOktave <Mathematik>MatrizenrechnungLineare AlgebraC sharpF sharpBitKreuzvalidierungWellenpaketValiditätDifferenteBlackboard <Expertensystem>ComputerspielMultiplikationsoperatorPunktOktave <Mathematik>MathematikAlgorithmusZahlenbereichVisualisierungBildgebendes VerfahrenLastVirtuelle MaschineTypentheorieSchießverfahrenMomentenproblemFlächeninhaltAlgorithmische LerntheorieEndliche ModelltheorieEinsMereologieFehlermeldungProgrammierumgebungSchnittmengeZweiKlasse <Mathematik>Algebraisches ModellMatrizenrechnungGüte der AnpassungÄhnlichkeitsgeometrieKontextbezogenes SystemMaschinencodeProjektive EbeneSpielkonsoleGeradeApp <Programm>CAN-BusElement <Gruppentheorie>Elektronisches ForumRechenbuchRechter WinkelProzess <Informatik>OktaederFortsetzung <Mathematik>Physikalische TheorieStatistikNichtlinearer OperatorEntscheidungstheorieMittelwertInstantiierungWiederkehrender ZustandSchlüsselverwaltungDatensatzWort <Informatik>Bridge <Kommunikationstechnik>Familie <Mathematik>DatenfeldMailing-ListeComputeranimation
25:16
VektorraumMatrizenrechnungKonstruktor <Informatik>Maschinelles LernenAlgebraisches ModellVektorrechnungLineare RegressionLineare AbbildungBetafunktionSampler <Musikinstrument>InstantiierungZufallszahlenFehlermeldungBefehlsprozessorRechenwerkTermVirtuelle MaschineHardwareService providerVersionsverwaltungGleitkommarechnungAlgorithmusKontrollstrukturSchnittmengeKonfiguration <Informatik>ProgrammierumgebungPhysikalisches SystemCAN-BusInteraktives FernsehenMathematikÜbersetzer <Informatik>Lokales MinimumWurzel <Mathematik>GraphikprozessorCompilerComputerspielSpeicherbereinigungLineare AlgebraLineare RegressionFitnessfunktionLuenberger-BeobachterGüte der AnpassungFunktion <Mathematik>Formale SpracheGeradeZahlenbereichAnalysisMultiplikationsoperatorZweiBetafunktionEndliche ModelltheorieSchnittmengeSchaltnetzVirtuelle MaschineTypentheorieEin-AusgabeMathematikHash-AlgorithmusDifferenteElement <Gruppentheorie>FehlermeldungAlgebraisches ModellSupport-Vektor-MaschineHardwareBefehlsprozessorMultipliziererBitResultanteSchätzfunktionSampler <Musikinstrument>MaschinencodeCompilerMatrizenrechnungService providerRandomisierungFunktionalRegulärer AusdruckAlgorithmische LerntheorieNichtlinearer OperatorNeuroinformatikStatistikMeta-TagPunktDatensatzAuswahlaxiomGlobale OptimierungProgrammschleifeSichtenkonzeptProzess <Informatik>CASE <Informatik>SpieltheorieFamilie <Mathematik>ComputersimulationSchlussregelKurvenanpassungHill-DifferentialgleichungUnrundheitMeterProdukt <Mathematik>KreiszylinderMinkowski-MetrikExtreme programmingInverseBildschirmmaskeZusammenhängender GraphSondierungGewicht <Ausgleichsrechnung>Umsetzung <Informatik>InstantiierungMailing-ListeSchraubenlinieAggregatzustandWürfelTeilbarkeitPaarvergleichKomplex <Algebra>EnergiedichtePerfekte GruppeComputeranimation
33:42
RechenwerkBefehlsprozessorGleitkommarechnungKontrollstrukturPhysikalisches SystemWurzel <Mathematik>Übersetzer <Informatik>CompilerGraphikprozessorGewicht <Ausgleichsrechnung>Lineare RegressionWiederkehrender ZustandInteraktives FernsehenProgrammierungUnüberwachtes LernenMaschinelles LernenSchreiben <Datenverarbeitung>Domänenspezifische ProgrammierspracheDatenmodellAlgorithmusRekursive FunktionObjekt <Kategorie>FokalpunktMaschinencodeFunktion <Mathematik>GruppenoperationProdukt <Mathematik>Schreiben <Datenverarbeitung>ComputerspielNeuroinformatikRauschenMultiplikationsoperatorSupport-Vektor-MaschineSchnittmengeBitFunktionale ProgrammierspracheLineare AlgebraSoftware EngineeringQuaderAliasingGüte der AnpassungProgrammbibliothekNeuronales NetzCASE <Informatik>MatrizenrechnungTypentheorieFormale SpracheGewicht <Ausgleichsrechnung>PunktVirtuelle MaschineKreuzvalidierungDatenfeldMaschinencodeCompilerLineare RegressionZählenÄhnlichkeitsgeometrieMusterspracheAlgorithmusSoftwareAlgebraisches ModellEndliche ModelltheorieMAPGeradeAlgorithmische LerntheorieFitnessfunktionValiditätKlassische PhysikCluster <Rechnernetz>InstantiierungGarbentheorieDomänenspezifische ProgrammierspracheImplementierungSpeicherabzugMapping <Computergraphik>DickeUnüberwachtes LernenATMMailing-ListeMessage-PassingRechter WinkelFunktionalEinsTranslation <Mathematik>Klasse <Mathematik>RechenschieberKartesische KoordinatenWiederkehrender ZustandDifferenteClientGenerator <Informatik>Rekursive FunktionProgrammierungAggregatzustandAutomatische HandlungsplanungMathematikEnergiedichteFahne <Mathematik>MeterObjekt <Kategorie>EntscheidungstheorieDatenstrukturMetrisches SystemBildverstehenFigurierte ZahlGruppenoperationResultanteDatensatzForcingComputeranimation
42:07
AbstandBefehlsprozessorRechenwerkGleitkommarechnungKontrollstrukturMaß <Mathematik>Physikalisches SystemWurzel <Mathematik>Übersetzer <Informatik>GraphikprozessorCompilerAdressierungVersionsverwaltungComputersicherheitDatenpfadZeichenketteIRIS-TKonvexe HülleKlasse <Mathematik>Prozess <Informatik>PunktAlgorithmusCliquenweiteKlumpenstichprobeTypsystemGasströmungLaufzeitfehlerAusnahmebehandlungMereologieVirtuelle MaschineExplosion <Stochastik>Formale SpracheKurvenanpassungGraphfärbungMomentenproblemFormation <Mathematik>TypentheorieEinsMultiplikationsoperatorMehrrechnersystemBitPhysikalismusUltraviolett-PhotoelektronenspektroskopiePunktHackerGarbentheorieCluster <Rechnernetz>AuswahlaxiomBildgebendes VerfahrenElement <Gruppentheorie>FlächeninhaltElektronische PublikationVisualisierungBrowserNeuroinformatikSchlüsselverwaltungSoftwaretestCAN-BusKlasse <Mathematik>DickeKlassische PhysikBildverstehenMAPSchnittmengePlotterInformationAlgorithmische LerntheorieAlgorithmusZweiOrdnung <Mathematik>MagnetbandlaufwerkRekursive FunktionMathematikResultanteMittelwertGruppenoperationCASE <Informatik>TermPhysikalisches SystemEntscheidungstheorieProjektive EbeneTouchscreenFramework <Informatik>Mapping <Computergraphik>ExistenzaussageJensen-MaßCompilerMaschinencodeParalleler AlgorithmusGeradeVerfügbarkeitNichtlinearer OperatorResolventeRechter WinkelDemo <Programm>Fächer <Mathematik>Computeranimation
50:33
BefehlsprozessorRechenwerkKontrollstrukturMaß <Mathematik>Physikalisches SystemWurzel <Mathematik>Übersetzer <Informatik>CompilerGraphikprozessorGewicht <Ausgleichsrechnung>Service providerInformationTypentheorieDatentypVideo GenieAusnahmebehandlungTypsystemLaufzeitfehlerVersionsverwaltungWechselseitige InformationVideokonferenzProdukt <Mathematik>PunktGeradeBenutzerfreundlichkeitp-V-DiagrammAbfrageTypentheorieVisualisierungKategorie <Mathematik>Boolesche AlgebraSyntaktische AnalyseBitDemo <Programm>QuaderMultiplikationsoperatorElektronische PublikationEinsBildschirmmaskePunktService providerOpen SourceMailing-ListeStatistikMechanismus-Design-TheorieF sharpParserProgrammbibliothekInformationOffene MengeKlasse <Mathematik>InformationsspeicherungPrototypingOrdnung <Mathematik>StandardabweichungNummernsystemSkalarproduktFehlermeldungMagnetbandlaufwerkZeichenketteTotal <Mathematik>NP-hartes ProblemNormalvektorCASE <Informatik>TermSchnittmengeFortsetzung <Mathematik>Klassische PhysikMessage-PassingComputeranimation
55:39
VersionsverwaltungMaschinencodeAbfragep-V-DiagrammGewicht <Ausgleichsrechnung>Service providerDatentypInformationTypentheorieZeichenketteZählenDezimalzahlUmsetzung <Informatik>TeilbarkeitOrdnungsreduktionPlot <Graphische Darstellung>Total <Mathematik>Codierung <Programmierung>RandomisierungBildschirmfensterMaschinencodeMailing-ListeF sharpService providerCASE <Informatik>BitSchreib-Lese-KopfFormale SpracheTypentheorieMultiplikationsoperatorGeradeKontextbezogenes SystemDialektUmsetzung <Informatik>Klasse <Mathematik>Äußere Algebra eines ModulsInformationPunktProzess <Informatik>Divergente ReiheFlächeninhaltHypermediaZahlenbereichBaum <Mathematik>InstantiierungRauschenEntscheidungstheorieNummernsystemZweiMagnetbandlaufwerkSoundverarbeitungInformationsspeicherungForcingStatistikMatrizenrechnungIndexberechnungTeilbarkeitComputeranimation
01:00:45
TypsystemGasströmungAusnahmebehandlungLaufzeitfehlerGewicht <Ausgleichsrechnung>Interaktives FernsehenDesintegration <Mathematik>HydrostatikTypentheorieDatentypFormale SpracheMaschinelles LernenSmith-DiagrammErlang-VerteilungSkalierbarkeitPlastikkarteGreen-FunktionFormale SpracheDynamisches SystemRechter WinkelService providerVirtuelle MaschineTypentheorieGewicht <Ausgleichsrechnung>Funktionale ProgrammierspracheSoftware EngineeringSoftwareMaschinencodeProdukt <Mathematik>HydrostatikFunktionalAlgorithmische LerntheorieRichtungMAPPlastikkarteTwitter <Softwareplattform>RechenschieberVererbungshierarchieFitnessfunktionReelle ZahlPhysikalisches SystemFlächeninhaltWiederkehrender ZustandNeuroinformatikMagnetbandlaufwerkBitrateCASE <Informatik>SkriptspracheE-MailSoftwaretestZweiDifferenteFormation <Mathematik>Tablet PCNatürliche ZahlHilfesystemGüte der AnpassungComputeranimation
01:03:43
Computeranimation
Transkript: Englisch(automatisch erzeugt)
00:02
Hello, everybody. I guess it's time to start. I'll be talking about machine learning and F-Shop today. Before starting, here are a few words about me. My name is Mathias Brandwender. You can find me on Twitter as at brandwender. Usually, I'm the little character on the right.
00:22
That's me on GitHub and places like that. That would be typically me. I'm French. I live in San Francisco. It's my first time in Oslo, and I'm having a grand time. It's really awesome. A few things which might be relevant. Unlike most of you, I'm not a software engineer by training. I came to software engineering 10 years ago.
00:43
My background is in economics and operations research. That's like applied math, optimization, probability, all that type of stuff. I came into .NET 10 years ago by accident. At the time, I was doing models and a whole lot of VBA and more and more VBA. At some point, I had to realize that this was probably not right.
01:03
I looked into other things, and I came across C-Sharp. I started with C-Sharp. That was great. I still did models, forecasting things. Four years ago, I read somewhere that you were supposed to learn a new language every year. I opened Visual Studio. There was this little box which was F-Sharp. I thought, hey, maybe let's give it a go.
01:22
I started with it, and I completely fell in love with the language. Since then, I do F-Sharp pretty much all the time, and C-Sharp when I have to. Something along these lines. Since then, I have been doing mostly forecasting, quantitative models, using software. I discovered recently that apparently this has a name, and this is called Data Science.
01:45
Apparently, I'm a data scientist. I looked from the definitions. I came across a few definitions. One of them is a data scientist, a statistician who lives in San Francisco. That's correct. The other one is a data scientist who uses a Mac, so that's not correct.
02:01
The third one, where I thought it actually fits well, is this one which I really like. A data scientist is a person who is better at statistics than any software engineer, and better at software engineering than any statistician. I feel that's kind of what I'm doing. Data science is about having one foot in math, statistics, and all of this, and the other one in code.
02:23
Otherwise, I have a blog and all these things. Today, we're going to talk a bit about machine learning and data science. I made a few assumptions about who you guys were. The first assumption I made is that everybody, or most of you, are probably familiar with all languages. C-Sharp, Java, all of this.
02:41
I'm assuming that most of you, or probably all of you, are unfamiliar with machine learning, because it's a software conference, not a machine learning conference. I'm assuming that some of you, probably not all of you, are familiar with F-Sharp, and that some of you, and probably not most of you, are familiar with functional programming. Is that a fair assumption so far?
03:02
Cool. I'm not completely off-base. That's reassuring. Why did I want to do this talk? I live in San Francisco. This is probably a bit of a bias, but right now in San Francisco, the topics machine learning and data science are red hot, because I'm a data guy, I brought a piece of data on the right.
03:24
This is the list of meetups, a recent list of meetups. Pretty much every meetup on the topic is drawing somewhere between 100 and 300 people, and you have one of these every week. People are getting crazy over there. I do realize that San Francisco is sometimes biased.
03:41
It's not necessarily what the rest of the world is doing, but I feel like there is a big trend there. The second thing I noticed is that if you go to machine learning, or talk to machine learning people, usually they talk about lots of things, but they don't talk about .NET much. Coming from .NET, for me that's a bit of an issue, and I think they're probably also missing something with the F-sharp.
04:02
The third one is on the other side of the house, on the software side, I think lots of people in the software community don't realize that machine learning is for statisticians, but it's also for software engineers. The reason it's not called statistics is because it's one foot in one, and one foot in the other, and so I feel like it's important to tell you guys that it's a fun place to be,
04:23
and you should probably look into it because it's going to be a fun place with very fun computer science problems, and so you should look into it right now. So my goal today, I'll start with what I can't do, and what I can't do is two things. There is no way I can introduce F-sharp in one hour. That would just make no sense.
04:41
The other thing I can't do, which is probably even worse, is introducing machine learning in one hour. I can't do that either, so I had to choose a bit how we'd approach the topic. So what I want to do is rather than trying to do everything poorly, I'm going to try to do a few things hopefully decently, and what I want is to give you a sense for what machine learning is.
05:02
Given the fact that you're developers, I'm going to try to highlight also some of the differences with how is it different from writing code as a software engineer, and give you a sense of what is the day of a machine learning guy. The other piece is obviously I'm here because I want to talk about F-sharp, and so I'm also going to have a second thread
05:20
which is going to try to explain why F-sharp is actually a great fit for that type of activity, and why you should pick it up. So, a quick introduction in case you haven't heard about F-sharp. Like in Five Bullet Points, I guess F-sharp is a functional first statically typed language. So it's just like C-sharp is object first, a bit functional.
05:41
F-sharp is kind of the flip side of that. It's cross-platform, it runs on Windows, on Mac, on Linux, pretty much whatever you want. It's open source. There is actually in the room, Tihan, over there, there is a pull request last week which went to the compiler, so it is open source. One way you could think about it is maybe something like Python with types.
06:01
So the main way to say this would be like it's Python which is actually performant and with less typing mistakes. And it's also a language with a fantastic community. And if you want to find us, it's on Twitter, hashtag F-sharp. So that was for the F-sharp side. For the machine learning one, I thought it would be useful to give a definition for this. Like it's a bit clearer than data science actually,
06:21
which is a bit of a buzzword. And so when I need a definition which I go to the source of truth, so I went of course to Wikipedia, and I copy-pasted this one and the, how to put it, like the dry version is like a computer program is said to learn from experience E with respect to a task T and a preference measure P if its performance at task T
06:41
as measured blah, blah, blah improves with experience. So that's, it's a definition. It's probably not the most friendly definition. So I thought an English translation might help. So what you're really trying to do is like, one is like you're writing a program and your program is written to perform a task. And to perform that task, you're actually going to consume or use data.
07:01
And the part about performance and all of this is really saying like you're doing a program such that the more data the program is going to see, the better the program is going to become at performing that specific task. It's probably easier that way. And it's rooted in statistics and in math, but it's also a computer science problem.
07:20
For me, the reason it's called machine learning probably and not statistics is that statistics was rooted in the past in the days where you had very little data, you had no computer, like it was the dark ages, maybe you had floppies, stuff like that. And so like your problem was very little data and squeeze information. And machine learning is different in that today it's not the problem we have. Today, the problem you have is that you have probably too much data.
07:42
And so the old school statistics don't quite work. And this is where you're trying to do the same thing as a statistician, which is use your data. But you also need to know a bit of computer to deal with it because it's just not a tiny file, like it's a bigger type of thing. So the plan. I was saying like I'm going to have like two threads here.
08:03
So I'm going to progress in like four little sections. Each of them is going to have a bit of a machine learning point. So I'm going to try to teach you some ideas or some concepts about machine learning so that you come out of it and you have a bit of a sense of the landscape. So on the first section on the machine learning side will be I'll talk a bit about classification. I'll be talking a bit about regression
08:21
and about unsupervised machine learning. So these are things I'm going to try to show you a bit what they are. And on the right-hand side, at the same time, I'm going to show you like how you can actually do fairly decent machine learning on .NET and FSharp in particular because they are actually pretty good libraries. I'm going to talk a bit about Algebra because even though it's probably not your favorite topic,
08:41
it's actually an important topic and for people who care about it, it's a big deal. And I'm going to try to make the point that the functional style is actually a great style of coding for machine learning. And finally, I'm going to talk about something which doesn't fit in really one or the other, which is type providers, because any sufficiently long discussion with FSharp people ends up with type providers, so that's what we'll do.
09:02
So, let's start with the classification and regression. And the goal here in my section will be to give you a sense of, like, if you do machine learning, what does a day of machine learning look like? And I'm also going to explain what classification and regression are. So that's a bit of vocabulary or conceptual ideas.
09:22
One thing you might want to do with your data is you have two classes of problems. One class of problems is like you're trying to... You have data and you're trying to make a prediction, and your prediction is trying to use the data to classify items. Like you're trying to say, is this red, is this black? Or typically, prototypical examples would be,
09:42
if you take your inbox or your email system, you probably have a spam filter. That's a prototypical classification problem. I'm receiving emails and I'm trying to say, is that email spam or is that email ham? Sorry, that's a classification problem. The one we're going to look at in a minute is character recognition.
10:01
I'm trying to say, is this an A, is this a B, is this a C? These are like discrete choices. I'm trying to say, which bucket do I fall in? By contrast to that, the second big class of problems you can find is regression problems. And in a regression problem, you're not trying to decide whether something is in bucket A or in bucket B. You're trying to predict a number. The prototypical example would be,
10:21
I'm trying to predict the price of that car. I'm trying to predict the cost of an apartment, so a number which could be from zero to whatever. That's a regression problem. And both these things belong into one category of machine learning, which is what's called supervised learning, by a position to unsupervise, which we'll look at later.
10:41
The idea of supervised learning is, I have data, I have a question, and I know exactly the question I'm trying to answer. In the case of my email, I know that the problem I'm trying to solve is I want to know if it's ham or if it's spam. If I want to recognize characters, I want to know if it's a one, a two, a three. So that's a supervised learning problem, because what I'm going to do is I know the question I'm trying to answer,
11:03
and I'm trying to help push the model or supervise the model into the direction of the question I'm interested in. Does it make sense so far? Cool. So rather than talk more about classification, what I'm going to do is I'm going to actually work live with an example.
11:23
I pulled it from Kaggle, which is a company in San Francisco, and they organize machine learning competitions. For that matter, if you're interested in getting started with it, check out Kaggle.com. They have free competitions. They have competitions where you can make a boatload of money, and it's just extremely fun to do and to get started in the topic. So the problem of the digit recognizer is simple.
11:43
They took people, they asked them to write numbers on a sheet of paper, one, a zero, a three, whatever. So this is the type of thing you have. And your problem is, if I give you a new image which you have never seen, you're trying to tell me, is this a five, is this a three, is this something like that. So we're trying to build a classifier which recognizes handwritten digits.
12:03
To do this, we're going to use a classic algorithm. I thought I would just say what the algorithm is. It doesn't really matter, but we're going to use a support vector machine. And we are specifically going to use the Accord.NET implementation. And one of the reasons I picked it is Accord.NET is actually written entirely in C-Sharp.
12:20
It's a pretty nice library. They have lots of things. And the thing which is neat is I can use this out of the box with F-Sharp. Absolutely no problem. Whatever you have in C-Sharp, you can use it in F-Sharp. And what the algorithm is going to try to do, if you see the picture, I'm trying to classify black and white. And the general high-level idea is the algorithm is going to try to separate the two groups,
12:43
so in that case, black and white, in our case, more zero, one, two, three, four, by boundaries or by bands which are as wide as possible. That's what it's trying to do. So not only do you separate the data in two groups, but you are pretty certain that the separation is good, so you're trying to make it white. And so now I'm going to show this in action.
13:02
And so I'm going to jump straight in Visual Studio. And I'm going to go to the place called classification. It's magnificently organized. So my day as a machine learning guy will typically start with data. And so that's really...
13:20
Your day is probably going to look a bit like that. Show me my data. That's typically your day, which is probably not what you're used to as a software engineer. Your particular problem is somebody will go, hey, here is a big chunk of data. In that case, what I have is...
13:40
So these are the images I was talking about. I have 5,000 images. I have something like 800 columns. And so this is obviously not fun to work with, but that's the type of material you're dealing with on a daily basis. And now my problem is I want to make a prediction out of this. So what I'm going to do is I'm going to jump into the scripting environment, like f-shop interactive in f-shop.
14:02
And I'm going to just load a few references here. So think about it. I'm just loading what I need. That's not usually interesting. And now my day can begin. So the first thing I'm going to need to do is I'm going to actually load that data. So let's do this. So I'm going to... This is where the data is,
14:21
what the name of the file is. Nothing super interesting. And here I'm going to just write a small function, which is going to read my data. We're going to see there's actually a much better way to do that in a minute, or a bit later. But here I'm going to say, hey, look at the file path, read all lines, and then take these lines, drop the header, just keep everything from one to the end.
14:40
Then take every line and split it. Then take everything which has been split. The first thing is going to be the number I'm trying to predict. The rest is going to be the pixels. And then I'm done. And the one thing I like about f-shop is this thing here on the left is the pipelining, which is when your day looks like data and you're trying to transform data, this is a pipeline which is showing me I'm trying to do this,
15:01
take data, transform, transform, transform, you're done. This is extremely readable, and I really love this. It's a small feature, but it's really neat. So what I'm going to do is I'm going to run it, and I'm actually going to read the data from my training set. So obviously this is going to take a bit of time. It's not big data, but it's, let's say, moderately tiny.
15:22
More than tiny, but not big data. So I loaded it, and it took a bit of time to grab. And I'm just making the observation for the moment. And just because nobody is right, this is not exactly pleasant to look at. What I'm going to do is I wrote a tiny visualizer. So what I'm going to do is I'm going to take the 10 first elements in my set,
15:42
and I'm just going to represent them. So this is the data we're dealing with. I have a three that's fairly recognizable, a five that's already... The point here is that you can see that three humans have written it. Some handwriting are pretty nice. And some of them look more like your physician or your doctor writing the prescription. So it's not a trivial problem.
16:01
Like, even as a human, sometimes I look at the images, and I have no idea if it's really... Okay, this one actually pretty... So that's one, for instance, like I would not necessarily have guessed it. So that's what we're trying to predict. So now I loaded it, so it was a bit slow. So I'm going to use simply accord.net.
16:23
And what I'm going to do is I'm going to set up the algorithm I'm going to use. And so I'm going to choose... Here, the details are not super important, but if you see, the end is like a learner algorithm passing a configuration. So I'm going to tell the algorithm how I want to learn about my data. To do this, I'm going to specify, like, this is the algorithm I want.
16:44
I'm going to use a kernel, which is a linear kernel. That doesn't really matter what it is. I work this way, prepare the configuration, and now it's like my learning routine is ready to go. The only thing I need to do is I need to pass the data, which is the next thing I'm going to do. So I'm going to say learner run.
17:01
And now it's working the magic, like cranking on the data and trying to learn. So let's give it a second. The algorithm at that point is looking at 5,000 elements, and it's trying to separate the ones from the twos from the threes,
17:20
and create something which then you can pass to data, which is going to tell you, I think this is a one, I think this is a two, and so on and so forth. And so this just runs, so this is wonderful. And on top of the running part, it also gave me an error. And now this is absolutely awesome. I can see on the scripting environment here, this is telling me, hey, the error is zero percent.
17:44
Hooray! My day is gone. It's 100% correct. It's time to open a beer. Let's go celebrate. We're done. Right? And I would say, not so fast. Because the... I'm sorry, it would be nice to go for a beer, but it's a bit too early.
18:03
So... Where's my mouse? The reason it's a bit too early is what we really did here is we gave the algorithm a set of data, and we told it, hey, do the best you can to give me a model which fits on this data and gives me the right answer. That's great. The problem you might get too
18:21
is you will potentially get what's called overfitting, which is you get a model which is going to be extremely good on one dataset. The one thing you don't know is, is this going to actually work on data it has never seen? And that's really what you want. The fact that it's doing a good model and the data you already know is kind of useless. If you're creating a model, it's because you want to predict things you have not seen before.
18:43
In the olden days of statistics, you would crank out the math and the blackboard and all of this and do lots of calculation, but today, given that we have more data, there is a method which is much easier to check how good your model is doing. If I have lots of data, I can just say, hey, take half of the data for the learning part,
19:01
create a model, and keep the other half, and just run your model in the other half and see if it's doing any good. That's going to be really giving you a pretty good answer, because now it's like you're giving data it has never seen. That's going to behave pretty much like in real life. You can immediately see is this good, is it bad, and if you need to rework things. This is what I'm going to do here,
19:21
and that's called cross-validation. Here, I'm going to open my second dataset, which is validation, which is exactly the same, or not exactly the same, but like a similar type of dataset, and now what I'm going to do is I'm going to take the learner or the classifier I just created, and I'm just going to run it on my data.
19:41
What I'm going to do is simple. I'm going to take my validation data, and for every element, I'm going to look. This is the true answer, like the label. This is the image. Now I'm going to say, classifier, tell me the answer. If this is the same, this is a one. If this is not the same, this is a miss, and this is a zero. At that point, if I average this out, I'm going to get the percentage of misclassified.
20:03
Everybody with me? Let's do that. Again, I think the pipeline style is pretty neat. You can really read fairly well what's happening. I'm going to do that. You can see, to my point, we get something which is still pretty good. Is this still pretty good, or is this terrible, actually?
20:20
No, that's pretty good. Instead of 100% on the training set, now we get 90% correctly classified. It's still decent, but it's not quite as beautiful as we initially thought. That's an important part of the machine learning process, is this idea of you do a training set, you train on it, and then you keep the other side of the data,
20:41
and you do validation on it. Now, because numbers are kind of dry, like I told you, it was 90% correct, but why would you believe me? What I'm going to do is I'm going to use my visualization piece, and I'm going to do the following. I'm going to take 10 random images in my data set,
21:00
and I'm just going to classify them, and we'll see what it does, and that will give you a sense of how good it is. This was a 3, it told me a 3. That's actually pretty neat. This is impressive. I'm not sure I would have gotten this right. See, this was a 1, and this told me a 1. This one, I'm starting to be really impressed, because this is really an ugly 8, and it got it right.
21:23
I might have gotten 100. Yeah, that was easy. That was easy. That's also pretty neat, actually. It could be a 4. It looks like on my little sample... See, that's nice. It's like recognizing a 6 here. I think it's neat. In 10 lines of code or so,
21:40
I managed to get something which recognizes 90% of images. It took me just a bit of work, and it's working nicely. So, that's really a lot of how your day is going to look like now. We have a model, it has a certain quality. We also have cross-validation with training and validation.
22:02
We have something like a harness, which tells us, are we doing good, are we doing bad, and we can start working. The next step would be, can I go from 90% to 91%, maybe 92%? Try to squeeze out some more out of the data. This is where having... The reason I went into the scripting environment here
22:22
is it's a feature which is making a huge difference in my life in the context of machine learning. Now, imagine that you were in C Sharp, and your project was in a console app or whatever. Every time I decide to change my code, what will I have to do? I will have to do two things. I will have to recompile, and I will have to reload absolutely all my data.
22:43
So, the recompile part is not that bad. But loading the data, this was a fairly tiny dataset, and it took me a couple of seconds to load. If I have something more reasonable, it's not unusual to spend two or three minutes loading the data. So, if I have to rebuild, reload every time I change something, my day is essentially going to be spent loading data
23:01
and waiting for data to load. That's a terrible situation to be in. If I'm in the interactive environment, the REPL like this, like with F Sharp, it's like, this is beautiful, because now I can keep going. If I wanted to, I can change my code. I don't need to reload the data. It's loaded in the morning. I go load, I do my coffee, and then I come back. It's there, and then I can start hacking for the whole day.
23:21
That's a big deal. So, that's one of the big reasons. In general, doing machine learning without a REPL is like shooting yourself in the foot, and that's one of the reasons I would take F Sharp any day over C Sharp for that type of work. So, this will be closing the pot on the classification. Do you guys have questions?
23:41
No questions for the moment. So, I will move to the second step. There will be less moving images, I'm sorry, but I tried my best to make algebra sexy, but it's resisted a bit. So, I still wanted to talk about algebra, because algebra is an important area.
24:03
I'll try to show you why it's important in a second, but if you take, for instance, there is a great class online on Coursera, which is a machine learning class, and if you take that class, you will see that pretty much every session is like algebra, algebra, algebra. There are a few reasons for that,
24:21
but if you do machine learning, chances are you are going to care about having good or bad linear algebra. So, here what I'm going to show is simply, even without thinking about machine learning there, F Sharp has a few nice features which make it very pleasant to work with algebra. If I take something like this, let A equals matrix,
24:43
I mean, if I look at this, this is pretty much how a matrix would look if I open a math book. It doesn't look like something complicated, something weird, it looks exactly like the math. If I create a vector, same thing, and I can do things like that, like C equals B times A. This is also very close to the way it would look
25:02
to somebody coming from MATLAB, coming from Octave. If you want to work in algebra, you want it to look like algebra, and F Sharp is going to give you that. So, F Sharp is awesome again. So, that's the first point. The second point is, besides the fact that algebra looks like algebra,
25:21
there is a feature which is really neat. So, if you come from Python, you're going to say, hey, of course it has it. It's called slicing, or array slicing. One operation you're going to have very often is like, hey, I have my data set, I want to drop column seven, I want to manipulate it a bit. So, one thing you can do here, which is pretty neat, is I can say now I've got my vector and my matrix,
25:43
and what I can actually do is I can say, out of the matrix here, I want you to take only column one to two, and I want you to take only column row zero to one. That's extremely convenient. It's the type of thing which you won't be able to really do nicely in C Sharp, and which makes a huge difference in clear code and in knowing what you're doing.
26:04
Because when your code is not clear, then this is when you start doing mistakes. So, again, from a Python people, it's like, yeah, of course, that's not really impressive, but it depends where you come from. So, that's why I think for me, F Sharp is a pretty good choice.
26:22
If you want to do algebra, it's going to look like algebra. Now, there are a few reasons why machine learning people do care about algebra. The first one is, I can't quite go into the details of why that is, but lots of problems which are related to optimization and machine learning can be expressed in an extremely compact way, like in a very short way.
26:44
Instead of having loops everywhere, you can just write a few matrix operations, and your problem will be just stated and done. So, in that case, what I wanted to do was to show a bit of regression, a linear regression. For instance, solving a linear regression, which is if I take input,
27:01
and what I'm trying to do is I'm trying to predict the output as a linear combination of the input, it turns out that I can solve that problem as a one-liner in algebra using the normal form, and so that's the way it would look. If you take the math book or the statistics book, you're going to have something like x transpose times x inverse
27:20
times x transpose times y. So, the details are not usually important, but that's going to give you, if you use this, like the algebra is going to give you in one line exactly the solution to your regression problem. So, already, that's nice because it's very short. So, let's do this. And now, what I'm going to do here
27:41
is I'm going to create a completely artificial data set, because I didn't have really a good one, and what I'm going to do is I'm going to create a data set where imagine that I'm trying to predict the price of a car. I'm going to create 500 features, so I could probably not come up with that many, but imagine that what I have is the age of the car, the number of cylinders, the mileage, all that stuff,
28:00
and I have 500 of these. It's starting to be, not big data yet, but serious data. And I'm going to have 5,000 observations, like these are my cars, and what I'm going to do is I'm going to create, so the real model is going to be a vector of 500 components. I'm just making it like a random vector
28:20
because I don't really care what the numbers are. And I'm going to create also a random set of inputs here. And now, what I'm going to do is I'm going to create a model which is a perfect fit. So, what I'm seeing here is why the output, like the price of the car in that case, is going to take every observation in my data set, which I created here, and multiply true beta times X.
28:41
So, it's like I'm really exactly producing the linear combination of my input. So, let's do this. If you don't get the details, that's not usually important. I'm just trying to explain a bit what I'm doing here. So, here what I did was I created a data set. So, a nifty feature, which I really like in F-Sharp, it's maybe under-heralded, is this small thing here.
29:02
You can type in like a hash time, and I let you guess what it does, it's like suddenly you have a timer. And this is extremely convenient when you just want, even if you don't do machine learning, this gives you a nice way to start tuning your code and see what works, where you're spending time. So, now, if you recall, the math book is telling me
29:21
this is how I should compute my model. This is really what I get if I go to a math book. And so, I'm going to write it in F-Sharp, and it's like, hey, sure enough, it's looking exactly the same. X transpose times X inverse times X transpose times Y. So, that's nice again. I take the math book, I just copy over, and it's just going to work.
29:40
So, now I'm going to run it. And like this is, so, now it's cranking. And it did crank. And so, this is where the timer is telling me, hey, this thing took five seconds. This is stuff about the garbage collection. Well, this doesn't really matter. But so now, it took me five seconds to estimate my model.
30:01
Good. One thing you should be able to check is if I'm correct. What I should observe, if you recall, is what I did. I created the output by using a vector which was true beta. The result of my estimation is better. So, normally, if I make the difference between what I used and what the model estimated, everything should be zero. Like, the two vectors should be the same.
30:20
Otherwise, my model is not doing what I expect. So, I'm going to just check this out, just to make sure I'm not cheating you. And here, what I'm getting is it's telling me the difference here. So, I'm taking every element. I'm computing the difference of the values and taking the biggest one. And so, the biggest error is zero, which means, hey, the model gave me exactly what I expected.
30:41
It was a perfect fit in five seconds. Good. So, I said the first reason people care about algebra is that it's going to give you very compact solutions. It's very easy to express things which should be complex to express otherwise.
31:01
Like, this function or this expression here is very short. And so, that's kind of convenient. That's not the only reason people care. The other reason people care about algebra is because sometimes there is an upside to people who do video games. And so, one of the good things about video games
31:21
is that these guys need really graphics which go blazingly fast. It turns out that graphics also use linear algebra and vectors. And so, that's pretty awesome, because now, because some of you guys are playing Halo or whatever you guys are playing, the industry has put tons of effort in the hardware to actually get that type of operation to run blazingly fast.
31:43
And so, that's cool, because now what I can do is instead of using the initial computation I did, which was reusing traditional CPU and all .NET, what I can do is I can ship this and send it to the CPU or to hardware, and use the goodness which is coming from the gamers.
32:01
So, thanks to the gamers. And this is extremely simple in that case. So, what I can do is I can say, hey, instead of using the normal linear algebra provider, what I'm going to do is I'm going to use the MKL linear algebra provider. Good. And so, what this is,
32:20
is like it's saying instead of computing normally algebra computations, when you see something which looks like algebra, ship it to the CPU where you're going to find a bit of hardware which actually knows about algebra, and use that, because that's going to be better. So, that's what I'm going to do here. And now, the cool thing is I can take exactly the same operation I had before,
32:41
but I'll give you a hint. Like, if you see that it's going fast better, it's probably going to go faster. So, I'm learning exactly the same thing as before, and bam. So, if you remember, like before that, we had, what, like five seconds? And now, we went from five-second computation to 0.5 seconds. So, it's like with one line of code there, is like I got like a speed-up of like I reduced my computation time by 90%.
33:03
So, that's nice. It's like Halo and the gamers, they can give me a massive speed-up. And this is probably the most trivial thing you can do. Like MKL is not the craziest one. So, you, like really crazy people, like use GPGPU.
33:21
And F-Sharp also has a great story on this. Like, so, F-Sharp historically is coming from OCaml, which is coming from ML. And ML, the name ML is coming from meta languages. And these languages were created like for compilers, for code analysis and all of this. And they are actually pretty good at doing compilers to other things. So, it's like, of course, like every language today has a compiler to JavaScript.
33:41
So, yeah, F-Sharp has a compiler to JavaScript. But there is also a compiler to CUDA, to GPU. Like, it's a commercial product called Alia Cubase. But this is completely awesome. It's like, if you want to target the GPU, instead of typing hand-crafted C code, you can just like write high-level code in F-Sharp.
34:00
It's going to be generic and all of this. And it's going to compile like straight to the GPU and run blazingly fast. So, most people, if your daily life is like writing, accounting applications, you probably don't care. If you're doing like neural networks and deep learning, like this is the type of place where people's eyes light up. Because that can mean something like 50% faster computation
34:22
on something which could take a couple of days. So, that's a big deal. And I think that's what I have in regression so far. Do I have questions from you guys? What, of what? No, they weren't on the GPU? No, I don't. Like, yeah, like I should have written a noise. I wish, maybe next time I'll do that.
34:43
So, let me go back to the slides for a sec. So, the takeaways from this section of the thing I hope I conveyed are the following. One, F-Sharp is a first-class citizen in .NET. So, the reason I'm mentioning this is like,
35:02
sometimes people have the impression that F-Sharp is a different language and all this, and it's actually going to work really nicely. Anything which has been ever done in C-Sharp is going to work in F-Sharp and vice versa. So, you can actually reuse a ton of stuff. Two, even though .NET is not Python, maybe, like we don't have the same length of history in machine learning,
35:21
we don't have maybe something as deep as Scikit, there is actually a ton of good tools which already exist and which are pretty decent. Like, accord.net has all the things you expect in the first pass. Like, it has a logistic regression, it has support vector machines, it has neural nets. Like, all the base box is there. So, it's not like you're naked in the jungle with just a knife. Like, you have things to use.
35:40
You have Alia Cubase, you have a good linear algebra library. Three, the thing I really care about is the interactive experience with the REPL, which is going to make your day either, if you don't have one, your day is going to be miserable, and if you have one, your day is going to be possibly miserable, but one of the miseries is gone. Four, so, I know not everybody would agree on that,
36:03
but I would argue that actually syntax matters, and that's why I showed a bit the algebra case. It's like, if I work on a problem which is about matrices and vectors, I would like my code to look like matrices and vectors. And that's the type of thing you will get with F sharp, probably because it's functionally closer to math. Like, you get things which look actually much closer to the type of code
36:22
you're typically writing in machine learning, so it's easier to understand than all of this. And finally, on the machine learning front, I hope I give you a bit of a sense of what is classification, what is regression, unsupervised learning, and what cross-validation is about. So, I'll close the first step of my journey here, and I'm going to go to the next step,
36:41
which is unsupervised learning. And the goal is here to illustrate unsupervised learning. And my point here, besides showing you a bit about unsupervised learning, is I will argue that functional programming and machine learning are actually a really nice fit.
37:03
So, in the first part, what we did was, hey, we have a problem, we use a library that's all nice and good, it works, and we are happy. Sometimes, you will actually have to write your own. So, in general, when a software engineer tells you, hey, there is a library, but I'm actually going to write my own, it's usually a red flag, a red flag, a red flag,
37:20
it's not a very good idea. But it actually happens quite a bit in machine learning, or it could happen more often in machine learning. And there are a few reasons. One of them, and that's kind of what makes the field interesting, is usually what people do in software is things which happen, which are following academic research and stuff, which happened 20 years ago or 30 years ago. In machine learning, it's actually not uncommon to see people tell you,
37:42
hey, I'm working on an algorithm which was on a research paper which is three months old, that type of thing. And so, if it's three months old, chances are nobody implemented it, and if nobody implemented it, if you want it, this is like, hey, you will have to do it. And also, the other one is, it's nice to use stock models, like the one I did with the support vector machine, but at some point, as you gain more knowledge of your domain,
38:02
you might hit the point where you actually need to start to tweak and customise your model, and then the classic model out of the box won't work, and so you will have to do it. So, it's not unusual to have to write your own. And if you do that, and write your algorithm, which I end up doing fairly regularly,
38:20
you'll see that most algorithms actually have the same general structure, with some variations, maybe. So, typically, one, obviously, you're going to read data, because if you don't have data, you're not going to learn much. Two, out of the dataset, what you're going to do is, this is the data, this is how I want to shape it, so you're going to try to shape it into what's called features. You transform it into what you want.
38:41
Three, once you have the features, you're going to pass it to something which is going to learn, like what we had on the support vector machine, and so that's going to be, take the data, and learn until you're satisfied with the learning. And finally, once you're done, evaluate how good your model is, by probably looking at cross-validation,
39:00
like at the other dataset. And so, if I take these steps, they actually translate pretty well into a functional programming style. So, read data, I'm actually going to show you that F-sharp has something nice on the read data side, which is not necessarily functional, but step two, transform into features, that's exactly what the map is. I'm going to take a list or a set, which is my dataset,
39:23
and apply a function and give me features. That's a core concept of functional programming. If I put a model and I'm trying to learn from the data and the features, typically what you're going to have is learn until the model is good enough, and that's a straight fit for recursion, which is also the bread and butter of functional programming.
39:40
And if you want to evaluate how good your model is, what you're going to do is, you're really going to do, hey, take your validation set on a computer metric, and accumulate the results, like for instance what we did with counts the ones and the zeros, and that's a fold, and that's also straight-up functional programming. And so, in the end, pretty much every implementation I have looks that way, like you have a map in the beginning,
40:01
a recursion, and then a fold, and you're done. And so, that's nice, because the problems you have or the translation maps really nicely. The other reason I think functional programming is nice is typically, what I'm going to do is, you're always changing your model, because you have an idea, it works, and then you have a new idea,
40:22
so you start to change the features and all of this. And so, if you're in that mode where you're trying to iterate very rapidly, you can't really afford to change your domain model all the time. The last thing you want is to have classes and all of that, and start to tinker with this. That's just not right. And so, an old style is, in my opinion, or in my experience,
40:41
not working really well, and instead of forcing the domain model into your algorithm, what works much better is take the objects, take the data the way they are, and just apply functions to it. And that's much easier, you can manipulate the functions, you don't touch your domain model, and it works just very nicely. So, I said that I was going to talk about unsupervised learning.
41:04
So, supervised was, hey, I have a question, here is the data, do the best you can to give me the answer to the question I know. Unsupervised learning is the opposite. It's like, hey, I still have lots of data, but I don't know what I want to know about that data. So, it's unsupervised, because what you're trying to do is to give to the computer data,
41:21
and you hope that it's going to come up with something which is interesting. So, one of the examples of classical algorithms is clustering. So, clustering would be, I have maybe a data set about my clients, I have maybe a history of my products and all of this, and what I'm trying to do is I'm trying to find patterns, like maybe something like similar products or similar clients,
41:42
like maybe ladies have different habits than guys, maybe older customers have different habits from younger customers. So, you're trying to see if you find patterns or clusters of items in your data set. So, one of the ways to do that is the k-means algorithm. So, imagine that this is your data set.
42:00
So, this is clearly like a tiny data set just for illustration purposes, but if I look at this, I see two clusters. There's like a bucket of people on the left and a bucket of people on the right. What I could do is I could say, hey, let's try to see if I can recognize two clusters in here. And so, I'm going to create what's called a centroid. That's like the big, I think they're orange.
42:20
I'm color blind, so I never know what color is what. But the big thing in the middle, that's a centroid. And I'm saying, suppose I have two clusters. Now, what you try to do is take every element in my data set and assign it to the closest centroid. So, that's a map. It's like, take element one, map it to a centroid,
42:40
pop, pop, pop, pop, pop, so on and so forth. So, in that case, what I did is all the guys on the left became, I believe, red, and all the guys on the right became blue. I assigned them to the two different centroids. Now, the next step would be take the centroids and move them. Update so that you get better. So, what I'm going to do is now that I know that all the guys on the left
43:04
belonging to centroid one, take centroid one and move it to the middle or to the average of that cluster. So, move it a bit and do the same to the other one. So, that's what I'm doing here. And finally, try and look at whether the result changed.
43:20
If the cluster didn't change, there is no reason to keep going because it's going to keep staying the same. If it changed, keep going until nothing stops. So, that's a recursive function, like do it, do it, do it, until it doesn't change. So, that's kind of how the clustering, the k-means algorithm works at a high level.
43:41
So, what I'm going to do here is I'm going to jump back to code. Actually, that's not the one I want. So, I'm going to show you also something I started doing with the friend. So, the project is called VegaHub. And the intent was to be able to rapidly visualize charts.
44:03
So, try at your own risk. I would say it would be charitable to describe it as alpha quality. So, there is a possible chance that everything explodes during the demo. So, let's spice it up a bit. But I like to live on the edge. So, we're going to take a classic dataset.
44:20
Like what it is, it's not usually important, but it's like a set of flowers. I have three types of flowers here, like Aris, Setosa, Versicolor, and Virginica. This is a classic of machine learning. You have information about the flower, like sepal length, sepal width, whatever that means. I'm not a botanist. So, what I want to do is I want to see if I can find clusters in that dataset.
44:42
So, the first thing I would actually like to do is to resize Visual Studio. So, that's what I'm going to do here. I'm going to read these guys. I'm going to read my dataset into a type I just created here. And this is not usually important.
45:02
So, I'm going to fire up VegaHub. So, now what this is going to do is it should fire up the browser. Victory. So, that already didn't bomb. I'm very happy. And here, what I can do now is live. This is using essentially a D3, Vega, and a signal R. And so, now the browser is here, and I can start sending things to the browser as I want. So, for instance, I can do something like, hey, give me a scatter plot.
45:23
And you're going to take the data, and I want X to be petal width, Y to be petal length, and use the class to color, and use the other one for size, and that's the type of thing I get. And I think this is kind of cool, because now what I can do is, okay, how about the other variable? This is also nice because I have types.
45:41
So, I can actually see what I have available here. So, I can say, okay, let's show this guy, and let's see how it looks. And hopefully, so I'm still colorblind, but hopefully you can see there should be three different colors and three different clusters on the screen. I should probably... Yeah, so hopefully this shows I have three clusters.
46:03
So, what I would want is to apply my clustering algorithm and see actually three clusters. So, I'm going to speed up a bit on this for the sake of time, but essentially, the point I would like, if I had more time, and if you look at the code, which is actually online, you would see that this maps pretty much directly what I described before,
46:22
which is, like, I'm going to have a clustering, I'm going to have two steps, like assign centroids to the point, update the centroids to the point, and recursively repeat until this is done. So, that's really my clustering algorithm, and the higher point is, like, this is not a completely trivial algorithm, it's like 30 lines of code, it's done, not even that, like 25.
46:43
And now, I can just apply it to my dataset here. And I'm going to see if it works, actually. Let's do that. So, now is the moment where I'm hoping things are going to... Ha! Did you see that?
47:01
So, I'm going to do it again, because I like moving things. So, first, you should still have three colors or three clusters, and you have big blobs here, and these are my clusters. And what I'm going to show is, what you should see is the centroids are moving as you go. So, you see the algorithm updating, and they are actually moving to the right places,
47:20
so you see how the algorithm is progressing. And so, I think that's kind of what I have on the clustering part. So, let me close that guy. I'm actually very happy it didn't explode. And so, the part of it is that I want to have enough time
47:43
for the typewriters, because I think that's a big deal, and I want to have enough time on that section. So, typewriters. If you recall the step of the algorithm, it was step two, three, blah, blah, blah. We're doing things with data. The problem is that you have a step one,
48:01
and the step one is to get data. And if you listen to people talking about machine learning, and you go to meetups and all of this, people go talking about parallel algorithms and GPU and the latest craze they do. And the thing that nobody tells you, which is the sad truth, and maybe I shouldn't tell you, the dirty secret is that you're not going to spend much time
48:21
creating fancy algorithms. If you do machine learning, you're going to spend most of your time cleaning up data and getting data which you can work with. And that's kind of the unsexy part of machine learning, and it's kind of a janitorial work. And it's really time-consuming, and it's really important,
48:40
because really, if you have no data, you have no learning. So, now, that's a bit problematic, because at that point, you have a bit of a trade-off. It's nice because you write code in whatever language of your choice, and at the moment you're working in your language, you're happy, you have your compiler and all of this, everything is the types you expect.
49:02
But the problem here is you're trying to get data from the rest of the world, maybe a CSV file, maybe SQL, maybe JSON, whatever, and that's not in your type system. And so, now, it doesn't know anything about your class, doesn't know, like, it's a JSON thing, like it's a piece of text. And so, now, you have a choice between two things, and neither of them is really fun.
49:20
The first one is that you can say, that's fine, I'm going to kind of ignore the types, and I'm going to use a dynamic language. And I think that's why people like Python. There is an upside to it, it's like, hey, you don't have really much types, so it's like you can hack at whatever you want and be optimistic, and if it works, it works. The downside is, like, really, the compiler is not doing much for you, because the only way you will know if it works,
49:41
actually, the only way you know it didn't fail is if you run it and it doesn't explode. That's the best you can get, right, because you don't really have types. On top of that, it's like, well, so that's not great. It's easy to get stuff, but you have no idea if it works. The other side is that you can take a language, maybe like C-Sharp, where you have static types, and the benefit is, like, the opposite.
50:00
It's like, yeah, it's safe, the compiler is going to help you, it's going to tell you, hey, you told me it should be an int, it's actually a string, something is not right. The problem here is, like, to do that, you're going to have to use, typically, something like an ORM, or like, I'm sure you guys are all fans of Entity Framework, like, all these big things, which are just like, you have to use tons of scaffolding to get there. So that's not cool.
50:20
It's not fun, because I have two bad solutions to choose from. And so this is where type operators are absolutely awesome. Type operators kind of resolve this magically, and you're going to get the easy hacking you would get from Python with the performance and all of this coming from static types. So rather than talk more about it, I'm going to demo a bit of type providers
50:41
and show you, go from the obvious ones to the crazier ones. So the obvious one, so the prototypical usage for a type provider is like, you have data, the data has some form of a schema, so it's a mechanism which is... Of course, that would happen.
51:03
I should still be fine. So while Visual Studio is resulting... So what a type provider does, it's a mechanism, like, a bunch of them ship out of the box. There is a big library of type providers, open source ones, but the thing which is nice is that you can write your own.
51:22
If you have a schema, you want a type provider, you can write it. Like, it's an open, extensible mechanism. And the way it's going to work is like... So let's see. The way it's going to work is the type provider is essentially going to look at the schema, look at that and infer, like, given what you gave me, I think the types you mean are this,
51:40
and it's going to create everything for you and give you types. So I'm going to demo this on... Yes. See, like, it exploded, but not where expected. It was a surprise. So good. So we are back here. So I'm going to open F Sharp Data, which is the biggest open source collection of type providers.
52:01
I'm going to start with the most obvious example. So, like, in any project, like, at some point, you know that you're going to hit a CSV file. It's kind of the grand idea of all NoSQL storage technologies. And at some point, you know the accounting department is spitting out a CSV file or something like that. And I'm sure that all of you guys have written,
52:22
at some point, a CSV parser. I'm sure you can do it. It's not very difficult. At the same time, it's a bit of a waste of time. So this is where, like, a type provider is nice, because I'm going to use the CSV type provider to look at that file, which is the passenger list for the Titanic. And it's not that I'm particularly morbid, but I do like this dataset.
52:40
And so that guy has, like, pretty typical, has headers, like passenger ID, did that guy survive, was it a first-class, second-class, or third-class age? And so here I can see that survives is 0 or 1. It's probably actually Boolean and coded as a 0 or 1. Here I see that I have probably doubles, I have strings, I have missing data.
53:00
So, you know, like, your bread and butter, like, poorly, like, painful file to deal with. So you could go ahead and write your own parser, or you could do something like that. You could say, hey, I'm going to use the CSV provider, and it's going to provide me types, and I'm just going to do, like, you look at that file, titanic.csv, and that's going to create a type Titanic. Great. Done.
53:21
And then I can do, now I can simply say, use this, get the data, grab the first one. And so at that point, it's like I created my, the parsing is done, the types are done, and now I can do something with this first, dot, dot. Come on. Uh-huh. Uh-huh.
53:40
The magic is not happening. This is a... Ah, here we go. Well, that's proving the point that it's doing it lazily, I guess. So what we'll see in a second, normally, either that or, like, Visual Studio is going to explode on me again, which would be highly unpleasant. Uh, okay, so I will stop on this guy.
54:02
So under normal circumstances, let's say, like, you saw it happen, and what you should see happening... What you should see happening here is you should see that it created actually a full class. I'm going to try it again because this is really upsetting.
54:21
Okay, yeah, you'll have to trust me for this. Like, I'm actually not sure what happened. But it's going to create properties, and the properties will have all the right types. Like, the survived should be a boolean. The doubles are doubles, and all of this, so your parsing is done. So let's say that it's a successful... Let's ignore a bit the fact and then move on to the fact that this was a completely successful demo.
54:40
And so you have that type of typewriter for JSON, for XML, for SQL, like, all your classic things where you have a schema which describes the data. That's a standard one. You have some which are a bit more crazy. Like, the World Bank typewriter is, for instance, pretty interesting. So the World Bank is this institution which does lots of bank things, like whatever banks do,
55:01
or whatever the World Bank does, but it's also known for collecting tons of statistical information. Are all my typewriters dead? Oh, it looks like... Okay, you know what I'm going to do? I'm going to just restart Visual Studio here. So what the World Bank does,
55:21
it also publishes lots of information about countries everywhere in the world, like with economic data and all of this. And what the typewriter is going to give you... It's going to give you... I hope I will not have to ask you to imagine this again.
55:40
It would be nicer if it worked. But under normal circumstances, it's just going to give you all that information at your fingertips. Okay, so let's see.
56:01
Ah, here we go. Ah, I'm so happy. So what I can do here, for instance, here in one line I created a data context, and the data context is connecting live over the wire to the World Bank, like there is no magic, no nothing. And if I do World Bank dot, now let's read... If I put World Bank dot in the right place,
56:21
this will show me things like this. Hey, the World Bank, can you give you countries, regions or topics? I'm going to take countries. And now I could say countries dot, and it's going to help me discover what data I have available. So if I did countries, I could say Afghanistan, blah, blah, blah. Let's say I'm in Norway. I don't really know much about Norway, so I'm going to say Norway, North Africa, Norway, Norway, Norway.
56:43
Here we go. And so what do I want to know about Norway? I want to know some things, but maybe I could start with the capital city. And so here I'm going to do that. I'm actually going to load all the stuff I should have loaded before. And so what you will see here is that what this did is that it hits over the wire the World Bank,
57:00
got me like, hey, here's the list of countries you have. Here is Norway, and it got me like the capital city, which I believe is returned correctly as Oslo. So that's neat. It's very awesome. I could ask questions which are more interesting. And so the capital city is not mind-blowing, but the thing which is kind of cool is like this one. I could say countries dot Norway, not Namibia.
57:22
Actually, I could do Namibia too. And here I could say what about the indicators? So I could start looking at things like what could I want to know about Norway? I could want to know about the benefits for the first 20% of the population. I could type a D maybe, and I could want to know about the deck alternative conversion factor, whatever the hell this is.
57:40
I could go to Z, and I could get the bank Z score. Like, I mean, this is unbelievable. Like this, what I have here is I have, I think, 2,000 series. And if I did something like population, for instance, point of sale terminals, see, that's... I'm not going to do that one. I'm going to do population.
58:00
So I could ask, for instance, for the population in 2000, let's say 2005, and this is, again, going to go over the wire, go to the World Bank and tell me the population of Norway in 2005 was like 4 million people. So I don't know if this is true, but that sounds... No, that's right.
58:21
Just in case there is a half person, like... So that's starting to be a bit more cool. So now you can start to go a bit crazier. So I mean, the thing which is impressive about this one, if you think about it, it's going over the wire, and on the fly, it's going to create classes and all that stuff for you with nothing, no ORM, like, no stuff.
58:41
This is like, when you start thinking about this, this is mind-blowing. Like, my head melts every time I think about what's happening here. So now you can push the idea a bit further, and you can say, hey, that's great, like, data has a schema, I can get types. I could really... How about other languages? Like, a language is also something which has a schema, and I could also start to do things with it. And so, like, one guy at Blue Mountain decided
59:02
that maybe you could do type provider to R. So R is like this statistical package. It's like a language created by statisticians for statisticians. So as a language, it's like pretty awful. But it does also some stuff for statisticians. Like, I can now here use R from within F Sharp.
59:21
So it's going to give me things like, hey, you can see what packages you have. I see I have matrix, I have boot, I have, like, graphics. So now it's like R is included, like, came magically inside F Sharp, and I can start using it with, on top of that, the benefit of types. So that's pretty cool. So I can start merging it with maybe some F Sharp code.
59:42
So here what I'm going to do is I'm going to, for instance, create a list of random numbers, and I'm going to say, hey, take that, and that's F Sharp type, and send it to R. So let's do it. And now what I will see in a second is I can see a little window here, and boom, like, this just... Now I'm talking to R live and, like, seamlessly from F Sharp.
01:00:01
And the place which is really, really neat is that you could say that's great, but really I could also use R instead of using F sharp. I was like, why would I use R from F sharp? The thing which is nice is what I can't do from R is use the other type providers. So for instance, what I could do is I could say, hey, I'm going to take every single country from the World Bank, pull these guys, and retrieve the population in 2000.
01:00:22
Done. So that's happening over the wire, nothing to do. And then I'm going to put it in a data frame, and I'm going to send it to R. And so now I get the best of both worlds. I can use data from JSON, data from here, data from there, and here I see a little blink which tells me that R did its job, and I'm going to get things like that.
01:00:41
And so if you think about the amount of work you would have to do otherwise to do this, this is awesome because I like the map in R. I like the data from the World Bank. I can just tack, tack, tack, tack, take it left and right, and it's all working. And the beauty is I could probably do that in Python as well, but I would make typos all the way, probably, because I type poorly.
01:01:01
And here I get also compiler help, I get IntelliSense, all of this. So this is really brilliant. I really like type providers. So let me wrap this up and go back to my slides to conclude. So what I hope I showed was that now you get all the benefits of dynamic
01:01:21
and all the benefits of static. So my conclusion is that one, FSharp is a really nice fit for machine learning on .NET. Functional style is great for machine learning. The REPL is making the difference, is crucial in your experience. It integrates with everything you have in .NET. It's a language also which is great because with the REPL, you can do flexible exploration,
01:01:42
but it's also .NET code. So I can also promote my script, put it into a library, and I can now run it in production. So that's nice because it's flexible, but it will perform like a champ if you put it in a real system, which is not always the case with other languages. And type providers are just like a story no other language has, except maybe Idris.
01:02:01
I hear they do something like that. So you get static types without any of the problems. So this is awesome. My recommendation to you guys is as a software engineer, do yourself a service and take a look at machine learning and data science. Maybe you won't like it, but you should probably look at it because it's a very fun area, lots of things are happening there, and these guys also need software engineers.
01:02:21
So it's a fun place to be, and it's actually less difficult than what you might think. And if you do it, I would recommend you do it with a functional language. And if you're in .NET in particular, I would argue that you should really be doing it with F-Sharp. Otherwise you should probably. And beyond that, I showed you one take on F-Sharp and why it's awesome,
01:02:40
but today this room is going to be packed with good stuff. There's going to be Xamarin with F-Sharp with Rachel Rees, Quake with F-Sharp with Will Smith, and there will be something awesome in Erlang with Natalia Chichina later. So if you enjoyed what you saw, stay, and there will be more in different directions. And get involved. The community is awesome. Go to fsharp.org and find us on Twitter.
01:03:02
And if you loved it or if you hated it, you can rate me using the right card. And it's a test. So I'll give you a hint on what the right solution is. And that's what I had for you. So if you want to contact me, this is me on Twitter. This is my email, and come talk to me.
01:03:22
And thank you guys for coming also early today. I'm super excited. Thank you.
Empfehlungen
Serie mit 2 Medien