in sourcecode/scoring/matrix_factorization/pseudo_raters.py [0:0]
def _add_extreme_raters_to_id_maps_and_params(self):
"""Adds extreme raters to a new copy of raterIdMap and raterParams called
self.raterIdMapWithExtreme and self.raterParamsWithExtreme
"""
# TODO: should concat all at once for efficiency instead of iterative appends
self.raterIdMapWithExtreme = self.raterIdMap.copy(deep=True)
self.raterParamsWithExtreme = self.raterParams.copy(deep=True)
for i, raterDict in enumerate(self.extremeRaters):
if not (self.raterIdMap[c.raterParticipantIdKey] == raterDict[c.raterParticipantIdKey]).any():
self.raterIdMapWithExtreme = pd.concat(
[
self.raterIdMapWithExtreme,
pd.DataFrame(
{
c.raterParticipantIdKey: [raterDict[c.raterParticipantIdKey]],
mf_c.raterIndexKey: [raterDict[mf_c.raterIndexKey]],
}
),
],
unsafeAllowed=c.raterParticipantIdKey,
)
if not (
self.raterParams[c.raterParticipantIdKey] == raterDict[c.raterParticipantIdKey]
).any():
self.raterParamsWithExtreme = pd.concat(
[
self.raterParamsWithExtreme,
pd.DataFrame(
{
c.raterParticipantIdKey: [raterDict[c.raterParticipantIdKey]],
c.internalRaterInterceptKey: [raterDict[c.internalRaterInterceptKey]],
c.internalRaterFactor1Key: [raterDict[c.internalRaterFactor1Key]],
}
),
],
unsafeAllowed={
c.raterParticipantIdKey,
c.internalRaterInterceptKey,
c.internalRaterFactor1Key,
},
)