sklearn - How to generate proper labels with multiple values












0















In my course, we have to implement a working traffic light recognition algorithm using python with the common modules (numpy, sklearn, etc.)



In my simple_train dataset, there are 209 pictures where each of those pictures has no, one or multiple traffic lights on it. For simplification, I modified my loading algorithm to just return a single traffic light (if there is one or more).



My independet dataset (picture arrays) has a shape of (209, 720, 1280, 3) and I noticed that I have to reshape it into an 2d array - so my feature set array has a shape of (209, 2764800).



Now there's the tricky part I'm stuck at. Each traffic light consists of four coordinates (x_min, x_max, y_min and y_max). This means for the first three pictures, my label would look like this:



array([None, None, (610, 351, 615, 358), ... ])


On the first two pictures, there are no traffic lights but on the third one, there's a traffic light with the given boundaries.



Calling the .fit function of the MLPClassifier I get the following error message:




ValueError: Unknown label type: (array([None, None, (610, 351, 615, 358), ...])




How do I have to modify my label to get this to work?










share|improve this question























  • You could add (0,0,0,0) label, for the no traffic light, and attempt. During prediction (0,0,0,0) should be defined to be no traffic light. However that is kinda brute forcing. Not sure of the scope of your model, but there are many recognition models out there you can research on.

    – Dinari
    Nov 26 '18 at 12:20











  • No, the task you described is object-detection and will be too complex for scikit-learn models. You can start by only predicting if any traffic light is present in the given picture or not. This can be done by changing the labels to [False, False, True] or [0, 0, 1] for your given examples.

    – Vivek Kumar
    Nov 26 '18 at 13:38


















0















In my course, we have to implement a working traffic light recognition algorithm using python with the common modules (numpy, sklearn, etc.)



In my simple_train dataset, there are 209 pictures where each of those pictures has no, one or multiple traffic lights on it. For simplification, I modified my loading algorithm to just return a single traffic light (if there is one or more).



My independet dataset (picture arrays) has a shape of (209, 720, 1280, 3) and I noticed that I have to reshape it into an 2d array - so my feature set array has a shape of (209, 2764800).



Now there's the tricky part I'm stuck at. Each traffic light consists of four coordinates (x_min, x_max, y_min and y_max). This means for the first three pictures, my label would look like this:



array([None, None, (610, 351, 615, 358), ... ])


On the first two pictures, there are no traffic lights but on the third one, there's a traffic light with the given boundaries.



Calling the .fit function of the MLPClassifier I get the following error message:




ValueError: Unknown label type: (array([None, None, (610, 351, 615, 358), ...])




How do I have to modify my label to get this to work?










share|improve this question























  • You could add (0,0,0,0) label, for the no traffic light, and attempt. During prediction (0,0,0,0) should be defined to be no traffic light. However that is kinda brute forcing. Not sure of the scope of your model, but there are many recognition models out there you can research on.

    – Dinari
    Nov 26 '18 at 12:20











  • No, the task you described is object-detection and will be too complex for scikit-learn models. You can start by only predicting if any traffic light is present in the given picture or not. This can be done by changing the labels to [False, False, True] or [0, 0, 1] for your given examples.

    – Vivek Kumar
    Nov 26 '18 at 13:38
















0












0








0








In my course, we have to implement a working traffic light recognition algorithm using python with the common modules (numpy, sklearn, etc.)



In my simple_train dataset, there are 209 pictures where each of those pictures has no, one or multiple traffic lights on it. For simplification, I modified my loading algorithm to just return a single traffic light (if there is one or more).



My independet dataset (picture arrays) has a shape of (209, 720, 1280, 3) and I noticed that I have to reshape it into an 2d array - so my feature set array has a shape of (209, 2764800).



Now there's the tricky part I'm stuck at. Each traffic light consists of four coordinates (x_min, x_max, y_min and y_max). This means for the first three pictures, my label would look like this:



array([None, None, (610, 351, 615, 358), ... ])


On the first two pictures, there are no traffic lights but on the third one, there's a traffic light with the given boundaries.



Calling the .fit function of the MLPClassifier I get the following error message:




ValueError: Unknown label type: (array([None, None, (610, 351, 615, 358), ...])




How do I have to modify my label to get this to work?










share|improve this question














In my course, we have to implement a working traffic light recognition algorithm using python with the common modules (numpy, sklearn, etc.)



In my simple_train dataset, there are 209 pictures where each of those pictures has no, one or multiple traffic lights on it. For simplification, I modified my loading algorithm to just return a single traffic light (if there is one or more).



My independet dataset (picture arrays) has a shape of (209, 720, 1280, 3) and I noticed that I have to reshape it into an 2d array - so my feature set array has a shape of (209, 2764800).



Now there's the tricky part I'm stuck at. Each traffic light consists of four coordinates (x_min, x_max, y_min and y_max). This means for the first three pictures, my label would look like this:



array([None, None, (610, 351, 615, 358), ... ])


On the first two pictures, there are no traffic lights but on the third one, there's a traffic light with the given boundaries.



Calling the .fit function of the MLPClassifier I get the following error message:




ValueError: Unknown label type: (array([None, None, (610, 351, 615, 358), ...])




How do I have to modify my label to get this to work?







python machine-learning scikit-learn classification






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 26 '18 at 12:14









C4p741nZC4p741nZ

4631723




4631723













  • You could add (0,0,0,0) label, for the no traffic light, and attempt. During prediction (0,0,0,0) should be defined to be no traffic light. However that is kinda brute forcing. Not sure of the scope of your model, but there are many recognition models out there you can research on.

    – Dinari
    Nov 26 '18 at 12:20











  • No, the task you described is object-detection and will be too complex for scikit-learn models. You can start by only predicting if any traffic light is present in the given picture or not. This can be done by changing the labels to [False, False, True] or [0, 0, 1] for your given examples.

    – Vivek Kumar
    Nov 26 '18 at 13:38





















  • You could add (0,0,0,0) label, for the no traffic light, and attempt. During prediction (0,0,0,0) should be defined to be no traffic light. However that is kinda brute forcing. Not sure of the scope of your model, but there are many recognition models out there you can research on.

    – Dinari
    Nov 26 '18 at 12:20











  • No, the task you described is object-detection and will be too complex for scikit-learn models. You can start by only predicting if any traffic light is present in the given picture or not. This can be done by changing the labels to [False, False, True] or [0, 0, 1] for your given examples.

    – Vivek Kumar
    Nov 26 '18 at 13:38



















You could add (0,0,0,0) label, for the no traffic light, and attempt. During prediction (0,0,0,0) should be defined to be no traffic light. However that is kinda brute forcing. Not sure of the scope of your model, but there are many recognition models out there you can research on.

– Dinari
Nov 26 '18 at 12:20





You could add (0,0,0,0) label, for the no traffic light, and attempt. During prediction (0,0,0,0) should be defined to be no traffic light. However that is kinda brute forcing. Not sure of the scope of your model, but there are many recognition models out there you can research on.

– Dinari
Nov 26 '18 at 12:20













No, the task you described is object-detection and will be too complex for scikit-learn models. You can start by only predicting if any traffic light is present in the given picture or not. This can be done by changing the labels to [False, False, True] or [0, 0, 1] for your given examples.

– Vivek Kumar
Nov 26 '18 at 13:38







No, the task you described is object-detection and will be too complex for scikit-learn models. You can start by only predicting if any traffic light is present in the given picture or not. This can be done by changing the labels to [False, False, True] or [0, 0, 1] for your given examples.

– Vivek Kumar
Nov 26 '18 at 13:38














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480919%2fsklearn-how-to-generate-proper-labels-with-multiple-values%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
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • 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.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480919%2fsklearn-how-to-generate-proper-labels-with-multiple-values%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)