keras_nn.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:NN_with_Keras 作者: IBMPredictiveAnalytics 项目源码 文件源码
def check(self,df):
        if self.objective == "regression" or self.objective == "classification":
            if self.input_type == "text":
                if not self.text_field:
                    raise Exception("Please specify a text field")
            else:
                if not self.target:
                    raise Exception("Please specify a target field")
                if len(self.fields) == 0:
                    raise Exception("Please specify at least one predictor field")
                numericTarget = False
                if df[self.target].dtype == np.number:
                    numericTarget = True
                if self.objective == "regression" and not numericTarget:
                    raise Exception("Please use a numeric target field for the regression objective")
                if self.objective == "classification" and numericTarget:
                    raise Exception("Please use a string target field for the classification objective")

        elif self.objective == "time_series":
            if not self.target:
                raise Exception("Please specify a target field")
            if not self.order_field:
                raise Exception("Please specify an index field")
            if df[self.target].dtype != np.number:
                raise Exception("Please use a numeric target field for the time series objective")
        else:
            if len(self.fields) == 0:
                raise Exception("Please specify at least one predictor field")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号