haifengl / smile

Statistical Machine Intelligence & Learning Engine

Home Page:https://haifengl.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dot product Question

nandsmalho opened this issue · comments

Hello!
While implementing the Maxent class to train a model for this input data :

 int[] labels = {0, 1, 0, 1, 0, 0, 1, 0, 1, 1};
    int[][] features = {
      {1, 2},
      {2, 3},
      {3, 4},
      {4, 5},
      {5, 6},
      {6, 7},
      {7, 8},
      {8, 9},
      {9, 10},
      {10, 11}
    };

I am getting an issue in the Maxent.dot() method :

private static double dot(int[] x, double[] w) {
        double dot = w[w.length - 1];

        for (int i : x) {
            **dot += w[i];**
        }

        return dot;
    }

I dont know if my input data is of the incorrect format or if there is some other issue.

This is how i am training the model :
Maxent model = Maxent.fit(trainingData[0].length, trainingData, trainingLabels);

Using Java8
Using the latest 3.0.2 version of smile
Build system - Ubuntu 22.04.3 LTS

Also, what is the parameter 'p' we have to input to fit the model?
In the test file, there is something with Protein.p - can you give some more insight into this parameter?

The data is in wrong format. X should be array of index of non-zero entries.

Okay, resolved it! Thank you