Esempio n. 1
0
ax.tick_params(axis='both', which='major', labelsize=25)
ax.tick_params(axis='both', which='minor', labelsize=25)
ax.set_title('Inverse Participation Ratio week ' + str(w+1), fontsize = 30)
ax.grid()
# graph[countGraph].axhline(y=0, color='k')
# graph[countGraph].axvline(x=0, color='k')
eigenValueList = pca_result[9].explained_variance_
eigenVectorList = pca_result[9].components_
IPRlist = libRMT.IPRarray(eigenValueList,eigenVectorList)
ax.axhline(y=IPRlist['IPR'].mean(), color='k', label='mean value of IPR') 
ax.plot(IPRlist['eigenvalue'], IPRlist['IPR'], '-', color ='blue', label='IPR')
ax.legend(loc='upper right')
plt.show()

#outbounce select
a = libRMT.selectOutboundComponents(pcaDataWeeks[9],pca_result[9].explained_variance_)

#eigenvalues
fig = plt.figure(figsize=(40,30),dpi=240)
graph = []
countGraph = 0
num_bins = 100
for w in range(0,12):
    ax = fig.add_subplot(3,4,w+1)
    graph.append(ax)
    graph[countGraph].set_xlabel('eigenvalue λ', fontsize = 15)
    graph[countGraph].set_ylabel('P(λ)', fontsize = 15)
    graph[countGraph].set_title('Week ' + str(w+1), fontsize = 20)
    graph[countGraph].grid()
    # graph[countGraph].axhline(y=0, color='k')
    # graph[countGraph].axvline(x=0, color='k')
Esempio n. 2
0
    # tempData = tempData.merge(prediction_transition[w+1]['data']['successPassedRate'], left_on = tempData.index, right_on=prediction_transition[w+1]['data']['successPassedRate'].index).set_index('key_0')
    temp = FCAMiner.PCAcohortToValue(tempData)
    temp1 = temp[1]
    pcaResult = temp[0]
    # temp1 = temp1.merge(prediction_transition[w+1]['data']['result_exam_1'], left_on = temp1.index, right_on=prediction_transition[w+1]['data']['result_exam_1'].index).set_index('key_0')
    pcaDataWeeks.append(temp1)
    pca_result.append(pcaResult)
    columnsReturn2.append(temp[2])

import libRMT

transitionDataMatrixWeeks_directFollow_standardised_outbound = []
for week in range(0, 12):
    transitionDataMatrixWeeks_directFollow_standardised_outbound.append(
        libRMT.selectOutboundComponents(pcaDataWeeks[week],
                                        pca_result[week].explained_variance_,
                                        mode="upper"))

transitionDataMatrixWeeks_directFollow_standardised_cleaned = []
for week in range(0, 12):
    outBoundComponents = transitionDataMatrixWeeks_directFollow_standardised_outbound[
        week].columns
    componentToClean = ['pc1']
    for c in pcaDataWeeks[week].columns:
        if c not in outBoundComponents:
            componentToClean.append(c)
    transitionDataMatrixWeeks_directFollow_standardised_cleaned.append(
        libRMT.cleanEigenvectorEffect(
            transitionDataMatrixWeeks_directFollow_standardised[week],
            pcaDataWeeks[week], componentToClean, pca_result[week].components_,
            0.8, 0.5))
Esempio n. 3
0
        'correct'] / practiceResult.groupby(
            [pd.Grouper(key='user'),
             pd.Grouper(key='task')]).count()['correct']
    cummulativeResult = practiceResultSum.reset_index().groupby(
        [pd.Grouper(key='user')]).sum()

    # cummulativeResult = practiceResultSum.groupby([pd.Grouper(key='user')]).sum()
    cummulativeResult['cumm_practice'] = cummulativeResult[
        'correct'] / practiceResult.groupby([pd.Grouper(key='user')
                                             ]).count()['date']
    cummulativeResult['successPassedRate'] = cummulativeResult['passed'] / (
        cummulativeResult['passed'] + cummulativeResult['failed'])

    pcaData1 = transitionDataMatrixWeeks[week]  #original data - scenario 1
    pcaData2 = libRMT.selectOutboundComponents(
        pcaDataWeeks[week], eigenValueList[week]
    )  #filtered pca data to original data - scenario 2 #testing with eigenvalue > 1
    pcaData3 = pcaDataWeeks[week]  #full pca data - scenario 3
    pcaData4 = transitionDataMatrixWeeks_normalised_cleaned[
        week]  #clean data - scenario 4
    pcaData5 = pcaDataWeeks_cleanedData[week]  #pca clean data - scenario 5
    pcaData6 = libRMT.selectOutboundComponents(
        pcaDataWeeks_cleanedData[week], eigenValueList_cleanedData[week]
    )  #pca filtered clean data - scenario 6
    # print(pcaData.columns)

    mode = 'transition'

    tic = time.time()
    test1 = PredictionResult.predict_proba_all_algorithms_data_ready(
        pcaData1, excellent, weak, cummulativeResult, mode)