Spooky Sale: 10% off Premium yearly · $118.80 for the first year · until Nov 6Get it

Deep-ML
Learn
Problems1,200+ hands-on ML problemsLearning PathA guided route through the fundamentalsLabsInteractive labs on real techniquesProjectsBuild a GPT, an RL agent, CUDA kernelsCollectionsCurated problem sets and videosMathPen-and-paper math for MLIntuitionInvent the idea behind the formula yourselfPlaylistsYour own problem lists, shareableStudy AssistantAn AI teacher that knows your progress
Interview Prep
Compete
ContestsFresh problem sets, ranked liveLeaderboardWhere you stand, globallyBuddiesSolve with a friend: streaks, a weekly board, chat
Discuss
Deep-Path
Premium
      Intuition
      21 of 102

      Colors into numbers

      A model only understands numbers, but your data has a color column: red, green or blue. Write encode(color, all_colors): turn one color into a list of numbers the model can use.

      Three cars and what they sold for. A model only reads numbers, so the colors need numbers, and a model reads a number as an amount. Watch what numbering them red 0, green 1, blue 2 does, then number them another way.

      Three cars for sale, and what each sold for.carsold forits numberred$12k0green$20k1blue$10k2012$0k$10k$20kthe color’s number →↑ priceoff $3koff $6koff $3kencode(color, all_colors) → numbers that put no color between two others?
      Your functionencode(color, all_colors)
      colorone of all_colors, e.g. "green"e.g. "red"
      all_colorsevery color there is, e.g. ["red", "green", "blue"]e.g. ["red", "green", "blue"]
      returnsa list of numbers for this color
      solution.pyLoading Python
      Sign in for an AI hint
      ← Shared interestsWhich words matter? →