Analyzing Top Runner Performance from A to Z with AI using Workspace

Philip Schouiners walks through DataCamp Workspace's AI assistant analyzing his Strava running data. He uses natural language prompts to generate Python code for cleaning data, computing metrics like average speed, and building visualizations including scatter plots and regression lines. The AI excels at rapid code generation but sometimes needs human fixes for syntax errors.
Chapters
Foreign.
And thank you for joining today's webinar. My name is Risa and I'm going to be your moderator today. We're going to kick off today's session in a couple of minutes. We're just waiting so everyone has a chance chance to join. In the meanwhile though, we'd love to hear from you. So let us know where you're joining from using the chat or the comments, depending on what platform you're watching from. And yeah, tell us something that you'd like to learn from today's webinar. A few bits of housekeeping before we kick off. The session is being recorded and the recording will be emailed to anyone that's registered on Data Camp. You can still do that now if you head to the registration links towards the events on social platforms. So yeah, get registered and we will send you the recording as soon as it's ready. Outside of that, we are using Workspace today, so if you don't have an account for Workspace already, please get one set up. And yeah, I'll also be sharing a link to allow you to code along with us shortly. And I'll also be putting a QR.
Screen QR code on screen. Jeez. Brilliant.
I'll be back to repeat these messages for any new joiners shortly, but until.
Then, enjoy the background music. Sam. Foreign.
And thank you for joining today's webinar. My name is Rhys and I'm going to be your moderator today. We're going to kick off today's session in about 20 seconds or so. We've just been waiting so everyone has had a chance to join. Let us know where you're joining from using the comments or the chat, depending on what platform you're watching on. And yeah, tell us something that you'd like to learn in today's webinar. If you have any questions as well throughout the session, let us know in the comments in the chat and we will save them for for the Q. A few bits of housekeeping for anyone that's just joined as well. The session is being recorded and the recording will be available for re watch on the social platform that you're watching on as well as on Data Camp. And if you've registered for the event, we will send the recording to you.
Via email as well.
We are using Workspace today, so if you don't have a datacamp Workspace account, please sign up for one. And shortly I will be sharing a.
Link so that you can code along.
With us in today's session.
Brilliant.
I think that's everything from me. So I'll hand you over to your host for today's session. Elena. Elena, please take it away.
Hi everyone and welcome to today's webinar on analyzing Top Runner performance from A to Z using datacamp Workspace. As a fellow data scientist myself, I would say that one of the most fascinating use cases of generative AI is its ability to to understand tasks in human language and translate them to code. This enables self serve analytics literally for everyone, even those without prior coding backgrounds, and boosts productivity for data experts, helping them code faster and with less effort. Today, Philip Schouiners, VP of Engineering at datacamp Workspace will showcase a real time example of how AI can enable faster time to insight on data analysis tasks. You will be able to code along in your own workspace notebook as well. Without further ado, I'll hand it over to Philip to guide us on how to use AI to write higher quality code faster. Take it away, Philip.
Thanks so much Helena for that kind introduction. Yeah, so let's do it. Let's analyze Top Runner performance from A to Z with AI using Workspace. So just real quick overview of what you'll like, what we'll cover in this session. The data we'll be working with is from Strava, which is a very common app for people that are doing sporty activities. So we'll use Strava activities data. In fact, it's going to be my Strava activities data, so I'm quite an avid runner, as we'll see from the data. But you'll also see that you can get like there's also instructions on how you can get an export yourself from Strava and then basically rerun the analysis with your own Strava data, which is always a bit more fun. Of course, if the data is relatable. The primary goal we're going to do is exploratory data analysis on Strava runs to uncover trends and personal bests and to see our consistency over the years, et cetera. And the secondary goal, and then that's also what Alena already alluded to, is to experience the power, but also sometimes the limitation of what AI can do for coding. So it's massive improvements or like it's a massive shift in how we do data science using the AI assistant. There's also times where you have to watch out and definitely vet what the AI is generating because it can also be wrong in subtle ways sometimes. Why did we try to do this case study? I think doing EDA is A very good use case of EDA is a very good example of where an AI can shine. And the fact that we're doing it on Strava data. It's real data, it's relatable data, and that's so much more fun, right? Aren't we all tired of analyzing Titanic data? So that's what we'll do as Rhys has just sent shared a message in the chat. You can code along with us in a Data Camp workspace. So it's basically a link that is going to copy a workspace that I prepared for you. And that's exactly what I'm doing right here. So I dropped this link address bar and that creates a new workspace for me. If you click on the link that Rhys has shared with you, you will see the exact same as what I'm seeing here. So basically a new workspace should be created. That same code along analyzing Top Runner performance from A to Z with AI using workspace should be created for you. Right? This already has the data set that we'll be using. So basically this activities CSV file, that's a CSV file that I got from Strava after asking for an export. This is something you can do yourself. There's a link to the instructions on how you can do this travel export, but this takes a while. You're not going to get that link, you're not going to get that export in 2, 3 minutes. This can take north of 30 minutes. I wouldn't do this right now. I would say for now, just follow along with the activities CSV file that I have made available inside this workspace. So basically the activities from my Strava profile. But if you feel like, if you're keen on trying this with your own Strava data, you can always do that later time. Basically just unzip the file that you download from Strava, drop the activities CSV file inside workspace and basically rerun the analysis. Of course, you might need to tweak a bit depending on the kind of activities you're doing on Strava, et cetera, but that's something you can do later. So I hope everybody's ready. I will try to go slowly but steadily through all of the different challenges we'll try to solve here. You can try to code along as I'm doing this. Everything is set up for you, the data sets available, Python is available, all the packages are available. So basically, let's get to it. Right, so first step in a typical export or data analysis task is of Course importing and prepping the data in question. So we already have the activities CSV file in place. I'll make the screen somewhat bigger. So to make sure that everybody can follow along and we can import the CSV file. I already provided the CSV file in question. So let's do that. And we can just click run, right? That's going to execute the Python code. Oh, and of course I have to first run the different package imports here and I'm going to execute the Python code. And what we immediately will see is that there's a lot of rows, 510 rows. So that basically corresponds to 510 activities with an activity ID, an activity date. It turns out that the first activity that happened, if we start ascending the first activity that happened is April 2, 20, 2021. No, I think the activity date, it's not sorting by date because it's just a simple string. How we currently read the CSV, that's something we already need to fix. It's like May 3, 2019 is the last one. And if we then fast forward to the last result here, it's August 29, 2021. But that's because there are some rows that are truncated. Because there's so much data in the CSV, not everything is being printed out. We're seeing activity id, activity date, activity name, activity type, all of these different things. Also relative effort, which is like a strava specific thing. Activity gear, like if you're using certain shoes for your run, athlete weight, something I'm not very keen on sharing. I hope it's not in there. Elapsed time, moving time, distance, max speed. So there's a bunch of stuff in there. What we're actually going to do in the first step, like there's a lot of stuff in there. But we are interested in time spent in activities, kilometers that were run so that we can calculate average speed, we're interested in the dates. We can also see if there's certain trends in the date. So the first thing we'll do is basically zoom in on the columns that we want. And that's why I prepared a bit of data for you here. So I listed out some positions of relevant columns. So it's position 0, the activity ID, the activity date, activity name, type description, those kind of things. I keep also 16 and 20, that's related to the moving time in the elevation gain. So basically how much meters that you rise in your run. So if you for example, like run up and down a hill that you basically make elevation, those kind of things. I basically have a list of columns and also a corresponding name. So we have nice and clean names. So what we'll do here is basically use this use calls array and this names array inside the PD readcsv function and you can look up the documentation for this to basically just a moment to basically filter out exactly what we need. Right? So we have PD read TSV activities. TSV header equals 0, means the header column. The first row is actually the name of the different columns. And then we're going to say the activity date. I want you to parse that as a date. So that's column one, that's activity date. We want to parse that as a date, as you can see here. So the header is zero and we're going to say use the columns in use calls. So basically only look at those columns and then the names for those columns. We assign names like this. If we run this code we will already get trimmed down versions. Right now we have a nice and clean data frame. Activity id, activity date, activity name, activity type, distance in kilometers, moving time in seconds and elevation gain. What you saw here, like I was a bit, I did this a bit on purpose. Distance, kilometers, moving time in seconds. Because that's useful as the more descriptive the names of the title, like the names of the columns are, the better. In the next stage the AI will be able to figure out and to reason about these, these values of columns. If I would just say distance, what is it? Is it feet, Is it meters, Is it kilometers, Is it miles? The. The AI doesn't necessarily know and right now I'm saying it's distance in kilometer and the AI will use that. So for example, if we have to calculate speed in the next step, as for example kilometers per hour, the AI will figure out, okay, it's in kilometers, moving time is in seconds. Have to do these and these and these calculations to convert it into the proper speed calculation. Right? So now that you have this data frame, there is a couple of cleanups we can do. So we said before we were going to analyze Top Runner performance. So we want to look at records inside this data frame that only have the activity type that is equal to run, right? So we can use our python skills for this. Like we can do a simple filtering with Pandas, but what we can also do is ask the AI, right? So I'm going to ask the AI over here and I'm going to say filter the data frame DF to only look at. To only keep activity types, to only keep activities with the type Run and let's store the results in a variable runs. I'm doing enter here. The AI is basically typing for me. If I accept a suggestion and run it, I can also print that out. Of course. What do I get? Indeed. Before we had 510 rows. Right now we have 423 rows. And if we go through the activity type, we see it's only runs that we keep. So all of the runs that we did are being kept. But for example, walks and swims and bike rides, those are all being thrown out. All right, cool. That's the first cleanup we did. Now there's also another problem, or that's something else we can verify is basically, let's have a look and add a piece of Python code to see what the different types are of this runs data frame. What we see is that distance kilometer is an object, but it should be a float. This is being treated as an object, but it should be a number so that later on we can do some calculations with this. So that's why it's saying here like we should convert distance kilometer to a float and calculate the average speed. Again, as this code long is called. Analyzing top running performance with AI. Let's use AI for this. Right? Going to AI and I'm actually the instruction I'm going to try to put it in. Basically convert this, this kilometer to a float and calculate the average speed. Start the result in runs clean. Let's see what gives. All right, so first thing it's doing, it's copying runs into runs clean. Then it's creating a new column. Or it's basically overriding the distance kilometer column with the distance kilometer column replacing a comma by nothing and then converting it into a float. Let's see if that's correct. And then it's calculating average speed kilometers per hour and then doing runs clean kilometers divided by runs clean moving time seconds divided by 3600. And that's where it comes in here. It saw it's in seconds. So I have to divide it by 3,600 to get it in kilometers per hour. Let's see how it looks. So indeed, the distance kilometer seems to be correct, where before it was also showing 10.50, 12.21, 10.74 is also 10.5, 12.21, 10. 74. And then the distance, the average speed in kilometers per hour has been calculated based on the distance in kilometers and the moving time. And it also seems to look right, like these are average running speeds that make sense. Let's maybe Just get rid of this one for sake of cleanness and run it again. But this looks good, I think. All right, cool. And then just as a verification, let's run the runs dtypes function again. This command again to see if now distance kilometer is still an object. Of course I have to look at runs clean, not at the runs. So runs clean dtypes distance clong floats. Great. So we managed to clean that one up. Right. So our control execution, we're going to get rid of that. So I'm going to click on delete to keep my analysis a bit clean. All right, cool. So, quick recap what we did. We imported the data frame activities CSV. We zoomed. We actually redid that read CSV call to zoom in on exactly the columns that we needed, specifying names for these columns that are sensible, that includes a unit so that the AI better knows how to handle those. And then we did some cleanups. We basically converted distance kilometer to a float. We converted. We basically create a new column, average speed in kilometers per hour based on distance in kilometer moving time. And now we have actually a clean data frame that we can start exploring. All right, so as a first one, let's analyze some distances, right? Let's see, for example, how much time that we ran, not how much time, basically how much total kilometers that we ran every single year. Right? And basically see if there's like a trend there, whether there's more running going on or less running going on. Right again. So the instruction here is create a plotly bar chart that compares total distance runs per year. Let's see. Right, let's ask the AI, rather than typing this ourselves. Let's see, let's see. All right, there we have it. So let me quickly accept and run this, which I can do in one go here by clicking Accept and run. Invalid syntax. Let's see, let's see. So it's distance per year Runs clean equals runs clean. It should be. Let's see if now it runs. All right, cool. Again, every time I use this, I'm part of the team that's building this. But every time I'm doing this, I'm pretty much in awe of what this is capable of. This figured out that it needs to use runs clean. It did a group by the activity date the year, so it filtered. It basically took out a year bit from the activity date timestamp and basically group by that and then did a summation. So basically total distance run, did a sum of that, reset the index so that the group by is not the index, but it's just a regular column. And then it went on to create a plotly bar chart showing activity date, which is this year here, and then distance in kilometers on the Y axis. And what do we see in 2019? I know I was running more, but I didn't have like a watch yet, like one of these sports watches yet that was connected to Strava, so it was underreporting. I was running in 2020, I started getting that watch and in 2021, 2022, that's when I had that watch and that's when you see it going up. In 2021, I was clearly more avid at running than in 2022 with 1600km run and then in 20202400 and now in 2023. It's not entirely honest because in 2023 we are still not. We didn't do the full year yet, so that it's a bit hard to compare that. But we could for example, do somehow like an estimation, knowing that from August. But what I'll do now, maybe I can do a minor change. I can say set the color for the bars of the year 2023 to a lighter shade. That's something I can tell my AI. It's basically reviewing what we have here and what it's doing. It's setting the color for the bars of the year 2021, 2023 to a lighter shade. Let's see whether this worked out. Oh, I'm not seeing that. Activity date is 2023. So this is an example where the AI didn't necessarily did a extremely good job of improving the code or writing the right code we wanted. Right. So. Update traces marker colors, lighter blue. For the selector. So this is. This is not the right result. So actually the right way to do this is using basically specifying a color for all of these. So we can do colors equals. So you can say default color is. We can do black, for example, which is RGBA0001. And then the last year color we can do something else. We can do like a lighter kind of black, for example, 0.0.2. And then for the colors we have 2019-2020-2021-2022, 20, the default color four times. And then the last year color like this. And then we can do marker color equals colors. If this was a bit too much typing, just know that if you can, you can head over to the file section, go to Notebook Solution and get the solution notebook. And also there you'll find some functioning code to make this, to make this change slightly different, but I think this is a bit more comprehensible. So here we basically manually set certain colors. And if we rerun this now what we see is the first bars, we're giving that default color black, and then the last bar, because that's an incomplete here. That's now in gray. Right. So that's something we could do here. But this was an example of the AI. Like I gave an instruction to the AI, but maybe my instruction wasn't that good. Maybe the AI tripped over it and wasn't able to do it. So this definitely happens. And this is like a lesson in making sure that you're being critical about what the AI is generating and you try to understand what the AI is generating. All right, good. So we see definitely like some, some active running years in 2021, 2022, 2023 is off to a good start. But I think it's. It's also a bit less. If we like, if we extrapolate a bit, it's probably not going to reach the levels of 2022 yet. But I still have time to make up for that. What we can also do is just say, since tracking stuff in Strava, how much did I run? And to basically show a cumulative area plot. Right. So again, I'm going to copy this comment, going to click on AI. I'm going to ask create a cumulative area plot showing total distance run. I'm going to say plotly area plots because I like plotly as a plotting library. I'm going to click run again. Oh, not run. Of course. I have to hit enter to get the AI to generate something. Something. I noticed what the AI is consistently doing is consistently importing plotly Express spx, even though I already did that at the top. So I can easily just strip that out without a problem. Right. You only have to do that once. Importing the packaging question or the library in question. Except and run. Let's see. Oh, bam. There we have it. Great. So what do we see? We see indeed like 2019, 2020, but then in our cumulative kilometers run they go up and up and the increase is slightly lower for 2023. But we still need some more here. Actually, we shouldn't do this on a per date basis. It's using distance per year. But actually we should just use runs clean, I think. So if we do runs clean, Runs clean. Runs clean. That's better because we were using the previous data frame that was doing it on a per year basis. And then it was like A very saggy line. But this is actually showing a better indication. Like every day that you did an activity, it's going up, up, up, up and up. Right, Very cool. Great. Now, as a last one of analyzing, like distances run, what we can do is showing the total distance per month in the year 2022 to see if there's like a very big difference. For example, I'm living in Belgium. In wintertime, it's particularly hard to get out of the heat of the house to go for that run. Whereas in summertime it's easier to go for a run. Let's see if some of that rings true to me. So what we can do is show the total distance per month in the year of 2022. Again, let's ask the AI. Show the total distance on a plotly plot. Use the runsclean data frame. Is there another instruction we can give the AI in this? Let's see. I hit enter to ask the AI to come up with a response. Let's see. So again, it's importing plotly express. We don't need to do that. It's creating a new data frame, runs 2022, then looking only at runs of the year 2022. That's perfect. So that's good. Then distance per month in 2022, it's grouping by the months and then looking at distance kilometers again, summing that again doing the reset index. So that's the same that we saw before. Nan's creating a bar chart. So activity dates, we can rename that to activity date, that's fine. But he's labeling that to month and total distance kilometers. This looks good. Let's see what it gives. Bam. There we have it again. I'm amazed. Right. I basically typed two sentences, natural language, just in English, and it generated exactly the code that I wanted. This is showing me that indeed, February and March were definitely not the months where I ran the most. Also May, for some reason, I'm not sure why that is. It's been quite a while. And then around October, around April, those were particularly intense months where a lot of running happens, like an average of 40 kilometers a week. So. All right, cool. At this point, we imported the data, we did a bit of EDA on the distances, and I'm going to take a quick pause to see if there's some questions that I can already answer in the meantime, before we go off to some next EDA steps.
Yeah, sure, Philip. We do have two questions so far. And the first question is, is AI assistance only available for Python?
No. It isn't so in workspace. It's a great question by the way. In workspace you can create workspaces and we work in Python, but you can also work in R. So if you switch here to R and if you then ask the AI stuff, the AI will generate R codes also inside workspace. We're not doing this inside this code line, but you can also create SQL cells right inside workspace and for example, connect to a sample database like bicycle sales. You can also ask the AI here to generate code and in that case it will generate SQL code. And even you can create a markdown cell. And also here you can ask the AI to generate text. So the AI is able to write Python code, R codes, SQL code, or even just text. So you can say for example, like hey, I want to start doing a data analysis on analyzing runner performance. Can you write me a quick introduction? You can ask the AI to do that and immediately the text will appear right here. You know what, let's try. I'm saying this hypothetically. Let's try. So I can go to the top here. Maybe I already did a summary, but I can say I'm doing a code along on analyzing Strava. Aditya, can you write a quick introduction about Strava and how cool it is that you can use AI to analyze Strava data? If I do this, so it's going to say Strava is popular social fitness platform that allows at least to track and share their activities, blah, blah, blah, blah, blah. It's writing quite a lot, I think. So if I accept this and I view this, I basically have an introduction here. I can also say, hey, that's a bit wordy. Can you be more succinct? Feel free to use some emojis. All right, if I accept this, then it's way shorter. Okay, now we. I'm already saying he like it's not a person. The AI it now it decided to use a lot of emojis. That's a bit, that's a bit of emoji overload. But fine, right, like this is a case in point. You can basically use the AI inside workspace to generate text codes or in Python and SQL.
Perfect. That's so cool. And we have two more questions which are pretty similar. So could you uncover a little bit of the background behind this technology? Basically, I guess everyone is interested. Is it ChatGPT that is powering workspace, AI assistance of or like how do we integrate AI into Python?
Yeah, yeah, yeah. So yes, we're using the OpenAI API. To give you a bit of indication about how this is working, I created this overview some other time. Like I showed this in another webinar or live training. I did. Where am I? AI Assistant. Here you have an overview of how it currently works. So you of course can also go to chat.OpenAI.com and start talking to ChatGPT, right? You can also say like, hey, I want to analyze some data, blah, blah, blah. You can do that, definitely. But the special thing that Datacam does, the special thing that workspace does, is basically adding more context on there. So when you, for example, say you connect to a database on ticket sales, as in this example here, and you, for example, ask how many events are happening in different cities, we're not just sending that message to OpenAI, we're basically saying, hey, I need you to write a SQL query that answers the following question. How many events are happening in different cities? The ticket sales database that you are connected to has these databases. These databases have these columns, These columns have these types. These are data frames that you have already. These are data frames that the user has already defined in this workspace. These are the contents of those data frames. This is the code that the person has already written. So we basically expand the question that you're asking. We basically embellish it or enrich it with more context that's happening inside the notebook to improve the quality of the results, we're sending that over to OpenAI. OpenAI is coming back and saying, hey, here's the SQL code you need for that. And that's what we then show in the interface. And that's actually where the power lies and where we're constantly tweaking the system is in how we're engineering that prompts. So how we are building up more context that we're sending over to OpenAI. Some of it is relevant, some of it is not relevant, but that's where the true power lies. And that's where actually using the AI, right? Inside workspace is way more powerful than using the AI standalone, where you're just going into ChatGPT, it's like, hey, write me some code to do this and this and this and this, and then copy pasting that over to workspace. Because inside workspace, when you're using it inside workspace, we're sending along all of this context for basically adding more layers of context to the query you're sending before sending it to OpenAI.
Cool, cool. And I think also it's worth mentioning that we do not send directly the database contents to OpenAI. So we only send the metadata for the database or for the data frame that you have.
That's also explained in this article. Indeed. So what data is being shared with OpenAI? So to go back here, we never sent the fact that August 8th there was a lunch run and it was an activity type run. We never sent that. What we do send is there was a data frame with activity id, activity, date, activity names, basically the names of the columns we sent those, the types of the columns we sent those. But then the actual records of that data frame we do not send. We sent the name of a variable, but we don't set the contents of that variable. So we only send hints and contexts. That hopefully gives high quality results. But we never sent the actual contents to OpenAI.
Amazing. So let's get back to our exploratory analysis.
All right, perfect. Thank you. Great questions. All right, so we analyzed some distances. Now I getting a bit wound up about these plotly imports. We don't need those because we already did that at the top. Also, something else that the AI tends to do is always assigning the bar chart to a figure and then doing fig show. But since we're doing this in an interactive context, we can also just get rid of the fig show. So this should work exactly the same way. All right, cool. Something else that I was wondering is like, how am I progressing here? Right? Am I progressing over time? Is my average speed of running? Is that improving over time? Of course, you can run 5km faster than you can run 20 because you have to hold on for longer. You don't have to hold on for as long. That's why I decided maybe let's look at a subset of the runs. Basically runs between 13 and 20k. And look at how is this average speed for these activities progressing over time? So it's saying show average speech for activities with a distance between 13k and 20k. Let's drop it into the AI, but I think we can do a bit better with the prompt here. Like this is a bit too not very descriptive. So we can say show average speech for activities with a distance between 13 and 20k over time. We can say use runs clean. That's a data frame from the past. And maybe spice it up. Use plotly. Probably want to have a scatter plot in this case. And then use some splashy colors, not the typical blue. Let's see. Boom. Just going to accept and run at this point. I'm just curious what it gives. All right, it did go for the boring Blue, unfortunately. Let's see if we can change something about it. It's also showing the activity type run, which is not really necessary. It's coloring by activity type run, but that's the only activity type, so it's not very useful to do that. It's very nicely filtering out runs that are bigger than or equal than 13 or smaller than or equal than 20. Just think about it like writing this would have taken at least three times longer than writing the query here at the top. And it's basically just generating it. I'm still reviewing what the AI is typing, but it's so much faster. Right, so then it's creating a scatter plot, filtered runs, activity dates, average speed, kilometers per hour. Let's get rid of this activity type. Let's run this again. All right, so it's got rid of the legend because it was unnecessary. And let's say use. Red instead of blue for the dots on the scatter plots. All right, so also tailoring, tailoring what the graph looks like. That's also something you can do with the AI. In my experience, what I typically tend to do is the AI is getting me like 80% of the way there. And if I then want to start tweaking what the, the graphs look like before, I want to put them into a very nice looking report, for example, because these are still pretty basic graphs before like for tweaking. That's typically when I would head out to the data to the documentation, make a couple of small changes based on what I see in the docs. But you can also try to ask the AI, Right? The AI will also look at what your previous code was and then suggest small updates to it here I didn't have to repeat the entire sentence that I used before. I just said hey, use red instead of blue for the dots. So that's pretty great. And what do we see? Actually we still have to do a bit of an analysis here. We're seeing a low that's actually very recent. I was in Switzerland and I had to do a lot of height meters. So that's in July. We had an average speed of 8 kilometers per hour. And then we have a pretty high speed one, so 13.5 kilometers per hour somewhere in May 2022. And what do we see? We don't really see an upwards trend. Maybe let's try to add like a linear regression. Add a linear regression line on top of the plotly plot to see if there's an upwards trend. Let's see, let's see. This broke this Broke. This broke Filter transactivity date. Let's see if we can fix and explain the error with AI. I'm curious now, I'm no longer really following what's happening at this point. Let's first see if we can get. Oh, there we have it. Oh my God. It's amazing. So let's try to decipher what the AI did here. So here, nothing changed. Convert activity data numeric values. Okay. Yeah, for linear regression, you can't just have timestamps for the regression. So it's basically converting it to a numeric and it's using that for a fit. And yeah, we see it kind of broke here. Like the date it was converted to milliseconds, I think. So there's very big numbers. Like that's the amount of milliseconds that happened since the start of the computer's counting somewhere in 1970. So there's like the. We kind of messed up our X axis here. But we do see a of lot positive trend. It's not very outspoken, of course. Like running 13k, running 20k looks still quite a big difference. It's not a very outspoken trend, but there seems to be a light upward strength here. You can also get rid of the name linear regression to make it slightly better. Oh, another bracket and clicking run. Yeah, so it's same trace one. Let's not worry about that too much. But again, I would have no clue of how to do a linear regression. I just asked it to. Then the AI made a mistake. But then I used AI again to fix and explain the mistake and it managed to do it somehow. But still I see the code that the thing is that the AI is writing. I can review the code that the AI is writing. I can basically still tweak it. I can look into it myself. So it's still relevant that you know how to write these things. But just writing it all out yourself, that's way less important than in the past, like from before generative AI. All right, now just a couple of records. Just see like, hey, what is the activity with the highest average speed? Right. Ask the AI again. Find the activity to the highest average speed in runs cleaner. So in the clean runs. Let's see. Okay, that's not very good. It's just saying like it's the midwinter jogging. Can we do find the row in runs clean with the highest average speeds. So it's looking only for the activity name, but I want to have the full details. Let's see if this is better. Okay, this is already Better. So it basically did a lock looked for the index of the row average speed to kilometer per hour with the highest average speed. And what we see is like the activity name that was indeed like a running a competition was only 5.25 km. So that's quite obvious that that was the highest average run. It took a little over just north of 20, 20 minutes and the average speed was 15.65 here. That's what we see. So that was like the fastest run. Now let's look for the run with the highest elevation gain. So find the record in runs clean with the most with the highest elevation gain. Again, I don't need to write any code myself. Let's see. Accept and run this. Bam. That was very recent. Actually only a couple of days ago I was running in the mountains. I did 17 kilometers an elevation gain. So basically how much meters it rose was 577. Speed of course because you have to run upwards is way lower than for example the record time here and total accumulative distance. I'm not sure what this means actually. Oh, cumulative distance. That's a leftover from here is cumulative distance. So it basically added it onto runs clean. But that's something we shouldn't look at here. That's basically when this event happened. 2570 kilometers were run in the past already. But that's completely irrelevant. Okay, cool. So we have some records. So this should also give you an idea of what kind of analysis you you could do yourself as well. And then the last one which I think can be quite interesting is identifying patterns in basically when do I run during the day? I remember like back in the day to typically run in the evenings. Maybe other people are like lunchtime runners. Maybe other people are morning runners that even before they go for before they have some food, they already run. How about me? And how does this change over time? Right, so it's saying build a graph to see if the time of day that run that runs were started has changed over time. Let's see. I think this is too high level of a question to ask the AI, but let's see. Right. Then let's have a look. Accept and run. I would be surprised if this ran. This is already quite close. I think so Number of runs by start hour overtime. Let's see what it did. So it converts activity date to a date time, which I think it already is. But not sure if that's too big of a problem. Then it's extracting the hour from the activity date column. So it's basically stripping the day, the month, etc. It's just looking at the. The hour in the day that this happened. Then group the data by year and start our and count the number of runs in each group. So it's looking at the year and then the hour counting number of in each group. That also sounds good. And it's pivoting the data to have the years as a column and the start hour as an index also sounds fine. And then it's showing this. I think it makes more sense if this were bar chart. Use a bar chart instead. So it's just converting that. If we do that, what do we see? This is pretty hard to disambiguate. Right. Like let's say let's use plotly instead and show different years and different facets. So facets are like. Like these subplots that allow you to more easily compare patterns like this and different facets use three facets per row. I'm not sure if that's actually the right way to say it. Yeah, of course. Quite a lot of edits here. Let's see what gives a. Right. So, so, so what's this thing here? It feels like the data for 2019 and 2020 is quite thin. So drop the. Drop the records in runs clean that are in 2019 and 2020 and also use one facet per row. That that's going to probably be nicer. So again going over all the code again. Doing some thinking. I'm going to do accept and run here. Oh, errors. Let's first see without thinking maybe it can fix the code itself. Let's see if it figures it out. Didn't. It didn't. So there are. There are moments when we're trying to ask to too tricky a question that we. That we can run out of like that the AI basically isn't able to figure it out. Let's try rows three. Maybe that works. There we have it. Nice. So there was something wrong here with making subplots based on the error was saying something like rows equals two columns equals one. But I was seeing three titles so I thought okay, probably it's three rows and one column and then it matches the number of arrays, the number of elements in this array and then it iterates over each year adds a bar chart to the corresponding facets and its number of runs here. Right. So what do we see? Oh, but it's dropping 2022. Oh, but that's something that I typed wrong. Oops. Drop the records and runs clean. I should do 2021. 2022. And then also do here, 2021, 2022. That's going to be better. Let me get rid of the AI start hour. Still something not entirely right. Oh, is in. Not is in 2019 and 2020. This is probably also not the best code. If I would write it from scratch myself, that's probably not how I would write it. And then it's also overriding runsclean, which is something I don't really like. So right now, because I did a bit of a mess up, I have to rerun the code that generates runsclean. So I have to rerun this one because it's overrid. Like it didn't overwrite in place of runsclean. If I now rerun this, it should look better, but it doesn't, unfortunately. Start our. It's also using the start hour from runsclean, probably or no start hour. Huh. Did we already use start our before? I don't think so. Let me add a calculation for start hour. Maybe add Python code. All right, maybe that's what we need. What's up with the split? No. Based on activity date, of course. Sorry, I'm getting a bit tired here. Based on activity date. Yeah, now it's getting the hour. So I can use this piece. Drop it in here. I can drop this one. I can run this now, I hope. Should be good. I'm not sure why this is grayed out a bit like this. Whoa. Not sure what happened here. I think I. I think I went to the. To the previous screen in my browser when we see number of runs by start hour overtime. Okay, this looks good. Right, so we see the activities for the year 2021, the activities for the year 2022, the activity for the years, the number of runs for the year 2023. Basically the pattern over time. So what you see is in 2021 there was quite a lot of runs, more than 30 that happened at 4pm, then quite a lot that happened at 10am and then here there's also a bit of a spike. So here there's also a time zone problem still. I think the dates are in utc where I'm in the Brussels time zone. That's two hour difference. So it's true that I tend to go running over lunch and then I also sometimes go running after, after work. So that seems to correspond. And there seems to be a shift here. So in 2021 I was doing a lot of after work running and in 2022 I shifted to like doing some runs in between. In between my two blocks of work. This is getting quite personal anyways, but this was just another way. Again, this is quite convoluted, quite impressive Python code that the AI was able to churn out. It wasn't perfect from the start. Still things to improve, still some small tweaking, still some small debugging that needed to happen, but still quite impressive, I would say. Let's just make sure that this all runs from top to bottom so I can click run to rerun this notebook from top to bottom, all over. And that should run perfectly fine, of course. All right, cool. That's it. So this is what I had in store for you. This was just showing how you can get to work with real relatable data about sports activities. But of course, anything goes, right if you have data on anything that you find interesting, anything related to your job that you can put into a tabular data frame, get started, click on the AI icon, ask it a question, see how far it brings you, and basically be amazed by the results. We did quite an, quite an intensive analysis in less than an hour. Literally. Like we started, we started at the hour, now 50 minutes past the hour. We answered some questions in the meantime. I did some explanations in the meantime. It's quite mind blowing all the things you can come up with in such a short time frame, but always with the caveat, the AI can be wrong in obvious ways, but also in subtle ways. And we always have to realize or we always have to review what AI is generating to figure out if the code actually makes sense. So yeah, that's what I had. Maybe you can answer some more questions if there are any.
Sure, sure, there are some more questions, but before we get into them, I wanted to say that you can actually get a lot of beautiful dashboards boards on Strava, especially if you log in via your desktop. But you have to pay a lot for this subscription and actually you can use workspace, do this like data export and dive as deep into your running, swimming or whatever kind of sport data as you basically want. So, yeah, excited to repeat this analysis myself on my own data set later on today. And now let's cover some of the remaining questions and we have a very great question. Basically, do people who learned coding the traditional way now have an advantage over the people who will be coding with the assistance of AI? It's a very, very tricky question. What, what do you think, Philip, on that?
It's a very good question. Do you, Do I have to answer? No, I'm joking. I think it relates a bit to, to like, I'm A trained software engineer. And what you hear there is lots of like the people that are in the, in the profession of engineer for a longer time or like in their 40s or something. They always reminisce about the times when I was still programming and like the programs were punch cards, like basically cards with holes in them. And that's how we wrote programs. And it was like a very low level way we had to deeply understand how our program was running. And there weren't all these abstractions of things like Python for example, which is an abstraction of C, which is an abstraction of C, which is an abstraction of a kernel language. These people are very close to the bare metal and how computations happened. And you can say, yes, these people more deeply understood how a program ran. But in the end it also matters how well you can work with the tools that are available to you. So how I look at AI is just this additional layer of abstraction around Python codes that you can use natural language to service. You don't have to write Python code to execute commands. You can write English or like a language of your choice to generate the Python code for you. So it's basically a layer of abstraction extra to answer the question, because I'm going off topic a bit is do they have an advantage? I think it just depends on. I think you can also leverage. If you're like AI native, so to say, and you learn coding with AI, I'm sure that you will find innovative ways to have the AI also teach you about the subtleties of certain code that is generating something that somebody that is not leveraging AI by default will be able to do. So I would say not, but just be smart with tooling that is available to you.
Great, great. I also feel that when learning data science and when I was learning data science myself, I would often get stuck not being able to fix a bug or an error. And I remember once fixing a bug for a month and they literally couldn't find an answer on stack overflow. And now like with this fixed error capabilities, I feel that learners, those who are just entering this field of data science can move much, much faster. And if you want to learn how to steer AI and like learn how to do proper prompts for ChatGPT, how to work with, I don't know, generative AI APIs, you can check out our brand new AI curriculum, just head over to data Camp courses and search for new AI courses and you will find a lot of goods, like a lot of best practices, how you can already leverage AI in your workflows and applications are endless.
I would say, yeah, something to add there maybe is for the AI. You can think of it as the advanced calculator. And we all know how to use a calculator, but we all know that three times three is nine. And you have basic intuition around how calculating works. How do some numbers subtract numbers? You're able to say if you use a calculator, like you're doing some, some multiplications or some summations, you can say like, this looks off, right? My intuition tells me this looks off. This looks a bit fishy. That's because you ever like you, at some point you learned how to sum numbers, subtract numbers, get a sense for this, the size of numbers. I think with AI is the same. Like you can ask the AI to do complicated things, but you have to be able to think critically about what the AI is generating. But it's a tool, it's here. I think it's going to change drastically the way we work. So you better start adapting to this new reality and make sure that AI, like wherever, whatever you're doing, always think like, hey, can I help me do this? And leverage it whenever, whenever relevant.
True. Can't agree more. We have time for one more question. That's the last question. So how can someone without coding background use a workspace AI assistant effectively? Philip, any tips for that without coding background?
I think at this stage we're still working hard in making the AI assistants more powerful, but at this point having no coding skills whatsoever inside workspace. I think workspace is still a product that requires you to write code and I think some intuition around code is necessary. So I'm not sure if I would recommend people to just use the AI only if they don't know how to use Python or R. We are working towards that future where indeed I can show what this could look like, where you create a workspace, you create an empty workspace and you just ask AI to write stuff and you never see the code. It automatically executes the code. You see the results. Like, we're working towards that future. But for now, I think we're still at the stage where the quality of the AI is not always 100%. You still need to have that intuition around Python code to be able to reason about, hey, does this make sense? Yep, it's working on. It's working on it. I think that's the dream that we want to leverage the power of AI to just lower the barrier into being able to doing data analysis, into being able to get insights from Data to leverage AI to lower that barrier there. Right. And we're working on it, as you saw. Like we already did way more in way less time, but I think there's more we can do to basically remove more of the. Do more abstraction, only look at the Python code when it's really necessary rather than showing it by default and those kind of things.
True, true. Thank you so much, Philip, for showcasing the real life example how we can use AI to solve an analytics task. I encourage everyone to try AI Assistant yourself. I mean, it's really amazing. I've been using AI Assistant a lot for my projects at Data Camp and I actually managed to compile analysis without writing a single line of code myself and only prompting AI. I do have some coding background, but still it was possible for me, so go and explore it yourself. Also, if you want to learn how to steer AI, make sure to check our brand new AI curriculum and stay tuned for the upcoming webinars and code along sessions. Yep. Thank you Philip. One more time and see you next time.
Yeah, it was a lot of fun. Thanks all for joining in and hope to see you soon.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







