For this Code Pattern, we will use data on Wildfires from NASA to predict the intensity of Wildfires, using Watson Studio Machine Learning. NASA provides data for various things, from weather and climate to solar flares and wildfire. This data is paid for by U.S. taxpayers and is free to use. The missing component is machine learning, which can take data and train a model to predict one of the features of the data set. For this example, we'll grab wildfire data and build a model that can predict intensity of the fire base on latitude and longitude.
When the reader has completed this Code Pattern, they will understand how to:
- Use Watson Studio Machine Learning to train a model.
- Gather data from NASA for Wildfires.
- Create a predictor for intensity of wildfires based on latitude and longitude.
- Create a Node.js server that can utilize the Watson Machine Learning service for predicting wildfire intensity.
- Use Watson Studio to add data assets and services.
- Create the Machine Learning Model in Watson Machine Learning.
- User interacts with Web UI to choose location of a fire.
- Web UI interacts with ML model to predict brightness of fire.
- Artificial Intelligence: Artificial intelligence can be applied to disparate solution spaces to deliver disruptive technologies.
- Node.js: An asynchronous event driven JavaScript runtime, designed to build scalable applications.
- Install Node.js and npm (
npm
version 4.5.0 or higher) - For this pattern you will need to download current wildfire data in CSV format. Please choose
7d
for 7 days worth of information. - You may additionally download archived data which will take time due to the request process.
- You will need a Maps API key.
-
[Either Deploy to IBM Cloud or Deploy locally]
3b. Deploy locally
Clone the predict-wildfires
repository locally. In a terminal, run:
$ git clone https://github.com/IBM/predict-wildfires
- On Watson Studio choose
New project
:
and pick Data Science
:
- Name the project and select your object storage:
- Choose
+ Add to project
->Data asset
or click the10/01
button and add the data you downloaded in Prerequisites (MODIS_C6_*_7d.csv):
-
Under the
Settings
tab ->Associated Services
choose+ Add service
->Watson
and selectMachine Learning
. Either choose anExisting
ML Service or create aNew
one. -
Under the
Settings
tab ->Associated Services
choose+ Add service
->Spark
. Either choose anExisting
Spark Service or create aNew
one. -
Under the
Assets
tab ->Models
choose+ New Watson Machine Learning model
. Pick a name, the defaultSelect model type
ofModel builder
, andAutomatic
for "Prepare my data...". -
For
Select Data
choose theMODIS_6_\*_7d.csv
file you added. When finished clickNext
. -
For
Select a Technique
->Column value to predict (Label Col)
choosebrightness
. This represents the intensity of the fire as measured by the brightness detected from a satellite. -
For
Feature columns
choose the features:latitude
andlongitude
. -
For a Technique choose
Linear Regression
and ClickNext
. -
The model will train, and then
Save
the model. -
If you have downloaded archived data, you may create another model using that data using the same process.
-
Once you've created the model, go to
Deployments
and click+add Deployment
. Name it, keep the defaultWeb service
, and clickSave
. Leave this page open for the next step...
-
If you haven't left it open from the previous step, from the Watson Studio project page, under the
Assets
tab, double click theWatson Machine Learning
model you created earlier. Go to theDeployments
tab and double click to open it. -
Go to the
Implementation
tab and copy the Scoring End-point at the top. You will use this asSCORING_URL
in either the IBM Cloud Runtime Environment Variable or the locally deployed.env
file. -
On your Watson Studio project page, got to the
Services
tab on the top menu bar, and navigate to the Watson Machine Learning service you created earlier. Double-click the service, go toService Credentials
->View Credentials
.
-
You will need your Maps API key.
-
You will use the
username
,password
,url
, and 'maps API key' in either the Runtime Environment variables when running on IBM Cloud or in theserver/.env
file when running locally. These will beWML_URL
,WML_USERNAME
,WML_PASSWORD
, andMAP_APIKEY
.
- Press the above
Deploy to IBM Cloud
button, underIBM Cloud API Key:
chooseCreate+
, and then click onDeploy
.
To monitor the deployment, in Toolchains click on Delivery Pipeline
and view the logs while the apps is being deployed.
- Once the app has deployed, Click on
Runtime
on the menu and navigate to theEnvironment variables
tab.
- Update the 5 environment variables with the
SCORING_URL
,WML_URL
,WML_USERNAME
,WML_PASSWORD
, andMAP_APIKEY
that you saved during Get the credentials. The app will automatically restart and be ready for use.
-
In the
server/
directory, move theenv.sample
file to.env
. -
Populate the file with the
SCORING_URL
,WML_URL
,WML_USERNAME
,WML_PASSWORD
, andMAP_APIKEY
that you saved during Get the credentials.
SCORING_URL=""
WML_URL=""
WML_USERNAME=""
WML_PASSWORD=""
MAP_APIKEY=""
-
Install the nodejs modules with
npm install
. -
Start the app with
npm start
. The app will now be running and available on you machine in a browser athttp://localhost:3000
.
- IBM Call for CodeAnswer the Call for Code by building global solutions for disaster preparedness.
- NASA FIRMS (Fire Information for Resource Management)Fires in the last 24 hours.
- Can Scientists Predict a Wildfire's Spread?
- Predict a Wildfire's Behavior in Real Time
- Watson Node.js SDK
- Artificial Intelligence Code Patterns: Enjoyed this Code Pattern? Check out our other AI Code Patterns.
- Data Analytics Code Patterns: Enjoyed this Code Pattern? Check out our other Data Analytics Code Patterns
- AI and Data Code Pattern Playlist: Bookmark our playlist with all of our Code Pattern videos
- With Watson: Want to take your Watson app to the next level? Looking to utilize Watson Brand assets? Join the With Watson program to leverage exclusive brand, marketing, and tech resources to amplify and accelerate your Watson embedded commercial solution.
- Data Science Experience: Master the art of data science with IBM's Data Science Experience
- Spark on IBM Cloud: Need a Spark cluster? Create up to 30 Spark executors on IBM Cloud with our Spark service