DOI: 10.6084/m9.figshare.30636788
title: <b>Toward Implicit Gaze-Based Map Interaction: Predicting Selection Intentions from Eye Movements</b>

description: <b>README for Code and Data of the Research Paper</b><b>Title: </b><b>Toward Implicit Gaze-Based Map Interaction: Predicting Selection Intentions from Eye Movements</b>1. Requirements- python=3.9.18- scipy=1.11.4- tqdm=4.66.5- numpy=1.26.3- pandas=2.1.4- matplotlib=3.7.2- scikit-learn=1.4.2- lightgbm=4.3.0- imbalanced-learn=0.11.0- xgboost=1.7.3- shap=0.42.12. Folder StructureThe folder named <b>“GazeUserProfiling”</b> contains the following subdirectories:· <b>code</b>: Contains code of preprocessing and classification for the GazeIntentionPredicting.· <b>data</b>: Includes the raw data for computing eye movement features: gaze data, fixation data, saccade data, the map distinction coordination required for computing the GazeDistance feature and fixationfrequency.csv, which is used in computing saccade encoding.· <b>result: </b>We provide several feature computation and intention prediction results, organized into three folders: <b>cross_dataset</b>, which contains the cross-dataset prediction results; <b>Feature</b>, which includes the K-fold and LOGO cross-validation results as well as the computed features metrics; <b>FeatureClassify</b>, which contains the classified features in the mouse interaction mode. In addition, The folder also includes, for reference, the features selected in the gaze mode under the 1000-window/1000-step setting with 1Win-In-Adv prediction in the K-fold cross-validation, called <b>selected_features.txt</b>.· <b>readme.pdf</b>: This README file.· <b>GazeIntentionPredicting.yml</b>: The required dependencies for setting up the Python coding environment.3. Running Instructions<b>Step 1: Compute the eye movement features which are used in classification.</b>Run TimeWindowQuantify.py to output the raw data with timestamps. The input data is ‘data/ fixation.csv’. Then run Window_Feature.py, which uses the function FeatureComputing(fixationfile, saccadefile, fixgazefile, window, step, round) from FeatureComputing.py to generate the feature set. The FeatureComputing() function calls functions within GazeFeatureCalculate.py to compute various eye-movement features and integrate them.<b>Step 2: Preprocessing.</b>Run the script ‘ClassifierCompare.py’, to determine the best classifier in Section 2.5. Run the script ‘FeatureSelectionCurve.py’ to select the number of features to extract in Section 2.4. Both scripts need to use the eye movement features runed in Step1 as input.<b>Step 3: Classification.</b>Run the script ‘GazeSelectionPredicting_Window.py’ to conduct the K-fold cross-validation in Section 2.6 (1).Run the script ‘MixPredicting.py’ to conduct the cross-dataset in Section 2.6 (2).Run the script ‘GazeSelectionPredicting_Window_LOPO.py’ to conduct the LOGO cross-validation in Section 2.6 (3).Run the script ‘GazeSelectPredicting_Window_Selection.py’ to perform classification including the selection points and get the result in Section 3.1, Table 4.Run the script ‘FeatureClassifyPrediction.py’ to perform classification for different types of eye movement features and get the result in Section 3.3, Figure 9.4. code1. TimeWindowQuantify.pyDetermine the timestamp corresponding to each fixation, <b>mode </b>is the interactive mode, gaze or mouse.· <b>Function: TimeWindowQuantify(mode)</b>· <b>Output: Fixation file with timestamps, used as input for Window_Feature()</b>2. Window_Feature.pyCompute the eye movement feature file for a given time window combination, the function internally calls <b>FeatureComputing()</b>.· <b>Function</b>: <b>WindowFeature(window, step, timefile, mode)</b>.· <b>Input: window</b> is the size of time window; <b>step</b> is the length of the time window step; <b>timefile</b> is the output of <b>TimeWindowQuantify(mode)</b>; <b>mode</b> is the interactive mode.· <b>Output</b>: <b>Windowfile</b>: Eye movement feature file for the input time window combination, which can be saved freely.3. FeatureComputing.pyCompute all eye movement features and consolidate them into a single .csv file.· <b>Function: FeatureComputing(fixationfile, saccadefile, fixgazefile, window, step, round)</b>· <b>Input: fixationfile</b>, <b>saccadefile</b>, <b>fixgazefile</b> is a fixation, saccade, gaze file with timestamps and corresponding indices, respectively; <b>window</b> is the size of time window; <b>step</b> is the length of the time window step; <b>round</b> is the num of advanced time. These inputs are already computed within <b>WindowFeature(window, step, timefile, mode)</b> and can be called directly, theoretically, no modification is needed.· <b>Output: FeatureFileSet: </b>the consolidated feature set.4. GazeFeatureCalculate.py· <b>Function:</b> <b>FixationDensity(fixationfile); SaccadeFrequency(fixationfile, saccadefile, window, step, round); SaccadeFixationRate(fixationfile, saccadefile); ConvexHullArea(saccadefile); TotalScanpathLength(saccadefile); RawXYStd(fixationfile, fixgazefile); RawGazeStatistical(fixationfile, fixgazefile); GazeXYDelta(fixationfile, fixgazefile); SaccadeEncoding(saccadefile); SaccadeStatisticalFeature(saccadefile); FixationStatisticalFeature(fixationfile); GazeDistanceFeature(fixationfile).</b>· <b>Input:</b> Same as the input for <b>FeatureComputing.py</b>.· <b>Output:</b> Each function returns its own feature file separately.5. ClassifierCompare.pySelect the optimal classifier.· <b>Function</b>: <b>get_classifier(clf_name)</b>; <b>ClassifierCompare(classifier, mode)</b>· <b>Input</b>: <b>clf_name</b>, <b>classifier</b>: The corresponding classifier type; <b>mode</b> is the interactive mode· <b>Output</b>: The <b>get_classifier(clf_name)</b> function returns the corresponding classification algorithm. the results are output to a file in <b>ClassifierCompare (classifier, mode)</b>, which does not return any value.6. FeatureSelectionCurve.pySelect the optimal number of feature selection.· <b>Function</b>: <b>FeatureSelectionCurve(mode, num, n)</b>· <b>Input</b>: <b>mode</b> is the interactive mode; <b>num</b> is the num of advanced window; <b>n</b> is the num of selected features.· <b>Output</b>: Output the result file containing the current number of extracted features n, the function does not return a value.7. custom_fit.pyConduct the grid search and simultaneously output the current progress of the grid search. The custom_fit() is called by the classification function.· <b>Function: ParameterSearch (clf_name); custom_fit(model, grid, X_train, y_train, X_val, y_val, cv=5)</b>· <b>Input: clf_name</b> is the corresponding classifier type and this is ‘LightGBM’; <b>model</b> is the classifier algorithm, <b>grid</b> is the parameter grid returned by <b>ParameterSearch(clf_name)</b>, and <b>X_train</b>, <b>y_train</b>, <b>X_val</b>, <b>y_val</b> are the corresponding training and validation sets.· <b>Output:</b> the best params and score for the results of grid search.8. FeatureSelection_mRMR.pyConduct the feature selection using mRMR. This function is called by the classification function.· <b>Function: FeatureSelection_mRMR(file, featurenum)</b>· <b>Input: file</b> is the file of feature set; <b>featurenum</b> is the num of selected features.· <b>Output:</b> List of selected feature names.9. GazeSelectionPredicting_Window.pyPerforms K-Fold cross-validation (K=10).· <b>Function: GazeSelectPredicting_Window(window, step, num, mode)</b>· <b>Input: window</b> is the size of time window; <b>step</b> is the length of the time window step;<b> num </b>is the num of advanced window; <b>mode</b> is the interactive mode.· <b>Outputs:</b>o Classification performanceo SHAP value for negative classo SHAP value for positive classo SHAP value for baselineo AUC variableso Classifier probability estimateso The sample set used for the current classificationThis function does not return any values.10. GazeSelectionPredicting_Window_Selection.pyPerforms K-Fold cross-validation (K=10) using the selection window as the positive class.· <b>Function:</b> <b>GazeSelectPredicting_Window_Selection(window, step, num, mode)</b>· <b>Input: window</b> is the size of time window; <b>step</b> is the length of the time window step;<b> num </b>is the num of advanced window; <b>mode</b> is the interactive mode.· <b>Outputs:</b>o Classification performanceo SHAP value for negative classo SHAP value for positive classo SHAP value for baselineo AUC variableso Classifier probability estimateso The sample set used for the current classificationThis function does not return any values.11. MixPredicting()Performs<b> the cross-dataset classificatino</b>.• <b>Function:</b> <b>MixPredicting(trainmode, testmode).</b><b>Input:</b> <b>trainmode</b> is the mode used as training data; <b>testmode</b> is the mode used as testing data.· <b>Outputs:</b>o Classification performanceo SHAP value for negative classo SHAP value for positive classo SHAP value for baselineo AUC variableso Classifier probability estimateso The sample set used for the current classificationThis function does not return any values.12. GazeSelectionPredicting_Window_LOGO.pyPerforms LOGO cross-validation.· <b>Function: GazeSelectPredicting_Window_LOGO(window, step, num, mode)</b>· <b>Input: window</b> is the size of time window; <b>step</b> is the length of the time window step;<b> num </b>is the num of advanced window; <b>mode</b> is the interactive mode.· <b>Outputs:</b>o Classification performanceo SHAP value for negative classo SHAP value for positive classo SHAP value for baselineo AUC variableso Classifier probability estimateso The sample set used for the current classificationThis function does not return any values.13. FeatureClassifyPrediction.pyPerforms the feature classification results.· <b>Function: FeatureClassify(); FeatureClassifyPrediction(num, features)</b>· <b>Input: num </b>is the num of advanced window; <b>features</b> is the feature type.· <b>Outputs:</b>o Classification performanceo The sample set used for the current classificationThis function does not return any values.<br>