本文整理汇总了Python中importer.Importer.get_data方法的典型用法代码示例。如果您正苦于以下问题:Python Importer.get_data方法的具体用法?Python Importer.get_data怎么用?Python Importer.get_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类importer.Importer
的用法示例。
在下文中一共展示了Importer.get_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from importer import Importer [as 别名]
# 或者: from importer.Importer import get_data [as 别名]
def create(chapter_id, kctype, file_kcids=None, debug=False, train_pct= 0.6, dev_pct=0.2, index=""):
file_name = IntermediateData.input_path + "homework_xref_" + str(chapter_id) + "_decompressed.csv"
print "CLEANING DATA..."
imp = Importer()
df_imp = imp.get_data(file_name, kctype, debug)
kc_col = "kc"
if kctype == "tom":
kc_definition = [kc_col]
else:
#TODO: We should extracting features from exercises, but feature extracting does not support this
kc_definition = [kc_col] #",exercise_id]"
# Sort data
df_imp = FeatureExtractor.sort(df_imp)
for kc in df_imp[kc_col].unique():
print kc_col, kc
# GET SUBSET of data
df = df_imp[ df_imp[kc_col] == kc]
# "EXTRACTING FEATURES..."
fe = FeatureExtractor(default_kc=kc_definition)
df_features = fe.df_to_features(df, sort_data=False) # No need to sort data
# "SUBSET OF DATA..."
df_train, df_dev, df_test = split(df_features, train_pct, dev_pct)
# "STORING"
chapter_data = IntermediateData(chapter_id, kc, df_features, train_rows=df_train, dev_rows=df_dev, test_rows=df_test)
filename = os.path.join(IntermediateData.output_path, index, IntermediateData.get_filename(kctype, kc))
f_output = open( filename, "w")
pickle.dump(chapter_data, f_output)
f_output.close()
#hy commented
#df_features.to_csv(filename + ".csv")
if file_kcids != None:
file_kcids.write( str(chapter_id) +","+ str(kc) + "," + index + "\n")
file_kcids.flush()