Saturday, December 21, 2024

Example 1 Data

 

TensorFlow Data Collection

The data used in Example 1, is a list of car objects like this:

{
  "Name""chevrolet chevelle malibu",
  "Miles_per_Gallon"18,
  "Cylinders"8,
  "Displacement"307,
  "Horsepower"130,
  "Weight_in_lbs"3504,
  "Acceleration"12,
  "Year""1970-01-01",
  "Origin""USA"
},
{
  "Name""buick skylark 320",
  "Miles_per_Gallon"15,
  "Cylinders"8,
  "Displacement"350,
  "Horsepower"165,
  "Weight_in_lbs"3693,
  "Acceleration"11.5,
  "Year""1970-01-01",
  "Origin""USA"
},

The dataset is a JSON file stored at:

https://storage.googleapis.com/tfjs-tutorials/carsData.json


Cleaning Data

When preparing for machine learning, it is always important to:

  • Remove the data you don't need
  • Clean the data from errors

Remove Data

A smart way to remove unnecessary data, it to extract only the data you need.

This can be done by iterating (looping over) your data with a map function.

The function below takes an object and returns only x and y from the object's Horsepower and Miles_per_Gallon properties:

function extractData(obj) {
  return {x:obj.Horsepower, y:obj.Miles_per_Gallon};
}

No comments:

Post a Comment

How will AI transform your life in the next 5 years?

 AI is already transforming how we live and work, and over the next 5 years, this transformation is expected to accelerate in several key ar...