<jupyter_start><jupyter_text>Dataset selection<jupyter_code>_dataName, _inputData, _dataNameSUSNormalized, _inputDataSUSNormalized = selectDataset("data20190703")
stackedBarPlotsFilenamePathStem = graphsSavePathStem + "/SUS-matrices"
tryCreateFolder(stackedBarPlotsFilenamePathStem)<jupyter_output><empty_output><jupyter_text>SUS score functions<jupyter_code>def getSUSScore(question, game, data=_inputDataSUSNormalized, printResult=True):
    _score = 0
    _maxScore = 0
    _gameQuestionData = data.loc[data[gameQuestion]==game, question]

    for _answer in _gameQuestionData:
        if pd.notna(_answer):
            _score += _answer
            _maxScore += 4

    _percentageScoreResult = _score*100/_maxScore
    if printResult:
        print("'" + question + "': " + game + " " + '{:1.1f}%'.format(_percentageScoreResult))
    return _percentageScoreResult<jupyter_output><empty_output><jupyter_text>Best scores per question, including non-SUS Q11<jupyter_code>print("Best scores:")
for question in indexedLikertQuestions:
    bestGame = ""
    bestScore = 0
    for game in games:
        questionScore = getSUSScore(question, game, printResult=False)
        if questionScore > bestScore:
            bestGame = game
            bestScore = questionScore
    print("'" + question + "': " + bestGame + " " + '{:1.1f}%'.format(bestScore))<jupyter_output><empty_output><jupyter_text>Worst scores per question, including non-SUS Q11<jupyter_code>print("Worst scores:")
for question in indexedLikertQuestions:
    worstGame = ""
    worstScore = 100
    for game in games:
        questionScore = getSUSScore(question, game, printResult=False)
        if questionScore < worstScore:
            worstGame = game
            worstScore = questionScore
    print("'" + question + "': " + worstGame + " " + '{:1.1f}%'.format(worstScore))<jupyter_output><empty_output><jupyter_text>SUS scores matrices<jupyter_code>allSUSScores = pd.DataFrame(index=indexedSUSQuestions, columns=games)
for game in games:
    for question in indexedSUSQuestions:
        allSUSScores.loc[question, game] = getSUSScore(question, game, printResult=False)

allSUSScores = allSUSScores.astype(float)
saveFig = True

# normalize using minimum

fig = plt.figure()
ax = fig.add_subplot(111)
h = sns.heatmap(allSUSScores,
            ax=ax,
            cmap=plt.cm.jet,
            vmin=0,
            vmax=100,
            square=True,
            cbar_kws = dict(use_gridspec=False,location="left")
           )
ax.yaxis.tick_right()
plt.yticks(rotation=0);

# manually moves x labels closer to their ticks
h.set_xticklabels(ax.get_xticklabels(), rotation=30)
indexer = 0
for label in ax.xaxis.get_majorticklabels():
    dx = (50 - indexer * 9)/72.; dy = 0/72. 
    offset = tr.ScaledTranslation(dx, dy, fig.dpi_scale_trans)
    label.set_transform(label.get_transform() - offset)
    indexer+=1    
    
if saveFig:
    path = stackedBarPlotsFilenamePathStem + "/" + _dataName
    tryCreateFolder(path)
    fig.savefig(path + "/SUS-score-matrix")
pd.concat((allSUSScores.idxmin(), allSUSScores.min()), 1)
pd.concat((allSUSScores.idxmax(), allSUSScores.max()), 1)<jupyter_output><empty_output><jupyter_text>SUS scores variance<jupyter_code>def getVarianceOnQG(question, game, data=_inputData, printResult=True):
#    print("Q='"+question+"'; G="+game)
    gameQuestionData = data.loc[data[gameQuestion]==game, question]
    gameQuestionData = [int(v) for v in gameQuestionData if pd.notna(v)]
    return np.var(gameQuestionData)
allVars = pd.DataFrame(index=indexedSUSQuestions, columns=games)
for game in games:
    for question in indexedSUSQuestions:
        allVars.loc[question, game] = getVarianceOnQG(question, game, printResult=False)

allVars = allVars.astype(float)
saveFig = True

fig = plt.figure()
ax = fig.add_subplot(111)
h = sns.heatmap(allVars,
            ax=ax,
            cmap=plt.cm.jet,
            vmin=0.4,
            vmax=2.2,
            square=True,
            cbar_kws = dict(use_gridspec=False,location="left")
           )
ax.yaxis.tick_right()
plt.yticks(rotation=0);

# manually moves x labels closer to their ticks
h.set_xticklabels(ax.get_xticklabels(), rotation=30)
indexer = 0
for label in ax.xaxis.get_majorticklabels():
    dx = (50 - indexer * 9)/72.
    dy = 0/72. 
    offset = tr.ScaledTranslation(dx, dy, fig.dpi_scale_trans)
    label.set_transform(label.get_transform() - offset)
    indexer+=1

if saveFig:
    path = stackedBarPlotsFilenamePathStem + "/" + _dataName
    tryCreateFolder(path)
    fig.savefig(path + "/SUS-score-variance-matrix")
# recommendations:
#    - best game: which questions?
#    
pd.concat((allVars.idxmin(), allVars.min()), 1)
pd.concat((allVars.idxmax(), allVars.max()), 1)<jupyter_output><empty_output><jupyter_text>Global SUS score<jupyter_code>getSUSScore(question, game, data=_inputDataSUSNormalized, printResult=False)
totalSUSScore = 0
questionSUSScore = 0
for game in games:
    print("---------------------------------------------------------------------------")
    print(game)
    for question in indexedSUSQuestions:
        questionSUSScore = getSUSScore(question, game, data=_inputDataSUSNormalized, printResult=False)
        totalSUSScore += questionSUSScore
        print('{:1.1f}%'.format(questionSUSScore) + " " + question)
    totalSUSScore = totalSUSScore / (len(indexedSUSQuestions))
    print('{:1.1f}%'.format(totalSUSScore))
totalSUSScore = 0
questionSUSScore = 0
for game in games:
    print("---------------------------------------------------------------------------")
    print(game)
    question = shortLikertQuestions[lastLikertQuestionIndex-1]
    questionSUSScore = getSUSScore(question, game, data=_inputDataSUSNormalized, printResult=False)
    print('{:1.1f}%'.format(questionSUSScore) + " " + question)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1433230346721593, 'fraction_numerical': 0.014246481290765533, 'mean_word_length': 3.650438946528332, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '236156', 'license': 'MIT', 'n_tokens_mistral': 1997, 'n_tokens_neox': 1925, 'n_words': 346, 'path': 'Functions/3.0 Global SUS score.ipynb', 'repo_name': 'raphik12/AMRGamesAnalysis', 'size': '5826'}