<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Joel is right.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">In fact, you usually don't want to tune a lot the sample weights: you may leave them default, set them in order to balance classes, or fix them according to some business rule.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">That said, you can always run a couple of grid searchs changing that sample weights and compare results afterwards.<br><br>--<div>Julio</div></div><div><br>El 24 jun 2017, a las 15:51, Joel Nothman <<a href="mailto:joel.nothman@gmail.com">joel.nothman@gmail.com</a>> escribió:<br><br></div><blockquote type="cite"><div><div dir="auto">yes, trying multiple sample weightings is not supported by grid search directly.</div><div class="gmail_extra"><br><div class="gmail_quote">On 23 Jun 2017 6:36 pm, "Manuel Castejón Limas" <<a href="mailto:manuel.castejon@gmail.com">manuel.castejon@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear Joel,<div><br></div><div>I tried and removed the square brackets and now it works as expected <b>for a single</b> sample_weight vector:</div><div><br></div><div><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:11.9px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;color:rgb(36,41,46)"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:11.9px;padding:0px;margin:0px;background:transparent;border-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">validator = GridSearchCV(my_Regressor,
param_grid={'number_of_hidden_<wbr>neurons': range(4, 5),
'epochs': [50],
},
fit_params={'sample_weight': my_sample_weights },
n_jobs=1,
)
validator.fit(x, y)</code></pre><div class="gmail_extra">The problem now is that I want to try multiple trainings with multiple sample_weight parameters, in the following fashion:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:11.9px;margin-top:0px;margin-bottom:16px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;color:rgb(36,41,46)"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:11.9px;padding:0px;margin:0px;background:transparent;border-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">validator = GridSearchCV(my_Regressor,
param_grid={'number_of_hidden_<wbr>neurons': range(4, 5),
'epochs': [50],
'sample_weight': [my_sample_weights, my_sample_weights**2] ,
},
fit_params={},
n_jobs=1,
)
validator.fit(x, y)</code></pre></div><div class="gmail_extra">But unfortunately it produces the same error again:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:11.9px;background-color:rgba(27,31,35,0.05)">ValueError: Found a sample_weight array with shape (1000,) for an input with shape (666, 1). sample_weight cannot be broadcast.</span><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px">I guess that the issue is that the sample__weight parameter was not thought to be changed during the tuning, was it?</span><br></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px"><br></span></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px"><br></span></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px">Thank you all for your patience and support.</span></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px">Best</span></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px">Manolo</span></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px"><br></span></div><div class="gmail_extra"><span style="color:rgb(36,41,46);font-family:-apple-system,system-ui,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px"><br></span></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-06-23 1:17 GMT+02:00 Manuel CASTEJÓN LIMAS <span dir="ltr"><<a href="mailto:mcasl@unileon.es" target="_blank">mcasl@unileon.es</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Dear Joel,<div dir="auto">I'm just passing an iterable as I would do with any other sequence of parameters to tune. In this case the list only has one element to use but in general I ought to be able to pass a collection of vectors.</div><div dir="auto">Anyway, I guess that that issue is not the cause of the problem.</div></div><div class="gmail_extra"><br><div class="gmail_quote">El 23 jun. 2017 1:04 a. m., "Joel Nothman" <<a href="mailto:joel.nothman@gmail.com" target="_blank">joel.nothman@gmail.com</a>> escribió:<br type="attribution"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">why are you passing [my_sample_weights] rather than just my_sample_weights?</div><div class="gmail_extra"><div class="gmail_quote"><br></div></div></blockquote></div></div></blockquote></div></div></div></div>
<br>______________________________<wbr>_________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/scikit-learn</a><br>
<br></blockquote></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>scikit-learn mailing list</span><br><span><a href="mailto:scikit-learn@python.org">scikit-learn@python.org</a></span><br><span><a href="https://mail.python.org/mailman/listinfo/scikit-learn">https://mail.python.org/mailman/listinfo/scikit-learn</a></span><br></div></blockquote></body></html>