Label

struct defined in module FastAI


			Label(classes) <: Block
setup(LabelMulti, data)

Block for a categorical label in a single-class context. data is valid for Label(classes) if data ∈ classes.

See LabelMulti for the multi-class setting where an observation can belong to multiple classes.

Examples


			
			
			
			block
			 
			=
			 
			

			Label
			(
			
			[
			
			"
			cat
			"
			,
			 
			
			"
			dog
			"
			]
			)
			  
			# an observation can be either "cat" or "dog"
			

			
			@
			test
			 
			
			

	
			FastAI
			.
			

	
			checkblock
			(
			block
			,
			 
			
			"
			cat
			"
			)
			

			
			@
			test
			 
			
			!
			(
			
			

	
			FastAI
			.
			

	
			checkblock
			(
			block
			,
			 
			
			"
			horsey
			"
			)
			)

You can use setup to create a Label instance from a data container containing possible classes:


			
			
			
			targets
			 
			=
			 
			
			[
			
			"
			cat
			"
			,
			 
			
			"
			dog
			"
			,
			 
			
			"
			dog
			"
			,
			 
			
			"
			dog
			"
			,
			 
			
			"
			cat
			"
			,
			 
			
			"
			dog
			"
			]
			

			
			block
			 
			=
			 
			

	
			setup
			(

			Label
			,
			 
			targets
			)
			

			
			@
			test
			
			 
			block
			 
			 
			

			Label
			(
			
			[
			
			"
			cat
			"
			,
			 
			
			"
			dog
			"
			]
			)