Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

For each cell in the table, count the number of items in the same column with that value, and divide by the total number of items in the colum. Call this the cells 'value cardinality'.

Next determine a type for every cell (int, float, string, path, filename, whatever you think you are likely to find). Like before count the number of cells in the same column with the same type, and divide it by the total number of items in the column. This gives a cells 'type cardinality'.

Next for each row, multiple all the value cardinalities in that row, giving you a total value cardinatlity for that row. Do the same for type cardinality.

Finally, check if either the value or type cardinality of the first row is an outlier compare to all the other rows. This can either be a simple check such as either of the values being the lowest, or a more complicated check (such as not only being the lowest value but also being at least 1 standard deviation away from the nearest value when compared to the distribution of cardinality values for the other rows).

So if you have a table with headers like "Firstname","Lastname","Age", then the type cardinatlity will trigger because of the type difference in age. And if you have a table like "Firstname","Lastname","Sex", then the value cardinality will trigger.

The hard situation is when you have a header like "Firstname,Middlename,Surname". This is where your success depends entirely on how how much effort you put into type identification - because that is how a human does it.


In reply to Re: Useful heuristics for analyzing arrays of data to determine column header by sectokia
in thread Useful heuristics for analyzing arrays of data to determine column header by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-24 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found