Tensorflow - logistic regrssion -oneHot Encoder - Transformed array of differt size for both train and testWhy does logistic regression in Spark and R return different models for the same data?Question about train example code for TensorFlowTensorflow oscillating Test and Train Accuracy?Improve test accuracy for TensorFlow CNNHow to properly rotate image and labels for semantic segmentation data augmentation in Tensorflow?Train, test and submission files - what am I supposed to do with all of them?Logistic Regression doesn't predict for the entire test set
Couple of slangs I've heard when watching anime
LeetCode: Group Anagrams C#
Are there any elected officials in the U.S. who are not legislators, judges, or constitutional officers?
Justifying the use of directed energy weapons
How to make Ubuntu support single display 5120x1440 resolution?
Why do all fields in a QFT transform like *irreducible* representations of some group?
How to respectfully refuse to assist co-workers with IT issues?
antonym of "billable"
Did a flight controller ever answer Flight with a no-go?
Is using a hyperlink to close a modal a poor design decision?
Why is there so little discussion / research on the philosophy of precision?
How do I get a decreased-by-one x in a foreach loop?
What would be the challenges to taking off and landing a typical passenger jet at FL300?
what mathematical functions can we use to generate patterns for rhythm (meter and notes)?
Result of pgmathsetmacro is lost in loop iterations
What do these triangles above and below the staff mean?
Heyacrazy: Careening
Prove your innocence
“T” in subscript in formulas
How is the idea of "two people having a heated argument" idiomatically expressed in German?
Architectural feasibility of a tiered circular stone keep
How can I unambiguously ask for a new user's "Display Name"?
Why did Khan ask Admiral James T. Kirk about Project Genesis?
Is gzip atomic?
Tensorflow - logistic regrssion -oneHot Encoder - Transformed array of differt size for both train and test
Why does logistic regression in Spark and R return different models for the same data?Question about train example code for TensorFlowTensorflow oscillating Test and Train Accuracy?Improve test accuracy for TensorFlow CNNHow to properly rotate image and labels for semantic segmentation data augmentation in Tensorflow?Train, test and submission files - what am I supposed to do with all of them?Logistic Regression doesn't predict for the entire test set
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
x_train = tr1.loc[:, ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width']]
#x_train.shape - (120 x 4)
y_train = tr1.loc[:, ['Species']]
#shape - 120 x 3
x_test = test1.loc[:, ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width']]
#shape 30 x 4
y_test = test1.loc[:, ['Species']]
# shape 30 x 3
oneHot = OneHotEncoder()
oneHot.fit(x_train)
# transform
x_train = oneHot.transform(x_train).toarray()
# fit our y to oneHot encoder
oneHot.fit(y_train)
# transform
y_train = oneHot.transform(y_train).toarray()
oneHot.fit(x_test)
# transform
x_test = oneHot.transform(x_test).toarray()
# fit our y to oneHot encoder
oneHot.fit(y_test)
# transform
y_test = oneHot.transform(y_test).toarray()
print("Our features X_test1 in one-hot format")
print(x_test)
Shape of x_train: (120, 15)
Shape of y_train: (120, 3)
Shape of x_test: (30, 14)
Shape of y_test: (30, 3)
a) After conversion why is the size x_test = 30 x 14 I assume it has to be 30 x 15 ?
# hyperparameters
learning_rate = 0.0001
num_epochs = 100
display_step = 1
# for visualize purpose in tensorboard we use tf.name_scope
with tf.name_scope("Declaring_placeholder"):
# X is placeholdre for iris features. We will feed data later on
x = tf.placeholder(tf.float32, shape=[None, 15])
# y is placeholder for iris labels. We will feed data later on
y = tf.placeholder(tf.float32, shape=[None, 3])
with tf.name_scope("Declaring_variables"):
# W is our weights. This will update during training time
W = tf.Variable(tf.zeros([15, 3]))
# b is our bias. This will also update during training time
b = tf.Variable(tf.zeros([3]))
with tf.name_scope("Declaring_functions"):
# our prediction function
y_ = tf.nn.softmax(tf.add(tf.matmul(x, W), b))
b) did I define x, y, W, b correctly because when I run the accuracy I get this error "ValueError: Cannot feed value of shape (30, 14) for Tensor 'Declaring_placeholder_10/Placeholder:0', which has shape '(?, 15)'
"
tensorflow logistic-regression
New contributor
user80034 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
x_train = tr1.loc[:, ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width']]
#x_train.shape - (120 x 4)
y_train = tr1.loc[:, ['Species']]
#shape - 120 x 3
x_test = test1.loc[:, ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width']]
#shape 30 x 4
y_test = test1.loc[:, ['Species']]
# shape 30 x 3
oneHot = OneHotEncoder()
oneHot.fit(x_train)
# transform
x_train = oneHot.transform(x_train).toarray()
# fit our y to oneHot encoder
oneHot.fit(y_train)
# transform
y_train = oneHot.transform(y_train).toarray()
oneHot.fit(x_test)
# transform
x_test = oneHot.transform(x_test).toarray()
# fit our y to oneHot encoder
oneHot.fit(y_test)
# transform
y_test = oneHot.transform(y_test).toarray()
print("Our features X_test1 in one-hot format")
print(x_test)
Shape of x_train: (120, 15)
Shape of y_train: (120, 3)
Shape of x_test: (30, 14)
Shape of y_test: (30, 3)
a) After conversion why is the size x_test = 30 x 14 I assume it has to be 30 x 15 ?
# hyperparameters
learning_rate = 0.0001
num_epochs = 100
display_step = 1
# for visualize purpose in tensorboard we use tf.name_scope
with tf.name_scope("Declaring_placeholder"):
# X is placeholdre for iris features. We will feed data later on
x = tf.placeholder(tf.float32, shape=[None, 15])
# y is placeholder for iris labels. We will feed data later on
y = tf.placeholder(tf.float32, shape=[None, 3])
with tf.name_scope("Declaring_variables"):
# W is our weights. This will update during training time
W = tf.Variable(tf.zeros([15, 3]))
# b is our bias. This will also update during training time
b = tf.Variable(tf.zeros([3]))
with tf.name_scope("Declaring_functions"):
# our prediction function
y_ = tf.nn.softmax(tf.add(tf.matmul(x, W), b))
b) did I define x, y, W, b correctly because when I run the accuracy I get this error "ValueError: Cannot feed value of shape (30, 14) for Tensor 'Declaring_placeholder_10/Placeholder:0', which has shape '(?, 15)'
"
tensorflow logistic-regression
New contributor
user80034 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
x_train = tr1.loc[:, ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width']]
#x_train.shape - (120 x 4)
y_train = tr1.loc[:, ['Species']]
#shape - 120 x 3
x_test = test1.loc[:, ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width']]
#shape 30 x 4
y_test = test1.loc[:, ['Species']]
# shape 30 x 3
oneHot = OneHotEncoder()
oneHot.fit(x_train)
# transform
x_train = oneHot.transform(x_train).toarray()
# fit our y to oneHot encoder
oneHot.fit(y_train)
# transform
y_train = oneHot.transform(y_train).toarray()
oneHot.fit(x_test)
# transform
x_test = oneHot.transform(x_test).toarray()
# fit our y to oneHot encoder
oneHot.fit(y_test)
# transform
y_test = oneHot.transform(y_test).toarray()
print("Our features X_test1 in one-hot format")
print(x_test)
Shape of x_train: (120, 15)
Shape of y_train: (120, 3)
Shape of x_test: (30, 14)
Shape of y_test: (30, 3)
a) After conversion why is the size x_test = 30 x 14 I assume it has to be 30 x 15 ?
# hyperparameters
learning_rate = 0.0001
num_epochs = 100
display_step = 1
# for visualize purpose in tensorboard we use tf.name_scope
with tf.name_scope("Declaring_placeholder"):
# X is placeholdre for iris features. We will feed data later on
x = tf.placeholder(tf.float32, shape=[None, 15])
# y is placeholder for iris labels. We will feed data later on
y = tf.placeholder(tf.float32, shape=[None, 3])
with tf.name_scope("Declaring_variables"):
# W is our weights. This will update during training time
W = tf.Variable(tf.zeros([15, 3]))
# b is our bias. This will also update during training time
b = tf.Variable(tf.zeros([3]))
with tf.name_scope("Declaring_functions"):
# our prediction function
y_ = tf.nn.softmax(tf.add(tf.matmul(x, W), b))
b) did I define x, y, W, b correctly because when I run the accuracy I get this error "ValueError: Cannot feed value of shape (30, 14) for Tensor 'Declaring_placeholder_10/Placeholder:0', which has shape '(?, 15)'
"
tensorflow logistic-regression
New contributor
user80034 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
x_train = tr1.loc[:, ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width']]
#x_train.shape - (120 x 4)
y_train = tr1.loc[:, ['Species']]
#shape - 120 x 3
x_test = test1.loc[:, ['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width']]
#shape 30 x 4
y_test = test1.loc[:, ['Species']]
# shape 30 x 3
oneHot = OneHotEncoder()
oneHot.fit(x_train)
# transform
x_train = oneHot.transform(x_train).toarray()
# fit our y to oneHot encoder
oneHot.fit(y_train)
# transform
y_train = oneHot.transform(y_train).toarray()
oneHot.fit(x_test)
# transform
x_test = oneHot.transform(x_test).toarray()
# fit our y to oneHot encoder
oneHot.fit(y_test)
# transform
y_test = oneHot.transform(y_test).toarray()
print("Our features X_test1 in one-hot format")
print(x_test)
Shape of x_train: (120, 15)
Shape of y_train: (120, 3)
Shape of x_test: (30, 14)
Shape of y_test: (30, 3)
a) After conversion why is the size x_test = 30 x 14 I assume it has to be 30 x 15 ?
# hyperparameters
learning_rate = 0.0001
num_epochs = 100
display_step = 1
# for visualize purpose in tensorboard we use tf.name_scope
with tf.name_scope("Declaring_placeholder"):
# X is placeholdre for iris features. We will feed data later on
x = tf.placeholder(tf.float32, shape=[None, 15])
# y is placeholder for iris labels. We will feed data later on
y = tf.placeholder(tf.float32, shape=[None, 3])
with tf.name_scope("Declaring_variables"):
# W is our weights. This will update during training time
W = tf.Variable(tf.zeros([15, 3]))
# b is our bias. This will also update during training time
b = tf.Variable(tf.zeros([3]))
with tf.name_scope("Declaring_functions"):
# our prediction function
y_ = tf.nn.softmax(tf.add(tf.matmul(x, W), b))
b) did I define x, y, W, b correctly because when I run the accuracy I get this error "ValueError: Cannot feed value of shape (30, 14) for Tensor 'Declaring_placeholder_10/Placeholder:0', which has shape '(?, 15)'
"
tensorflow logistic-regression
tensorflow logistic-regression
New contributor
user80034 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user80034 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user80034 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 9 hours ago
user80034user80034
311 bronze badge
311 bronze badge
New contributor
user80034 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user80034 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Your shape is (30, 14) and not (30, 15) because there are only 14 unique values in your test (one is missing). In any case you shouldn't fit the encoder on the test set, just on the training set. Then just transform on the test set and you'll get the correct dimensions.
Also as far as I can see W and b are declared correctly. I'd ask however you take a minute to format your question a bit better next time.
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "557"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
user80034 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f58088%2ftensorflow-logistic-regrssion-onehot-encoder-transformed-array-of-differt-s%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Your shape is (30, 14) and not (30, 15) because there are only 14 unique values in your test (one is missing). In any case you shouldn't fit the encoder on the test set, just on the training set. Then just transform on the test set and you'll get the correct dimensions.
Also as far as I can see W and b are declared correctly. I'd ask however you take a minute to format your question a bit better next time.
$endgroup$
add a comment |
$begingroup$
Your shape is (30, 14) and not (30, 15) because there are only 14 unique values in your test (one is missing). In any case you shouldn't fit the encoder on the test set, just on the training set. Then just transform on the test set and you'll get the correct dimensions.
Also as far as I can see W and b are declared correctly. I'd ask however you take a minute to format your question a bit better next time.
$endgroup$
add a comment |
$begingroup$
Your shape is (30, 14) and not (30, 15) because there are only 14 unique values in your test (one is missing). In any case you shouldn't fit the encoder on the test set, just on the training set. Then just transform on the test set and you'll get the correct dimensions.
Also as far as I can see W and b are declared correctly. I'd ask however you take a minute to format your question a bit better next time.
$endgroup$
Your shape is (30, 14) and not (30, 15) because there are only 14 unique values in your test (one is missing). In any case you shouldn't fit the encoder on the test set, just on the training set. Then just transform on the test set and you'll get the correct dimensions.
Also as far as I can see W and b are declared correctly. I'd ask however you take a minute to format your question a bit better next time.
answered 2 hours ago
JcartJcart
3006 bronze badges
3006 bronze badges
add a comment |
add a comment |
user80034 is a new contributor. Be nice, and check out our Code of Conduct.
user80034 is a new contributor. Be nice, and check out our Code of Conduct.
user80034 is a new contributor. Be nice, and check out our Code of Conduct.
user80034 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f58088%2ftensorflow-logistic-regrssion-onehot-encoder-transformed-array-of-differt-s%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown