0

I am trying to use a library for multiple instance learning made by someone else.

This is the main code which explains the input.

function [Concepts,maxConcept,Iterations]=maxDD(PBags,NBags,Dim,Scales,SPoints,Epochs,Tol)


PBags   - An Mx1 cell array, the jth instance of ith positive bag is stored in PBags{i}(j,:) (1<=i<=M)
NBags   - An Nx1 cell array, the jth instance of ith negative bag is stored in Nbags{i}(j,:) (1<=i<=N)

I am new to the concept of cell array. My data is as follows. A text file containing say 400 instances.

First 200 are called positive intances..next 200 called negative.These need to be sorted out into 42 positive bags, then 40 negative bag.(each instances belong to a bag..each bag containig more than 1 instance) (Think of it as red and blue mailboxes.Each mailbox in turn will contain x number of instances (varying for each mailbox) The number of instances in each is given in a (42+40=82) dimensional vector.

example 4 5 6 ...2 meaning 4 intances go to first mailbox, 5 to second and and so on.

How do i give the input in correct cell array form.Since both the data and the algorithm are from the same library, i think somehow that the data i already in a form easily convertable into cell arrays!

4
  • I don't understand this. Can you give an example of an "instance"? Can you show the first lines of your text file? And tell us how to identify an "instance"? Also, edit the title! Commented Aug 11, 2016 at 13:11
  • A cell array is just an array that can contain whatever in each location. Convert do data into cell array would be a={PBags}. You probably want to reword your question. Commented Aug 11, 2016 at 13:11
  • Each instance is 1X166 vector. Each bag(+ve or negative) contains several instances. The positive and negative instances are listed sequentially (466x166 matrix). The number of intances belonging to first bag is given in first element of the other text file, say 5. Commented Aug 11, 2016 at 13:16
  • you can see a cell array in MATLAB almost as an array of objects in Java, Object [] = new Object[10];, except for that it is indexed using {} instead of [] and that it is easier to extend it. So an array where you can place anything in other words. Commented Aug 11, 2016 at 13:34

1 Answer 1

0

This question could definitely be clearer, but based on what I think you mean... I am assuming you have a cell array in your workspace and are trying to input the contents of each instance from that cell array into the MaxDD function you're calling. If you want to input the whole 1*166 vector (an "instance") you use:

PBags{i}

This will return the contents of the cell at location i (which should be an instance). This assumes PBags looks like this when you view the variable: Screenshot of rand-filled cell array

PBags
1x466 cell
_________________________________________________________________
|1x166 double|1x166 double|1x166 double|1x166 double|1x166 double| ...
-----------------------------------------------------------------
|            |            |            |            |            |
-----------------------------------------------------------------
.
.
.

Where each 1x166 double is an instance as mentioned above, and there's 466 instances.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.