<s> """<STR_LIT>""" <EOL> from __future__ import print_function , unicode_literals <EOL> import json <EOL> import os <EOL> import sys <EOL> import sklearn . datasets <EOL> from sklearn . cross_validation import train_test_split <EOL> def main ( ) : <EOL> """<STR_LIT>""" <EOL> print ( '<STR_LIT>' , end = '<STR_LIT>' ) <EOL> boston_data = sklearn . datasets . load_boston ( ) <EOL> sys . stdout . flush ( ) <EOL> print ( '<STR_LIT>' ) <EOL> sys . stdout . flush ( ) <EOL> X = boston_data [ '<STR_LIT:data>' ] <EOL> Y = boston_data [ '<STR_LIT:target>' ] <EOL> examples = [ { '<STR_LIT:id>' : '<STR_LIT>' . format ( i ) , <EOL> '<STR_LIT:y>' : y , <EOL> '<STR_LIT:x>' : { '<STR_LIT>' . format ( j ) : x_val for j , x_val in enumerate ( x ) } } <EOL> for i , ( x , y ) in enumerate ( zip ( X , Y ) ) ] <EOL> examples_train , examples_test = train_test_split ( examples , test_size = <NUM_LIT> , <EOL> random_state = <NUM_LIT> ) <EOL> print ( '<STR_LIT>' , end = '<STR_LIT>' ) <EOL> for examples , suffix in [ ( examples_train , '<STR_LIT:train>' ) , ( examples_test , <EOL> '<STR_LIT:test>' ) ] : <EOL> boston_dir = os . path . join ( '<STR_LIT>' , suffix ) <EOL> if not os . path . exists ( boston_dir ) : <EOL> os . makedirs ( boston_dir ) <EOL> jsonlines_path = os . path . join ( boston_dir , <EOL> '<STR_LIT>' ) <EOL> with open ( jsonlines_path , '<STR_LIT:w>' ) as f : <EOL> for ex in examples : <EOL> f . write ( '<STR_LIT>' . format ( json . dumps ( ex ) ) ) <EOL> print ( '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
