Yes, that's substantial.  Thanks for reminding me how big the difference
is. Still, n_classes for multilabel classification isn't often that big.
I'll change it.


On 11 February 2014 19:39, Arnaud Joly <notifications@github.com> wrote:

>  In sklearn/datasets/samples_generator.py:
>
> > -            else:
> > -                # pick a class and generate an appropriate word
> > -                c = y[generator.randint(len(y))]
> > -                w = generator.multinomial(1, p_w_c[:, c]).argmax()
> > -            x[w] += 1
> > -
> > -        return x, y
> > -
> > -    X, Y = zip(*[sample_example() for i in range(n_samples)])
> > +        if len(y) == 0:
> > +            # if sample does not belong to any class, generate noise word
> > +            words = generator.randint(n_features, size=k)
> > +            return words, y
> > +
> > +        # sample words with replacement from selected classes
> > +        cumulative_p_w_sample = np.cumsum(p_w_c[:, y].sum(axis=1))
>
> Without take
>
> (sklearn) ± time python benchmarks/bench_make_multilabel_classification.py -n 20000 -p 1000 -d 1000 -k 25 -s 0
> {'n_features': 1000, 'seed': 0, 'n_labels': 25, 'n_classes': 1000, 'n_samples': 20000}
> python benchmarks/bench_make_multilabel_classification.py -n 20000 -p 1000 -d  23.86s user 0.27s system 99% cpu 24.162 total
>
> with p_w_c.take(y, axis=1).sum(axis=1).cumsum()
>
> (sklearn) ± time python benchmarks/bench_make_multilabel_classification.py -n 20000 -p 1000 -d 1000 -k 25 -s 0
> {'n_features': 1000, 'seed': 0, 'n_labels': 25, 'n_classes': 1000, 'n_samples': 20000}
> python benchmarks/bench_make_multilabel_classification.py -n 20000 -p 1000 -d  8.77s user 0.23s system 99% cpu 9.010 total
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/scikit-learn/scikit-learn/pull/2828/files#r9616401>
> .
>