Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG] RandomActivation #4703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 34 commits into from

Conversation

IssamLaradji
Copy link
Contributor

Tasks

  • Add doc in code
  • Add more weight initialization methods
  • Add another example

This is meant to be the first stage of the pipeline for the random neural network algorithm [1]

It fits on the input data by considering the number of features and then randomly generates an n_features x n_activated coefficient matrix where n_activated is the number of the "hidden layer" features defined by the user.

The coefficient matrix can be used to transform the input data to a different space.

[1] http://homepage.tudelft.nl/a9p19/papers/icpr_92_random.pdf

@jnothman
Copy link
Member

I think this would be more useful and scikit-learn like with a choice of activation function. It's still easy to throw a Ridge on the end, but not quite as fragmented.

Also, I think this PR would be well illustrated by translating examples from #3306 into this model.

@IssamLaradji
Copy link
Contributor Author

yah that's true! will update it


class RandomActivation(six.with_metaclass(ABCMeta, TransformerMixin)):
def __init__(self, n_activated_features=10, weight_scale='auto',
activation='identity', intercept=True, random_state=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not identity because that would make it the same as RandomProjection more or less?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, also I guess it wouldn't make sense to have a hidden layer with identity activation.

@amueller
Copy link
Member

Btw, how about "RandomBasisFunction" as a name?

@IssamLaradji
Copy link
Contributor Author

yah RandomBasisFunction sounds better and more technically appealing

@ekerazha
Copy link

I'd add support for different initialization/randomization algorithms. E.g. The Nguyen-Widrow algorithm would be a nice addition.

@amueller
Copy link
Member

have you checked out the travis error? And porting the examples and doc over?

@IssamLaradji
Copy link
Contributor Author

yes, working on it - will push everything all at once. :)

Unfortunately, I caught the flu and had to stay in bed for the last 3 days :(, came at the worst time.

@amueller
Copy link
Member

I'm sorry! get well soon! [I've had some virus for the last 2 month, hurray ^^]

@IssamLaradji
Copy link
Contributor Author

Thanks!! that's nice of you ! :)

@IssamLaradji
Copy link
Contributor Author

back on my feet! :)

Will push a semi-complete version of this by tomorrow. I will basically use pipelining with Ridge to create examples very similar to those I had for extreme learning machines.

@IssamLaradji
Copy link
Contributor Author

Reproduced the results showing the affect of varying weight_scale and alpha.

Higher alpha in Ridge, more linear the decision graph appears.
Higher weight_scale in the random activation class, more non-linear the decision graph appears.

figure_1
figure_2

@IssamLaradji
Copy link
Contributor Author

Added the varying hyperparameters example, doc, and sanity checks in code.

  1. What would be a good test case for random activation ?
  2. is there another interesting example that I could add ?
  3. is it necessary to have a .rst document dedicated to this, or is the code doc sufficient ?

cheers.

@ekerazha
Copy link

  1. what about an example when varying n_activated_features?
Recently, Liu, Gao, etal. (2012) showed that the VC dimension
of an ELM is equal to its number of hidden neurons with probability
one. Thus we are provided a convenient way to compute the
generalization bound of ELM.

Source: http://www3.ntu.edu.sg/home/egbhuang/pdf/ELM-Suvey-Huang-Gao.pdf

@IssamLaradji
Copy link
Contributor Author

Here is the plot, scores in terms of training and testing. The dataset was randomly generated where 100 samples are for training, 50 samples for testing, and 50 is the number of features.
When the number of hidden neurons equals the number of training samples, the training score is 1.0, but the testing score plummets significantly, which makes sense.
figure_1

@IssamLaradji
Copy link
Contributor Author

 from base import ACTIVATIONS
ImportError: No module named 'base'

I wonder why this is a travis error for python 3.

For python 2.6, this works fine.

@sveitser
Copy link

Implicit relative imports are no longer available in python 3. See for instance http://stackoverflow.com/questions/12172791/changes-in-import-statement-python3 .

I never use relative imports but I think from .base import ACTIVATIONS would work.

@IssamLaradji
Copy link
Contributor Author

@sveitser awesome! this fixed it!

@ekerazha
Copy link

Why is there an "orphan" softmax function? It's not documented and it's not inside the ACTIVATIONS dict.

@jaquesgrobler
Copy link
Member

@ekerazha I assume it has to do with the last layer of the random neural network algorithm... This PR is the first stage for the pipeline of a random neural network algorithm. I haven't really read that paper but I assume the orphaned softmax will join the party later on ;)

@amueller
Copy link
Member

There should definitely be an rst with a narrative documentation. It doesn't matter so much if it is it's own file, there will be a supervised file when merging the mlp anyhow.

@maniteja123
Copy link
Contributor

Hi @IssamLaradji first of all great work on MLP. That was one of the first algorithms I used here. I just wanted to know if you are still working on this ? Thanks.

@IssamLaradji
Copy link
Contributor Author

Hi @maniteja123, thanks a lot!

Unfortunately, I am in the crunch time season of my PhD :( - therefore it might be a while before I can continue working on this.

You are welcome to work on this if interested :)

@maniteja123
Copy link
Contributor

Hi @IssamLaradji thanks for the response. I actually am interested to work on this and thanks for the permission to work. All the best for your PhD thesis :)

@ekerazha
Copy link

I found this new "Extreme Learning Machines" implementation https://github.com/maestrotf/pyExtremeLM which is pretty nice.

Base automatically changed from master to main January 22, 2021 10:48
@lucyleeow
Copy link
Member

Is there still interest in including this?

@adrinjalali
Copy link
Member

I think this is out of scope for scikit-learn these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.