# Rough Set Theory and Soft Computing Methods for Building Explainable and Interpretable AI/ML Models
## 4 Methodology
### Classification
#### 4.2.2 MLSpecialReduct  
The **MLSpecialReduct** algorithm computes a minimal subset of attributes from a decision system \(DS\) that preserves the dependency of the decision column \(d\). It iteratively builds the reduct \(R\) by adding attributes from the full set \(C\) that maximize dependency, stopping when \(R\) matches the dependency of all attributes or fails to improve. This process optimizes attribute selection for classification tasks. Algorithm 6 computes the indiscernibility relation \(ind\_c\) for the decision system \(DS\). The indiscernibility relation groups indistinguishable objects based on the given attributes. In MLSpecialReduct, \(ind\_c\) is used within the Dependance_Attributs function to evaluate attribute dependency by grouping objects for positive region computation. ```
0: Decision system \(DS\), decision column \(d\)
0: Indiscernibility relation \(ind\_c\)
1:\(ind\leftarrow[]\)
2:\(IS\gets DS.drop(d,axis=1)\)
3:\(group\gets IS.groupby(\text{list}(IS.columns))\)
4:for\(g\) in \(group\)do
5:\(gDS\leftarrow\text{pd.DataFrame}(g[1])\)
6:\(ind.append(\text{list}(gDS.index))\)
7:endfor
8:\(ind.sort()\)
9:returnind
```  
**Algorithm 7** MLSpecialReduct  
Algorithm 7 computes the dependency of a given set of attributes \(C\) in the decision system \(DS\). Dependency measures the proportion of objects correctly classifiable into decision classes based on \(C\). In MLSpecialReduct, Dependance_Attributs is repeatedly called (e.g., lines 8, 13, 17, 25) to assess the dependency of the current reduct \(R\) and potential attribute additions, guiding the iterative selection process. ```
1:Decision system \(DS\), attribute list \(C\), decision column \(d\)
2:Dependency of attributes
3:\(ds\gets DS[C]\)
4:if\(\text{len}(\text{list}(ds.columns))=1\) and \(\text{list}(ds.columns)[0]=d\)thenreturn 0
5:endif
6:\(ind\_c\gets IND\_C(ds,d)\)
7:\(pos\_c\gets POS\_C(ds,d)\)
8:\(dep\leftarrow\text{float}(\text{len}(pos\_c))/\text{len}(ds.index)\)
9:return\(dep\)
```  
**Algorithm 7** Dependance_Attributs  
B-lower approximation, Algorithm 8, a core concept in Rough Set Theory, identifies objects in a decision system \(DS\) that are certainly classifiable into a specific decision class \(d\_value\) based on an indiscernibility relation \(ind\_c\). In MLSpecialReduct, the B-lower approximation is indirectly used via POS_C (called by Dependance_Attributs) to compute the positive region, assessing how well attributes classify objects. ```
1:Decision system \(DS\), indiscernibility relation \(ind\_c\), decision column \(d\), decision value \(d\_value\)
2:B-lower approximation \(CXi\) or \"error\" if \(d\_value\) not found
3:\(X\gets DS.groupby(d)\)
4:\(Xi\leftarrow\) None
5:for\((name,group)\) in \(X\)do
6:if\(name=d\_value\)then
7:\(Xi\leftarrow\text{pd.DataFrame}(group)\)
8:endif
9:endfor
10:if\(Xi\
eq\) None then
11:\(CXi\leftarrow[]\)
12:for\(index\)in\(Xi.index\)do
13:\(id\_obj\gets group\_ind\_c\_obj(ind\_c,index)\)
14:if\(\
eg\text{any}(DS.at[index.obj2,d]\
eq DS.at[index,d]\) for\(index\_obj2\) in \(id\_obj)\)then
15:\(CXi.append(index)\)
16:endif
17:endfor
18:\(CXi.sort()\)return\(CXi\)
19:elsereturn\"error\"
20:endif
```  
**Algorithm 8** B-Lower Approximation  
B-lower approximation, Algorithm 9, another cornerstone of Rough Set Theory, defines objects in a decision system \(DS\) possibly belonging to a specific decision class \(d\_value\) based on an indiscernibility relation \(ind\_c\). In MLSpecialReduct, the B-upper approximation is indirectly utilized through POS_C (via Dependance_Attributs) to support positive region calculations, though its primary role is secondary to the dependency focus. Algorithm 10 is the main algorithm for computing a minimal subset of attributes (reduct) that preserves the dependency of the decision column \(d\). It iteratively adds attributes to the reduct \(R\) that maximize dependency, stopping when \(R\) matches the dependency of the full attribute set or no further improvement is possible.