Getting Strange Values In Machine Learning Classification Model2019 Community Moderator Electioncifar10 official keras example not giving expected accuracy, using sigmoid seems better than reluKeras: How to normalize dataframe with continuous and categorical data?Tensorflow regression predicting 1 for all inputsKeras LSTM: use weights from Keras model to replicate predictions using numpyMy Neural network in Tensorflow does a bad job in comparison to the same Neural network in KerasTraining Accuracy stuck in KerasValue error in Merging two different models in kerasProbability Calibration : role of hidden layer in Neural NetworkSteps taking too long to completeCan we use ReLU activation function as the output layer's non-linearity?
Have astronauts in space suits ever taken selfies? If so, how?
How do I create uniquely male characters?
Can I make popcorn with any corn?
Writing rule stating superpower from different root cause is bad writing
To string or not to string
Prove that NP is closed under karp reduction?
Why doesn't H₄O²⁺ exist?
Why are electrically insulating heatsinks so rare? Is it just cost?
Why not use SQL instead of GraphQL?
Why are 150k or 200k jobs considered good when there are 300k+ births a month?
How is it possible to have an ability score that is less than 3?
Can I ask the recruiters in my resume to put the reason why I am rejected?
Why was the small council so happy for Tyrion to become the Master of Coin?
What's the output of a record cartridge playing an out-of-speed record
How does one intimidate enemies without having the capacity for violence?
can i play a electric guitar through a bass amp?
What's the point of deactivating Num Lock on login screens?
Mage Armor with Defense fighting style (for Adventurers League bladeslinger)
TGV timetables / schedules?
Is it possible to do 50 km distance without any previous training?
Why does Kotter return in Welcome Back Kotter?
Collect Fourier series terms
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
How old can references or sources in a thesis be?
Getting Strange Values In Machine Learning Classification Model
2019 Community Moderator Electioncifar10 official keras example not giving expected accuracy, using sigmoid seems better than reluKeras: How to normalize dataframe with continuous and categorical data?Tensorflow regression predicting 1 for all inputsKeras LSTM: use weights from Keras model to replicate predictions using numpyMy Neural network in Tensorflow does a bad job in comparison to the same Neural network in KerasTraining Accuracy stuck in KerasValue error in Merging two different models in kerasProbability Calibration : role of hidden layer in Neural NetworkSteps taking too long to completeCan we use ReLU activation function as the output layer's non-linearity?
$begingroup$
I'm trying to train a machine learning model on the following data.
Here is a sample:
key A0 A1 A2 A3 A4 A5 A6 A7 A8 A9
a 12 15 28 35 22 10 11 10 18 11
d 11 14 29 24 10 11 10 19 11
The model is supposed to classify every letter of the alphabet and get
a non-random row of numbers associated with the letter. A-Z, with
values ranging from about 8-35. I've had to resort to using tensorflow 1.5.0 because I don't have an expensive GPU to train on.
If I run for only 10 epochs or less I get reasonable predictions of
about .04 percent, which would be pretty close to a random guess. But
if I try to train for longer I get the following.
[4.8728631e-04 2.8466644e-02 8.8677540e-02 ... 6.2057756e-02
2.9221788e-02 8.6455815e-02]
[1.4348865e-01 1.2017406e-01 3.5096225e-03 ... 3.7368879e-02
5.3554219e-03 1.1316765e-03]
[2.2863398e-06 1.4322808e-03 5.2052658e-02 ... 6.3502453e-03
This is the model that isn't working
import pandas as pd
import tensorflow
import numpy as np
import keras
from keras.models import model_from_json
dataset = pd.read_csv('mlglovesdata.csv')
X = dataset.iloc[:, 1:11].values
y = dataset.iloc[:, 0].values
# Taking care of missing data
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN', strategy = 'mean', axis = 0)
imputer = imputer.fit(X[:, 1:11])
X[:, 1:11] = imputer.transform(X[:, 1:11])
# dataset starts at 1 due to columns from openoffice formatting, I suppose
# Encoding categorical data
# Encoding the Dependent Variable
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_y = LabelEncoder()
y = labelencoder_y.fit_transform(y)
# May need to only go this far in the encoding
onehotencoder = OneHotEncoder(sparse=False)
y = y.reshape(len(y), 1)
y = onehotencoder.fit_transform(y)
y = y[:, 1:]
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
# Importin keras dependencies
import keras
from keras.models import Sequential
from keras.layers import Dense
# Initializing the ANN
classifier = Sequential()
# Add 1st input hidden layer
classifier.add(Dense(17,kernel_initializer='uniform',activation='relu',input_dim = 10))
# Add second hidden layer
classifier.add(Dense(17,kernel_initializer='uniform',activation='relu'))
# Add the output layer
classifier.add(Dense(25,kernel_initializer='uniform',activation='softmax'))
classifier.compile(loss="categorical_crossentropy", optimizer="adam", metrics=['accuracy'])
classifier.fit(X_train,y_train,batch_size=10,nb_epoch=20)
y_pred = classifier.predict(X_test)
print(y_pred)
Any help would be a greatly appreciated, and might earn an honorable
mention in a book if I write one.
machine-learning keras tensorflow
$endgroup$
add a comment |
$begingroup$
I'm trying to train a machine learning model on the following data.
Here is a sample:
key A0 A1 A2 A3 A4 A5 A6 A7 A8 A9
a 12 15 28 35 22 10 11 10 18 11
d 11 14 29 24 10 11 10 19 11
The model is supposed to classify every letter of the alphabet and get
a non-random row of numbers associated with the letter. A-Z, with
values ranging from about 8-35. I've had to resort to using tensorflow 1.5.0 because I don't have an expensive GPU to train on.
If I run for only 10 epochs or less I get reasonable predictions of
about .04 percent, which would be pretty close to a random guess. But
if I try to train for longer I get the following.
[4.8728631e-04 2.8466644e-02 8.8677540e-02 ... 6.2057756e-02
2.9221788e-02 8.6455815e-02]
[1.4348865e-01 1.2017406e-01 3.5096225e-03 ... 3.7368879e-02
5.3554219e-03 1.1316765e-03]
[2.2863398e-06 1.4322808e-03 5.2052658e-02 ... 6.3502453e-03
This is the model that isn't working
import pandas as pd
import tensorflow
import numpy as np
import keras
from keras.models import model_from_json
dataset = pd.read_csv('mlglovesdata.csv')
X = dataset.iloc[:, 1:11].values
y = dataset.iloc[:, 0].values
# Taking care of missing data
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN', strategy = 'mean', axis = 0)
imputer = imputer.fit(X[:, 1:11])
X[:, 1:11] = imputer.transform(X[:, 1:11])
# dataset starts at 1 due to columns from openoffice formatting, I suppose
# Encoding categorical data
# Encoding the Dependent Variable
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_y = LabelEncoder()
y = labelencoder_y.fit_transform(y)
# May need to only go this far in the encoding
onehotencoder = OneHotEncoder(sparse=False)
y = y.reshape(len(y), 1)
y = onehotencoder.fit_transform(y)
y = y[:, 1:]
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
# Importin keras dependencies
import keras
from keras.models import Sequential
from keras.layers import Dense
# Initializing the ANN
classifier = Sequential()
# Add 1st input hidden layer
classifier.add(Dense(17,kernel_initializer='uniform',activation='relu',input_dim = 10))
# Add second hidden layer
classifier.add(Dense(17,kernel_initializer='uniform',activation='relu'))
# Add the output layer
classifier.add(Dense(25,kernel_initializer='uniform',activation='softmax'))
classifier.compile(loss="categorical_crossentropy", optimizer="adam", metrics=['accuracy'])
classifier.fit(X_train,y_train,batch_size=10,nb_epoch=20)
y_pred = classifier.predict(X_test)
print(y_pred)
Any help would be a greatly appreciated, and might earn an honorable
mention in a book if I write one.
machine-learning keras tensorflow
$endgroup$
add a comment |
$begingroup$
I'm trying to train a machine learning model on the following data.
Here is a sample:
key A0 A1 A2 A3 A4 A5 A6 A7 A8 A9
a 12 15 28 35 22 10 11 10 18 11
d 11 14 29 24 10 11 10 19 11
The model is supposed to classify every letter of the alphabet and get
a non-random row of numbers associated with the letter. A-Z, with
values ranging from about 8-35. I've had to resort to using tensorflow 1.5.0 because I don't have an expensive GPU to train on.
If I run for only 10 epochs or less I get reasonable predictions of
about .04 percent, which would be pretty close to a random guess. But
if I try to train for longer I get the following.
[4.8728631e-04 2.8466644e-02 8.8677540e-02 ... 6.2057756e-02
2.9221788e-02 8.6455815e-02]
[1.4348865e-01 1.2017406e-01 3.5096225e-03 ... 3.7368879e-02
5.3554219e-03 1.1316765e-03]
[2.2863398e-06 1.4322808e-03 5.2052658e-02 ... 6.3502453e-03
This is the model that isn't working
import pandas as pd
import tensorflow
import numpy as np
import keras
from keras.models import model_from_json
dataset = pd.read_csv('mlglovesdata.csv')
X = dataset.iloc[:, 1:11].values
y = dataset.iloc[:, 0].values
# Taking care of missing data
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN', strategy = 'mean', axis = 0)
imputer = imputer.fit(X[:, 1:11])
X[:, 1:11] = imputer.transform(X[:, 1:11])
# dataset starts at 1 due to columns from openoffice formatting, I suppose
# Encoding categorical data
# Encoding the Dependent Variable
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_y = LabelEncoder()
y = labelencoder_y.fit_transform(y)
# May need to only go this far in the encoding
onehotencoder = OneHotEncoder(sparse=False)
y = y.reshape(len(y), 1)
y = onehotencoder.fit_transform(y)
y = y[:, 1:]
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
# Importin keras dependencies
import keras
from keras.models import Sequential
from keras.layers import Dense
# Initializing the ANN
classifier = Sequential()
# Add 1st input hidden layer
classifier.add(Dense(17,kernel_initializer='uniform',activation='relu',input_dim = 10))
# Add second hidden layer
classifier.add(Dense(17,kernel_initializer='uniform',activation='relu'))
# Add the output layer
classifier.add(Dense(25,kernel_initializer='uniform',activation='softmax'))
classifier.compile(loss="categorical_crossentropy", optimizer="adam", metrics=['accuracy'])
classifier.fit(X_train,y_train,batch_size=10,nb_epoch=20)
y_pred = classifier.predict(X_test)
print(y_pred)
Any help would be a greatly appreciated, and might earn an honorable
mention in a book if I write one.
machine-learning keras tensorflow
$endgroup$
I'm trying to train a machine learning model on the following data.
Here is a sample:
key A0 A1 A2 A3 A4 A5 A6 A7 A8 A9
a 12 15 28 35 22 10 11 10 18 11
d 11 14 29 24 10 11 10 19 11
The model is supposed to classify every letter of the alphabet and get
a non-random row of numbers associated with the letter. A-Z, with
values ranging from about 8-35. I've had to resort to using tensorflow 1.5.0 because I don't have an expensive GPU to train on.
If I run for only 10 epochs or less I get reasonable predictions of
about .04 percent, which would be pretty close to a random guess. But
if I try to train for longer I get the following.
[4.8728631e-04 2.8466644e-02 8.8677540e-02 ... 6.2057756e-02
2.9221788e-02 8.6455815e-02]
[1.4348865e-01 1.2017406e-01 3.5096225e-03 ... 3.7368879e-02
5.3554219e-03 1.1316765e-03]
[2.2863398e-06 1.4322808e-03 5.2052658e-02 ... 6.3502453e-03
This is the model that isn't working
import pandas as pd
import tensorflow
import numpy as np
import keras
from keras.models import model_from_json
dataset = pd.read_csv('mlglovesdata.csv')
X = dataset.iloc[:, 1:11].values
y = dataset.iloc[:, 0].values
# Taking care of missing data
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN', strategy = 'mean', axis = 0)
imputer = imputer.fit(X[:, 1:11])
X[:, 1:11] = imputer.transform(X[:, 1:11])
# dataset starts at 1 due to columns from openoffice formatting, I suppose
# Encoding categorical data
# Encoding the Dependent Variable
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_y = LabelEncoder()
y = labelencoder_y.fit_transform(y)
# May need to only go this far in the encoding
onehotencoder = OneHotEncoder(sparse=False)
y = y.reshape(len(y), 1)
y = onehotencoder.fit_transform(y)
y = y[:, 1:]
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
# Importin keras dependencies
import keras
from keras.models import Sequential
from keras.layers import Dense
# Initializing the ANN
classifier = Sequential()
# Add 1st input hidden layer
classifier.add(Dense(17,kernel_initializer='uniform',activation='relu',input_dim = 10))
# Add second hidden layer
classifier.add(Dense(17,kernel_initializer='uniform',activation='relu'))
# Add the output layer
classifier.add(Dense(25,kernel_initializer='uniform',activation='softmax'))
classifier.compile(loss="categorical_crossentropy", optimizer="adam", metrics=['accuracy'])
classifier.fit(X_train,y_train,batch_size=10,nb_epoch=20)
y_pred = classifier.predict(X_test)
print(y_pred)
Any help would be a greatly appreciated, and might earn an honorable
mention in a book if I write one.
machine-learning keras tensorflow
machine-learning keras tensorflow
asked Mar 27 at 7:03
brocksprogrammingbrocksprogramming
11
11
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
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
);
);
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%2f48065%2fgetting-strange-values-in-machine-learning-classification-model%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f48065%2fgetting-strange-values-in-machine-learning-classification-model%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