Ich versuche, eine einfache logistische Regression mit Tensor Fluss zu bauen, aber ich diesen Fehler:Tensorflow Typeerror: ‚Serie‘ Objekte sind wandelbar, so können sie nicht gehasht werden
TypeError: 'Series' objects are mutable, thus they cannot be hashed
Das ist mein code:
data = pd.read_csv(data_file,sep=";",names=header)
...
n = data.shape[0]
n_training_set = int(.7*n)
df_train = data[30:n_training_set]
df_test = data[n_training_set:]
LABEL_COLUMN = 'action'
CONTINUOUS_COLUMNS = ['rsi','stochk','stochd']
CATEGORICAL_COLUMNS = []
def input_fn(df):
# Creates a dictionary mapping from each continuous feature column name (k) to
# the values of that column stored in a constant Tensor.
continuous_cols = {k: tf.constant(df[k].values)
for k in CONTINUOUS_COLUMNS}
# Creates a dictionary mapping from each categorical feature column name (k)
# to the values of that column stored in a tf.SparseTensor.
categorical_cols = {k: tf.SparseTensor(
indices=[[i, 0] for i in range(df[k].size)],
values=df[k].values,
dense_shape=[df[k].size, 1])
for k in CATEGORICAL_COLUMNS}
# Merges the two dictionaries into one.
feature_cols = dict(continuous_cols.items() + categorical_cols.items())
# Converts the label column into a constant Tensor.
label = tf.constant(df[LABEL_COLUMN].values)
# Returns the feature columns and the label.
return feature_cols, label
def train_input_fn():
return input_fn(df_train)
def eval_input_fn():
return input_fn(df_test)
model_dir = tempfile.mkdtemp()
CONTINUOUS_COLUMNS = ['rsi','stochk','stochd']
rsi = tf.contrib.layers.real_valued_column(df_train["rsi"])
stochk = tf.contrib.layers.real_valued_column(df_train["stochk"])
stochd = tf.contrib.layers.real_valued_column(df_train["stochd"])
### defining the model
m = tf.contrib.learn.LinearClassifier(feature_columns=[
rsi,
stochk,
stochd
],
model_dir=model_dir)
m.fit(input_fn=train_input_fn, steps=200)
Wie kann ich das beheben?