Package: itca
ITCA - Guide the ambiguous outcome labels combination for multi-class classificationITCA(Information-theoretic classification accuracy) is a criterion that guides data-driven combination of ambiguous outcome labels in multi-class classification (seeITCA documentationfor detailed guides).InstallationRequirements:python >= 3.6numpy:https://pypi.org/project/numpy/scikit-learn:https://pypi.org/project/scikit-learn/[optional] pygraphviz:https://pypi.org/project/pygraphviz/(for visualization)Install from PyPI by running (in the command line):pipinstallitcaInstall from source code:gitclonehttps://github.com/JSB-UCLA/ITCA.gitcdITCApythonsetup.pyinstallITCA is easy to use.importnumpyasnpfromsklearn.discriminant_analysisimportLinearDiscriminantAnalysisfromitcaimportitca,compute_y_dist,bidict,GreedySearch# ===================  Data ========================# `X` is the feature matrix, a 2D numpy array of size (n_smaples, n_features).# `y_obs` is the observed labels, a 1D numpy array of size (n_samples, ) that takes values# in [0, 1, 2] (the observed classes number K0=3).# The combination is represented by a bidirectional disctionary `bidict`.# `bidict({0:0, 1:0, 2:1, 3:2})` indactes the mapping from the orignal labels to the combined labels.true_combination=bidict({0:0,1:0,2:1,3:2})X1=np.array([[0.,0.]])+np.random.randn(200,2)X2=np.array([[1.5,1.5]])+np.random.randn(200,2)X3=np.array([[-1.5,1.5]])+np.random.randn(200,2)X=np.concatenate([X1,X2,X3])# data matrixy_true=np.concatenate([np.ones(200)*iforiinrange(3)]).astype(int)# true lables K^*=3y_obs=true_combination.reverse_map(y_true)# observed labels K_0=4#===========  Classsification algorithm =============# `clf` can be any sklearn classifcation algorithm or any classifcation algorithm that implements# `clf.fit(X, y)` for fitting and `clf.predict(X)` for prediction.clf=LinearDiscriminantAnalysis()# =================== Evaluate s-ITCA on the true combination ================clf.fit(X,true_combination.map(y_obs))y_pred=clf.predict(X)itca(y_obs,y_pred,true_combination,compute_y_dist(y_obs))# ============= Search class combination =============gs=GreedySearch(class_type='ordinal')gs.search(X,y_obs,clf,verbose=False,early_stop=True)gs.selected# show the selected class combination#>>>{0: 0, 1: 0, 2: 1, 3: 2}|ITCA=0.8807|Please see thetutorialfor more details.TroubleshootingFor visualization, ITCA requirespygraphvizpackage. If you have trouble installingpygraphviz, please refer topygraphvizfor detailed installation guides.
Please make sure thatdotis in yourPATHenvironment variable. If you are using Windows, please refer toGraphvizfor detailed installation guides.Citation@article{JMLR:v23:21-1150,
  author  ={Chihao Zhang and Yiling Elaine Chen and Shihua Zhang and Jingyi Jessica Li},
  title   ={Information-theoretic Classification Accuracy: A Criterion that Guides Data-driven Combination of Ambiguous Outcome Labels in Multi-class Classification},
  journal ={Journal of Machine Learning Research},
  year    ={2022},
  volume  ={23},
  number  ={341},
  pages   ={1--65},
  url     ={http://jmlr.org/papers/v23/21-1150.html}}ContributeIssue tracker:https://github.com/messcode/ITCA/issuesSource code:https://github.com/JSB-UCLA/ITCAhttps://github.com/messcode/ITCA(the devlopmental version)ContactIf you are having any issues, comments regarding this project, please feel free to contactzhang.dabiao11@gmail.com