I'am trying to follow this tutorial:
https://www.youtube.com/watch?v=G7oolm0jU8I&list=PLIivdWyY5sqJxnwJhe3etaK7utrBiPBQ2&index=3
But since he is importing with old tf functions and he is already importing an heavily altered .csv file, I tried to import the original one, alter it with pandas and then use it in linear-model.
This is what I did:
filename = "iris.data"
data = pd.read_csv(filename, names=["feature1", "feature2", "feature3", "feature4", "target"])
data['target'] = data['target'].str.replace('Iris-setosa','1')
data['target'] = data['target'].str.replace('Iris-virginica','2')
data['target'] = data['target'].str.replace('Iris-versicolor','3')
data['target'] = pd.to_numeric(data['target'])
training_data: pd.DataFrame= data.loc[:120]
eval_data: pd.DataFrame = data.loc[120:150]
Which gives me two pandas dataframe. Now I try to use the training_data in TF:
feature1 = tf.feature_column.numeric_column("feature1")
feature2 = tf.feature_column.numeric_column("feature2")
feature3 = tf.feature_column.numeric_column("feature3")
feature4 = tf.feature_column.numeric_column("feature4")
feat_cols = [feature1, feature2, feature3, feature4]
input_fn = tf.estimator.inputs.pandas_input_fn(
x=training_data[['feature1', 'feature2', 'feature3', 'feature4']],
y=training_data['target'],
batch_size=128,
num_epochs=1,
shuffle=True,
queue_capacity=1000,
num_threads=1,
target_column='targetx'
)
classifier = tf.estimator.LinearClassifier(
feature_columns=feat_cols,
n_classes=3,
model_dir="/tmp/iris_model")
classifier.train(input_fn=input_fn, steps=1000)
This gives me an error because the x and y values are obviously wrong but I can't figure out what they mean, because the documentation about them is short to non existent. Some posts state that x stand for feature columns and y for labels. But this doesn't help me, because coming from pandas I know that labels are the names for the columns, but what are feature columns, bc for me it means the same?!
Could please somebody elaborate what x and y means.
Here is the error:
TypeError: Failed to convert object of type to Tensor. Contents: {'feature1': , 'feature2': , 'feature3': , 'feature4': , 'target': }. Consider casting elements to a supported type.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)