How to determine if a position is open or closed in a "rigorous" fashion? I am creating a set of chess positions to be used [as a data set] for a project. It's based on supervised machine learning, but I need to have labeled data (see more italicized text below) before any machine learning can be done. I wish to label each position as open or closed or possibly some combination of the two.

I started out with assigning each position to just "open" or "closed," but this wasn't clear for a lot of the positions. Then I decided to go with a third label, semi-open/semi-closed, which is like the middle and in between open and closed. I’ve labeled most of the positions, but there are many positions that I still haven’t comfortably labeled with a distinct class.

I know that open positions are characterized as having pawnless ranks, files, and diagonals, while closed positions have them clogged up with pawns. In open positions you can usually centralize your pieces, while closed positions give you a hard time moving an arbitrary piece to a random location on the board. There are many other related patterns, features, and qualities.

I can easily go with my gut feeling when assigning "closed" to a position that has 7 pawns on each side with each pawn blockading another, and "open" to a position that has pawns only on the flanks and in their starting squares. However, it's hard for me to classify some positions such as these two examples:

[White "Position1"]
[Black "Open/Semi/Closed/Etc"]
[FEN "8/5Qpk/p6p/P1b5/4pPn1/2Pp3P/1P1BbqP1/R3R2K w - - 0 1 "]




[White "Position2"]
[Black "Open/Semi/Closed/Etc"]
[FEN "3r1rk1/pp2pp1p/2p3pb/2P5/4P3/4nNPb/PP2P2P/R1RNK2B w - - 0 1 "]


What would you assign to the examples above and why? For example: one position is more open than the other due to characteristic XYZ, or the second position should not be considered closed since there's an open file, and so on.

Should I just ditch the whole binary-ish labeling (classification) and instead assign a variable number (regression) describing how open or closed a position is (e.g. 0% to 100% open?) Or is there still a way for positions to go into a few categories, which means that we can have "rigorous" definitions of the categories of openness? And "rigorous" as in having few contradictions and preferably can be applied by a human without too much difficulty.
As a chess player who currently studies computer science, I found this question very interesting so here's my thoughts on the topic. You already know how chess books categorize open and closed positions and you may also know that a semi-closed position is one with some of the characteristics of an open but not all. As you understand this makes the line between closed and semi closed positions not easy to be seen. So my recommendation is to use a number to describe the "openness" of a position(although 50% may be a problem). Now some things I thinks you might find useful for implementing you machine learning algorithm. Firstly, I will suggest you to take a look at this article https://chess24.com/en/read/news/how-do-chess-engines-think in the section about position evaluation. Now, some parameters you might use:


Number of pawns(a position with no pawns is apparently wide open).
Number of pawn moves(assuming a position with three pawns each,there's a big difference if they are on f2,g2,f7 and f7,g7,h7 respectively and if they are on c4,d5,e4 and c5,d6,e5.
As you see in 2 you may give an extra weight for pawn moves in the center. Generally it will be a good idea to give extra weight for anything open in the center. This will be more clear in 4.
Number of open and semi-open files. The ones in the center again should have an extra weight.
Open diagonals. Note that diagonals with one or more isolani should be counted almost as opens(As an example think about the Indian's bishop targeting d4 and b2 when the c pawn is not on c3). And you should of course take into consideration the length of the diagonal.


Note that essentially you don't judge the whole position, just the pawn structure. That's why count the available moves of every piece is a mistake. This just measures the mobility of the given piece and doesn't necessarily has something to do with the pawn structure. For example, in a position with no pawns a Knight on a1 has only two moves while in a closed King's Indian the f3 Knight has seven( only one is occupied by the King). Some of them drop the piece but they are legal moves nonetheless.

Hope that helps a bit!