當前位置: 首頁>>代碼示例>>Python>>正文


Python Importer.get_data方法代碼示例

本文整理匯總了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()
開發者ID:ml-smores,項目名稱:leopard,代碼行數:47,代碼來源:split_data.py


注:本文中的importer.Importer.get_data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。