pyspark/bigdl/dataset/movielens.py
def read_data_sets(data_dir):
    """
    Parse or download movielens 1m  data if train_dir is empty.

    :param data_dir: The directory storing the movielens data
    :return: a 2D numpy array with user index and item index in each row 
    """
    WHOLE_DATA = 'ml-1m.zip'
    local_file = base.maybe_download(WHOLE_DATA, data_dir, SOURCE_URL + WHOLE_DATA)
    zip_ref = zipfile.ZipFile(local_file, 'r')
    extracted_to = os.path.join(data_dir, "ml-1m")
    if not os.path.exists(extracted_to):
        print("Extracting %s to %s" % (local_file, data_dir))
        zip_ref.extractall(data_dir)
        zip_ref.close()
    rating_files = os.path.join(extracted_to,"ratings.dat")

    rating_list = [i.strip().split("::") for i in open(rating_files,"r").readlines()]    
    movielens_data = np.array(rating_list).astype(int)
    return movielens_data
def read_data_sets(data_dir):
    """
    Parse or download movielens 1m  data if train_dir is empty.

    :param data_dir: The directory storing the movielens data
    :return: a 2D numpy array with user index and item index in each row 
    """
    WHOLE_DATA = 'ml-1m.zip'
    local_file = base.maybe_download(WHOLE_DATA, data_dir, SOURCE_URL + WHOLE_DATA)
    zip_ref = zipfile.ZipFile(local_file, 'r')
    extracted_to = os.path.join(data_dir, "ml-1m")
    if not os.path.exists(extracted_to):
        print("Extracting %s to %s" % (local_file, data_dir))
        zip_ref.extractall(data_dir)
        zip_ref.close()
    rating_files = os.path.join(extracted_to,"ratings.dat")

    rating_list = [i.strip().split("::") for i in open(rating_files,"r").readlines()]    
    movielens_data = np.array(rating_list).astype(int)
    return movielens_data
def read_data_sets ( data_dir ) : WHOLE_DATA = 'ml-1m.zip' local_file = base . maybe_download ( WHOLE_DATA , data_dir , SOURCE_URL + WHOLE_DATA ) zip_ref = zipfile . ZipFile ( local_file , 'r' ) extracted_to = os . path . join ( data_dir , "ml-1m" ) if not os . path . exists ( extracted_to ) : print ( "Extracting %s to %s" % ( local_file , data_dir ) ) zip_ref . extractall ( data_dir ) zip_ref . close ( ) rating_files = os . path . join ( extracted_to , "ratings.dat" ) rating_list = [ i . strip ( ) . split ( "::" ) for i in open ( rating_files , "r" ) . readlines ( ) ] movielens_data = np . array ( rating_list ) . astype ( int ) return movielens_data
Parse or download movielens 1m  data if train_dir is empty.

    :param data_dir: The directory storing the movielens data
    :return: a 2D numpy array with user index and item index in each row
Parse or download movielens 1m data if train_dir is empty .