mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sven Boekhoff <s...@boekhoff.info>
Subject Re: Creating Multinomial Random numbers with Mahout
Date Fri, 04 Sep 2009 23:17:46 GMT
Would be enough for me to know, where in the documentation i can find 
which implemantation is valid to be instatiated. I imported 
uncommons-math and haddop (which is needed for this "SparseVector"), but 
stil it doesn't work.

import org.apache.mahout.clustering.dirichlet.UncommonDistributions;
import org.apache.mahout.matrix.SparseVector;
import org.apache.mahout.matrix.Vector;

public class Main {
	
	public static void main(String[] args) {
		
		Vector probabilities = new SparseVector();
		probabilities.set(0, 0.1);
		probabilities.set(1, 0.2);
		probabilities.set(2, 0.3);
		probabilities.set(3, 0.4);
		
		// 100 Messpunkte
		for(int i=0; i<100; i++) {
			
			Vector newCoordinates = UncommonDistributions.rMultinom(100, 
probabilities);
			
			System.out.println(newCoordinates.size());
			
		}
		
	}
	
}

it throws the error:

Exception in thread "main" org.apache.mahout.matrix.IndexException
	at org.apache.mahout.matrix.AbstractVector.set(AbstractVector.java:142)
	at Main.main(Main.java:12)



Sean Owen wrote:
> Well, sounds like you are loading classes that need Hadoop, and you
> have not put Hadoop in your classpath.
> 
> These questions aren't particularly specific to Mahout -- I think
> you'd benefit from learning a bit more about how Java works first.
> It'll get you past a lot of small issues like this.
> 
> On Fri, Sep 4, 2009 at 11:55 PM, Sven Boekhoff<sven@boekhoff.info> wrote:
>> It does nor work.
>> It throws the error:
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/hadoop/io/Writable
>>        at java.lang.ClassLoader.defineClass1(Native Method)
>>        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
>>        at
>> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
>>        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
>>        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
>>        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
>>        at java.security.AccessController.doPrivileged(Native Method)
>>        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>>        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>> Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.Writable
>>        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>        at java.security.AccessController.doPrivileged(Native Method)
>>        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>>        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>>        ... 12 more
>> Could not find the main class: Main.  Program will exit.
>>
>> Do I need the hadoop library? This is not written in the requirements,...
>>
>>
>> Sean Owen wrote:
>>> I think you probably want to study basic Java first then or you're
>>> going to run into a lot more confusion.
>>>
>>> Vector probabilities = new SparseVector();
>>>
>>> is what you want. Interfaces and instantiating objects are the very
>>> basics of Java.
>>>
>>> On Fri, Sep 4, 2009 at 5:30 PM, Sven Boekhoff<sven@boekhoff.info> wrote:
>>>> I never worked with interfaces.
>>>> And i also don't know what "instantiate an implementation" means.
>>>> How does it look like?
>>>>
>>>> Sean Owen wrote:
>>>>> Yes, Vector is an interface! You need to instantiate an implementation
>>>>> like DenseVector.
>>>>>
>>>>> On Fri, Sep 4, 2009 at 5:25 PM, Sven Boekhoff<sven@boekhoff.info>
wrote:
>>>>>> But i cant create an Vector object:
>>>>>>
>>>>>> Vector probabilities = new Vector();
>>>>>>
>>>>>> gives an error.
>>>>>>

Mime
View raw message