2016-04-23 7 views
0

私は同じ教示機能の異なる威力を渡して、異なる多項式回帰モデルを作成しています。Graphlab - OverflowError:変換が長すぎる

したがって、フィーチャ 'x'の次数3の多項式モデルが必要な場合。回帰モデルでは、x^1、x^2、x^3をフィーチャとして渡しています。

次の関数は、 'x'のべき乗のSframeテーブルを作成するために使用されます。それに渡された 'x'の値から、作成する必要がある度数を計算します。

def polynomial_sframe(feature, degree): 

# assume that degree >= 1 
# initialize the SFrame: 
poly_sframe = graphlab.SFrame() 

#poly_sframe['power_1'] equal to the passed feature 
poly_sframe['power_1'] = feature 

# first check if degree > 1 
if degree > 1: 

    # then loop over the remaining degrees: 
    # range usually starts at 0 and stops at the endpoint-1. 
    for power in range(2, degree+1): 

     #give the column a name: 
     name = 'power_' + str(power) 

     # then assign poly_sframe[name] to the appropriate power of feature 
     poly_sframe[name] = feature.apply(lambda x: x**power) 

return poly_sframe 

上記の関数から生成されたSframeを使用します。私は、Xの異なる次数に対して異なる多項式を生成することができます。次のコードに示すように、

Graphlabは、次数4のモデルを生成することができます。それ以降は失敗し、次のコードの場合。オーバーフローエラーが発生したことを示します。

poly15_data = polynomial_sframe(sales['sqft_living'], 5) 

my_features = poly15_data.column_names() # get the name of the features 

poly15_data['price'] = sales['price'] # add price to the data since it's the target 

model15 = graphlab.linear_regression.create(poly15_data, target = 'price', features = my_features, validation_set = None) 

--------------------------------------------------------------------------- 
ToolkitError        Traceback (most recent call last) 
<ipython-input-76-df5cbc0b6314> in <module>() 
     2 my_features = poly15_data.column_names() # get the name of the features 
     3 poly15_data['price'] = sales['price'] # add price to the data since it's the target 
----> 4 model15 = graphlab.linear_regression.create(poly15_data, target = 'price', features = my_features, validation_set = None) 

C:\Users\mk\Anaconda2\envs\dato-env\lib\site- 
packages\graphlab\toolkits\regression\linear_regression.pyc in create(dataset, target, features, l2_penalty, l1_penalty, solver, feature_rescaling, convergence_threshold, step_size, lbfgs_memory_level, max_iterations, validation_set, verbose) 
    284       step_size = step_size, 
    285       lbfgs_memory_level = lbfgs_memory_level, 
--> 286       max_iterations = max_iterations) 
    287 
    288  return LinearRegression(model.__proxy__) 

C:\Users\mk\Anaconda2\envs\dato-env\lib\site- 
packages\graphlab\toolkits\_supervised_learning.pyc in create(dataset, target, model_name, features, validation_set, verbose, distributed, **kwargs) 
    451  else: 
    452   ret = _graphlab.toolkits._main.run("supervised_learning_train", 
--> 453           options, verbose) 
    454   model = SupervisedLearningModel(ret['model'], model_name) 
    455 

C:\Users\mk\Anaconda2\envs\dato-env\lib\site- 
packages\graphlab\toolkits\_main.pyc in run(toolkit_name, options, verbose, show_progress) 
    87   _get_metric_tracker().track(metric_name, value=1, properties=track_props, send_sys_info=False) 
    88 
---> 89   raise ToolkitError(str(message)) 

ToolkitError: Exception in python callback function evaluation: 
OverflowError('long too big to convert',): 
Traceback (most recent call last): 
File "graphlab\cython\cy_pylambda_workers.pyx", line 426, in graphlab.cython.cy_pylambda_workers._eval_lambda 
File "graphlab\cython\cy_pylambda_workers.pyx", line 171, in graphlab.cython.cy_pylambda_workers.lambda_evaluator.eval_simple 
File "graphlab\cython\cy_flexible_type.pyx", line 1193, in graphlab.cython.cy_flexible_type.process_common_typed_list 
File "graphlab\cython\cy_flexible_type.pyx", line 1138, in graphlab.cython.cy_flexible_type._fill_typed_sequence 
File "graphlab\cython\cy_flexible_type.pyx", line 1385, in graphlab.cython.cy_flexible_type._ft_translate 
OverflowError: long too big to convert 

私のコンピュータに回帰モデルを計算するメモリがないため、このエラーはありますか?このエラーはどのように修正されますか?

答えて

0

それはあなたがこの行の末尾にタイプミスを持っているように思える:(販売[ 'sqft_living'] 5) poly15_data = polynomial_sframe 15へ

変更5とそれが動作するはずです。