Comments (2)
Unfortunately I'm very busy with some work right now, so getting to all these is going to take a bit.
I'm not sure what you are storing in your Table, you will have to determine if your features should be numeric or categorical yourself. Does the below code snippet help?
public static void main(String[] args)
{
//Some random data we want to convert to a DataSet object manually
Random rand = new XORWOW();
double[][] someStuffIWantToMakeIntoADataSet = new double[20][6];
for(int i = 0; i < someStuffIWantToMakeIntoADataSet.length; i++)
for(int j = 0; j < someStuffIWantToMakeIntoADataSet[i].length; j++)
someStuffIWantToMakeIntoADataSet[i][j] = rand.nextDouble();
//Lets decide the first 2 features are categorical and the rest are just numeric
//First we need the list the categories. Well create 1 categorie with 2 options and a 2nd category with 3 options.
CategoricalData[] categories = new CategoricalData[]
{
new CategoricalData(2), new CategoricalData(3)
};
SimpleDataSet sds = new SimpleDataSet(categories, 4);
for(double[] row : someStuffIWantToMakeIntoADataSet)
{
//first a place to store the categorical values.
int[] catValues = new int[categories.length];
catValues[0] = (int) Math.round(row[0]);//first cat will be whether the value was closer to 0 or 1
catValues[1] = (int) Math.round(row[1]*2);//similar for second
//Next we need a place to store the numeric features
Vec numericValues = new DenseVector(4);
for(int i = 0; i < 4; i++)
numericValues.set(i, row[2+i]);
DataPoint dp = new DataPoint(numericValues, catValues, categories);
//now just add to the dataset
sds.add(dp);
}
//done, we have made a data set
}
from jsat.
Perfect! Exactly what I was looking for - things like adding to the Vec one at a time being ok, not caring what the strings were that correspond to a category integer and just saving the final number - great stuff.
from jsat.
Related Issues (20)
- Kernal Density Estimation HOT 1
- question on image classifcation HOT 1
- Do not limit the elements in VPTree to vectors HOT 1
- KMeans data load
- Consider moving to a more liberal license HOT 1
- Question: Mean-Shift Starting point HOT 2
- do you want to release new version to maven central? HOT 1
- JSAT and Graylog plugin HOT 1
- Update Maven HOT 2
- Decision Tree Algorithm HOT 1
- SparseVector nulls all numerical values HOT 1
- PAM does not implement PAM HOT 18
- How to use for LVQ HOT 1
- How to create maven project for JSAT HOT 3
- Using MeanShift with given bandwidth?
- NullPointer getting thrown when using BDS feature selector on ClassificationDataSet HOT 3
- Null pointer when using BDS feature selector HOT 1
- Increase the usage of compound assignment operators
- OrdinaryKriging Infiniy HOT 2
- typos HOT 2
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 jsat.