Comments (7)
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.
Look at the main()
in bhtsne.py
from bhtsne.
Can you provide a code sample that allows me to reproduce your issue?
from bhtsne.
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.
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.
I'm afraid I cannot be of much help here: I don't actually speak Python... :)
from bhtsne.
@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)
- Usage of random generator(s) in the source HOT 2
- How can i visualize the image data like this? HOT 1
- bhtsne.py:135: ComplexWarning: Casting complex values to real discards the imaginary part HOT 1
- Butterfly effect HOT 3
- Can not use the python wrapper in Windows
- transposition based on input method HOT 3
- Why is the exact algorithm 10 times faster? HOT 8
- Dimension problem HOT 3
- Can't compile the .exe with visual studio 9.0 HOT 9
- Pytorch version? HOT 4
- python wrapper - Cost for each sample
- Performance difference to the old version HOT 1
- C API HOT 3
- Bhtsne for large datasets HOT 1
- Performance difference Windows/Ubuntu HOT 2
- t-SNE for Java/Scala/Kotlin/Clojure
- Is there a rule of thumb for the lower bound on the perplexity?
- Why use zeroMean in gradient update?
- Finding P and Q matrices
- Graphics problem with tsne algorithm
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bhtsne.