intel-analytics / BigDL-trainings

Training materials for BigDL
Apache License 2.0
13 stars 16 forks source link

the lambda passed to `ds.map` doesn't compile "SyntaxError: invalid syntax" #15

Open activedecay opened 5 years ago

activedecay commented 5 years ago

Did you mean to pass t and decompose t's members like this?

#convert ndarray data into RDD[Sample]
def array2rdd(ds):
    #build Sample from ndarrays
    def build_sample(c0,c1,c2,c3,prediction):
        feature = np.array([c0, c1, c2, c3]).flatten()
        label = np.array(prediction)
        #print("what ami", Sample.from_ndarray(feature, label))
        return Sample.from_ndarray(feature, label)
    rdd = ds.map(lambda t: build_sample(t[0],t[1],t[2],t[3],t[4]))
    return rdd

iris_rdd_train = array2rdd(iris_k_train)
iris_rdd_train.cache()
print("Training Count: " + str(iris_rdd_train.count()))

iris_rdd_test = array2rdd(iris_k_test)
iris_rdd_test.cache()
print ("Test Count: " + str(iris_rdd_test.count()))

see feedforward-iris.ipynb

activedecay commented 5 years ago

I think the update to python 3 broke many of the ipython notebooks.