Hi there! I am currently doing a project that utilizes decision trees and random forests, and I had a quick question. Can decision trees and random forests be used in iOS apps or apps in general? An example would be if the two types of machine learning were able to predict future water quality and their predictions were then displayed in an app. If so, how might it be accomplished? Thank you!
[Administrator note: project url for the machine learning project at Science Buddies: https://www.sciencebuddies.org/science- ... ved_oxygen ]
Predicting Future Water Quality with Machine Learning
Moderators: AmyCowen, kgudger, bfinio, MadelineB, Moderators
-
SwrDes
- Posts: 4
- Joined: Sun Dec 01, 2024 7:22 pm
- Occupation: Student
-
calixte
- Student Expert
- Posts: 49
- Joined: Tue Oct 01, 2024 9:42 pm
- Occupation: Student
Re: Predicting Future Water Quality with Machine Learning
Hello!
Decision trees and random forests can be used in IOS. To do so you first train the model on your computer using data and machine learning tools like Python's scikit-learn. After training, you convert the model to a format that works on iOS using Apple’s Core ML tool. Then, you add this model to your iOS app using Xcode and use it to make predictions. Good luck!
Decision trees and random forests can be used in IOS. To do so you first train the model on your computer using data and machine learning tools like Python's scikit-learn. After training, you convert the model to a format that works on iOS using Apple’s Core ML tool. Then, you add this model to your iOS app using Xcode and use it to make predictions. Good luck!
-
SwrDes
- Posts: 4
- Joined: Sun Dec 01, 2024 7:22 pm
- Occupation: Student
Re: Predicting Future Water Quality with Machine Learning
Hi!
Thank you for the help! I had another quick question. According to the instructions on the project page, it seems like the training of the model is already accomplished without Python. Should I still use Python sci-kit or is there another way to directly export the results to my app?
Thank you for the help! I had another quick question. According to the instructions on the project page, it seems like the training of the model is already accomplished without Python. Should I still use Python sci-kit or is there another way to directly export the results to my app?
-
SwrDes
- Posts: 4
- Joined: Sun Dec 01, 2024 7:22 pm
- Occupation: Student
Predicting Water Quality With Machine Learning
Hi! So, I've downloaded the ipnyb, and am currently running it, but when I get to code block 4A is says that there is an error. The error says KeyError: "['Date', 'Average Dissolved Oxygen +4 weeks mg/l'] not found in axis". I am not able to solve this error and I was wondering if there is any way to fix this, as my final sheet does have those two properties.
-
amyCC
- Site Admin
- Posts: 405
- Joined: Wed Apr 01, 2020 4:02 pm
- Occupation: Moderator
- Project Question: *
- Project Due Date: *
- Project Status: Not applicable
Re: Predicting Future Water Quality with Machine Learning
Can you take a screenshot of the output after running block 3B that shows the column names (showing that column name that is giving you an error).
I just ran through the notebook, and I'm not seeing an error with running 4A or 4B. So we need to look back at your data.
In step 1 of the directions, sub-step 10, you renamed all of the columns in the spreadsheet. Make sure you named it this way: Average Dissolved Oxygen +4 weeks mg/l and make sure that the location you pulled data for has data in the column.
Seeing a screenshot of your 3B will help.
(Also, remember that if you stopped and came back to your notebook at any point, you will need to run all the prior cells again.)
Amy
Science Buddies
I just ran through the notebook, and I'm not seeing an error with running 4A or 4B. So we need to look back at your data.
In step 1 of the directions, sub-step 10, you renamed all of the columns in the spreadsheet. Make sure you named it this way: Average Dissolved Oxygen +4 weeks mg/l and make sure that the location you pulled data for has data in the column.
Seeing a screenshot of your 3B will help.
(Also, remember that if you stopped and came back to your notebook at any point, you will need to run all the prior cells again.)
Amy
Science Buddies
-
SwrDes
- Posts: 4
- Joined: Sun Dec 01, 2024 7:22 pm
- Occupation: Student
Re: Predicting Future Water Quality with Machine Learning
Sure! Here is my code for 3B and 4A.
- Attachments
-
- Screenshot 2025-02-17 122151.png (108.38 KiB) Viewed 11452 times
-
- Screenshot 2025-02-17 122014.png (87.6 KiB) Viewed 11452 times
-
amyCC
- Site Admin
- Posts: 405
- Joined: Wed Apr 01, 2020 4:02 pm
- Occupation: Moderator
- Project Question: *
- Project Due Date: *
- Project Status: Not applicable
Re: Predicting Future Water Quality with Machine Learning
Thank you or uploading the screenshots. The first column I see in your 3B screenshot says "Unnamed." That should be your Date column.
Go back to Section 1, step 7.... you should have renamed that column Date there:
Rename these columns in Row 1 as Date (column A), Time (column B), and Temperature (column C).
Please make that change and run the block again.
(It looks like you are missing the Average Dissolved Oxygen column that should show up in 3B. But please relabel the Date column and see what happens when you run the cell.)
Amy
Go back to Section 1, step 7.... you should have renamed that column Date there:
Rename these columns in Row 1 as Date (column A), Time (column B), and Temperature (column C).
Please make that change and run the block again.
(It looks like you are missing the Average Dissolved Oxygen column that should show up in 3B. But please relabel the Date column and see what happens when you run the cell.)
Amy

