Exemple #1
0
def streaming_vw_createcache_modular(fname):
    # First creates a binary cache from an ascii data file.
    # and then trains using the StreamingVwCacheFile as input

    # Open the input file as a StreamingVwFile
    input_file = StreamingVwFile(fname)
    # Default file name will be vw_cache.dat.cache
    input_file.set_write_to_cache(True)

    # Tell VW that the file is in SVMLight format
    # Supported types are T_DENSE, T_SVMLIGHT and T_VW
    input_file.set_parser_type(T_SVMLIGHT)

    # Create a StreamingVwFeatures object, `True' indicating the examples are labelled
    features = StreamingVwFeatures(input_file, True, 1024)

    # Create a VW object from the features
    vw = VowpalWabbit(features)
    vw.set_no_training(True)

    # Train (in this case does nothing but run over all examples)
    vw.train()

    #Finally Train using the generated cache file

    # Open the input cache file as a StreamingVwCacheFile
    input_file = StreamingVwCacheFile("vw_cache.dat.cache")

    # The rest is exactly as for normal input
    features = StreamingVwFeatures(input_file, True, 1024)
    vw = VowpalWabbit(features)
    vw.train()
def streaming_vw_createcache_modular (fname):
	# First creates a binary cache from an ascii data file.
	# and then trains using the StreamingVwCacheFile as input

	# Open the input file as a StreamingVwFile
	input_file = StreamingVwFile(fname)
	# Default file name will be vw_cache.dat.cache
	input_file.set_write_to_cache(True)

	# Tell VW that the file is in SVMLight format
	# Supported types are T_DENSE, T_SVMLIGHT and T_VW
	input_file.set_parser_type(T_SVMLIGHT)

	# Create a StreamingVwFeatures object, `True' indicating the examples are labelled
	features = StreamingVwFeatures(input_file, True, 1024)

	# Create a VW object from the features
	vw = VowpalWabbit(features)
	vw.set_no_training(True)

	# Train (in this case does nothing but run over all examples)
	vw.train()

	#Finally Train using the generated cache file

	# Open the input cache file as a StreamingVwCacheFile
	input_file = StreamingVwCacheFile("vw_cache.dat.cache");

	# The rest is exactly as for normal input
	features = StreamingVwFeatures(input_file, True, 1024);
	vw = VowpalWabbit(features)
	vw.train()
Exemple #3
0
def streaming_vw_modular(dummy):
    """Runs the VW algorithm on a toy dataset in SVMLight format."""

    # Open the input file as a StreamingVwFile
    input_file = StreamingVwFile("../data/fm_train_sparsereal.dat")

    # Tell VW that the file is in SVMLight format
    # Supported types are T_DENSE, T_SVMLIGHT and T_VW
    input_file.set_parser_type(T_SVMLIGHT)

    # Create a StreamingVwFeatures object, `True' indicating the examples are labelled
    features = StreamingVwFeatures(input_file, True, 1024)

    # Create a VW object from the features
    vw = VowpalWabbit(features)

    # Train
    vw.train()
def streaming_vw_modular (dummy):
	"""Runs the VW algorithm on a toy dataset in SVMLight format."""

	# Open the input file as a StreamingVwFile
	input_file = StreamingVwFile("../data/fm_train_sparsereal.dat")

	# Tell VW that the file is in SVMLight format
	# Supported types are T_DENSE, T_SVMLIGHT and T_VW
	input_file.set_parser_type(T_SVMLIGHT)

	# Create a StreamingVwFeatures object, `True' indicating the examples are labelled
	features = StreamingVwFeatures(input_file, True, 1024)

	# Create a VW object from the features
	vw = VowpalWabbit(features)

	# Train
	vw.train()