craft ai AI-as-a-service enables your services to learn every day: provide a personalized experience to each user and automate complex tasks.
The end goal: automate the light in a room based on motion sensors and time. Using craft ai, this simple application learns when each household prefers the light to be turned when a motion is detected.
- Download or clone the sources from GitHub,
- Install Node.js on your computer (version 6.9 is recommended),
- Install dependencies by running
npm installin a terminal from the directory where the sources are.
- Create a new project using this link. You can see that you now have two tokens : the "Read API token" and the "Write API token". Only the latter will be used here. These tokens allow you to authenticate your calls to the craft ai API as explained in the documentation.
- In the cloned/downloaded repository, create a
.envfile. Fill it with the line
CRAFT_TOKEN=followed by the Write API token of your project. It should look like this:
The following will:
- create an agent,
- add a bunch of context operations from the example dataset,
- compute a decision tree and
- take a few decisions.
> npm run start
What do next ?
Now that you know how to compute your decision tree, you are able to complete the initial goal: automate the room's light using actual devices.
You can use the devices input to add context operations in real time and compute a decision when the context changes that can be used, in conjuction with its confidence, to turn the light on or off.
About the dataset
This starter kit uses real data extracted from a public dataset.
The dataset "twor.2010" was made available by the CASAS group of Washington State University; the original dataset can be found here. It comes from a house with 2 residents, gathered around 1 year (2009 - 2010) academic year. This house is equipped with sensors like motion, light, temperature, door, etc, in all the rooms.
The pre-treated data are already computed and available for this example.
We only use the movement sensors and the light sensor from one room: the bedroom of one of the residents. From the original data, we selected the desired sensors: one lightbulb and several motion sensors that we merge to a unique indicator counting the number of sensors detecting movements.
If you want to pre-treat by yourself, you could run:
> npm run prepare_data.
The result will be set in
src/prepare.js, you can check out this file to see what we've done and make your own preparation.
The craft ai user documentation can be found at https://beta.craft.ai/doc and technical questions can be sent by email at firstname.lastname@example.org.