in Education by
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)

1 Answer

0 votes
by
Do you need to be using a dataframe? Try converting them into an array beforehand: array = data.values x = array[:,0:3] y = array[:,4] But you should also check out keras for this kind of work.

Related questions

0 votes
    I'am trying to follow this tutorial: ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    I am utilizing the following to find missing values in my spark df: from pyspark.sql.functions import col, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    Currently I'm returning column name of the max value in the each row. df['Active'] = df.idxmax( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    Currently I'm returning column name of the max value in the each row. df['Active'] = df.idxmax( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I have a dataframe as below itm Date Amount 67 420 2012-09-30 00:00:00 65211 68 421 2012-09-09 00 ... solutions would be appreciated. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I want to select rows from a DataFrame based on values in some column in pandas, How can I do it? I ... WHERE column_name = some_value Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I have 2 columns in the python dataframe. I want to check each row in my Column A for any value that ... for this particular purpose. Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    This may sound like a very broad question, but if you'll let me describe some details I can ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have a dataset that only contains y-values in one column. I want to insert a column of x- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    The _________ function returns a list of densities (y) corresponding to bin values (x). (a) Spline (b) ... Out of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Predicting y for a value of x that's outside the range of values we actually saw for x in the original ... Regression of R Programming Select the correct answer from above options...
asked Feb 9, 2022 in Education by JackTerrance
0 votes
    My data looks as follows: ID my_val db_val a X X a X X a Y X b X Y b Y Y b ... JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    Which of the following makes use of pandas and returns data in a series or dataFrame? (a) pandaSDMX (b ... questions and answers pdf, Data Science interview questions for beginners...
asked Oct 28, 2021 in Education by JackTerrance
0 votes
    for my university assignment, I have to produce a csv file with all the distances of the airports of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    for my university assignment, I have to produce a csv file with all the distances of the airports of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
...