Code Monkey home page Code Monkey logo

Comments (7)

gpapadop79 avatar gpapadop79 commented on July 19, 2024 2

ok after some testing I figured out that the problem really was that I didn't know what a generator function is in python, because the main function bh_tsne is actually a generator.

So I just had to convert the output to a numpy array.
I finally added a function run_tsne for calling bh_tsne from another script which justs passes the parameters and returns a numpy array

def run_tsne(data, no_dims=DEFAULT_NO_DIMS, perplexity=DEFAULT_PERPLEXITY, theta=DEFAULT_THETA, randseed=EMPTY_SEED, verbose=True, initial_dims=INITIAL_DIMENSIONS):

   result = bh_tsne(data, no_dims=no_dims, perplexity=perplexity, theta=theta, randseed=randseed, verbose=verbose, initial_dims=initial_dims)
   return np.asarray(list(result))

so now this works fine:

import bhtsne
bhtsne.run_tsne(Xtrain)

from bhtsne.

ajdroid avatar ajdroid commented on July 19, 2024 1

Look at the main() in bhtsne.py

from bhtsne.

lvdmaaten avatar lvdmaaten commented on July 19, 2024

Can you provide a code sample that allows me to reproduce your issue?

from bhtsne.

gpapadop79 avatar gpapadop79 commented on July 19, 2024

Sorry for the delayed answer.
Actually when I run the wrapper with arguments (which is how it is designed), it works fine.
python bhtsne.py -i Xtrain.csv -o Xtsne.csv

The problem I mentioned occurs when I try to call bhtsne.py within another python script, because I want to pass the data to visualize as a numpy array, like you can do with the matlab wrapper.

So I tried:
import bhtsne
bhtsne.bh_tsne(Xtrain)

and also
bhtsne.bh_tsne(Xtrain_svd, no_dims=2, initial_dims=50, perplexity=30, theta=0.5, randseed=-1, verbose=True)

but no bh_tsne.exe process is starting and the output is something like:
<generator object bh_tsne at 0x0000000008F45900>

I suppose the bhtsne.py script needs modifications to work, is there any quick hack we can do?

Thanks

I'm using anaconda python 2.5 on windows 7 x64

ps. I accidentaly closed the issue and reopened it. sorry

from bhtsne.

RobRomijnders avatar RobRomijnders commented on July 19, 2024

Can you help me a little? Why does this not work? I added the run_tsne() function to the bhtsne.py

import sys
import numpy as np
sys.path.append('/home/rob/Dropbox/ml_projects/tSNE/bhtsne-master')
import bhtsne


X_train = np.loadtxt('/home/rob/Dropbox/ml_projects/FCN/X_train.csv', delimiter=',')
y_train = np.loadtxt('/home/rob/Dropbox/ml_projects/FCN/y_train.csv', delimiter=',')

result = bhtsne.run_tsne(X_train)

The codes take a while to run, but the variable result doesn;t contain anything.

I am familiar with tSNE. I use it a lot in Matlab, now I'd like to add it to my Python and iPython notebooks.

Thank you in advance

@lvdmaaten Laurens, I know you're active on these forums. Might you supply us with an example code for Python or iPython notebook , like you did for Matlab

from bhtsne.

lvdmaaten avatar lvdmaaten commented on July 19, 2024

I'm afraid I cannot be of much help here: I don't actually speak Python... :)

from bhtsne.

gpapadop79 avatar gpapadop79 commented on July 19, 2024

@RobRomijnders first thing to check is whether the wrapper is launching a bh_tsne.exe process.
I suspect that in your case it doesn't and the code takes a while to run because the wrapper applies PCA to the data as a preprocessing step before TSNE.

Anyway if that is the case, first thing I would check is the path to the executable.
It is defined in line 54 of bhtsne.py. If you are running this on windows the executable must be in a folder named "windows"

from bhtsne.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.