首页 > 其他分享 > auto_sklearn autosklearn AttributeError: 'NoneType' object has no attribute 'info�

auto_sklearn autosklearn AttributeError: 'NoneType' object has no attribute 'info�

时间:2023-10-08 17:55:24浏览次数:33  
标签:info no envs auto py File home line software

 

 
Traceback (most recent call last):
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/site-packages/autosklearn/automl.py", line 634, in fit
    self._logger = self._get_logger(dataset_name)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/site-packages/autosklearn/automl.py", line 390, in _get_logger
    self.logging_server.start()
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/process.py", line 112, in start
    self._popen = self._Popen(self)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/context.py", line 291, in _Popen
    return Popen(process_obj)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/popen_forkserver.py", line 35, in __init__
    super().__init__(process_obj)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/popen_fork.py", line 20, in __init__
    self._launch(process_obj)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/popen_forkserver.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError:
        An attempt has been made to start a new process before the     current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your     child processes and you have forgotten to use the proper idiom      in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program     is not going to be frozen to produce an executable.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/site-packages/autosklearn/automl.py", line 961, in fit
    self._logger.exception(e)
AttributeError: 'NoneType' object has no attribute 'exception'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/forkserver.py", line 281, in main
    old_handlers)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/forkserver.py", line 317, in _serve_one
    code = spawn._main(child_r)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/spawn.py", line 114, in _main
    prepare(preparation_data)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/spawn.py", line 225, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/multiprocessing/spawn.py", line 277, in _fixup_main_from_path
    run_name="__mp_main__")
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/data/pigenhancer/transformer_test/auto_sklearn_demo01_iris_classification.py", line 34, in <module>
    model.fit(X_train, y_train)# 预测并计算准确率得分
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/site-packages/autosklearn/estimators.py", line 1454, in fit
    dataset_name=dataset_name,
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/site-packages/autosklearn/estimators.py", line 540, in fit
    self.automl_.fit(load_models=self.load_models, **kwargs)
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/site-packages/autosklearn/automl.py", line 2313, in fit
    is_classification=True,
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/site-packages/autosklearn/automl.py", line 964, in fit
    self._fit_cleanup()
  File "/home/software/anaconda3/envs/bert_env/lib/python3.7/site-packages/autosklearn/automl.py", line 1064, in _fit_cleanup
    self._logger.info("Closing the dask infrastructure")
AttributeError: 'NoneType' object has no attribute 'info'

 

 print("Precision", sklearn.metrics.precision_score(y_test, predictions))

ValueError: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].

 Target is multiclass but average=‘binary’. Please choose another average setting, one of [None, ‘micro’, ‘macro’, ‘weighted’].

原代码如下,是要求某数据集的F1(精度和召回率组合成单一的指标)。

from sklearn.metrics import precision_score, recall_score

precision_score(y_train, y_train_pred)


解决办法

原代码基础上添加了average=‘micro’。

from sklearn.metrics import precision_score, recall_score

precision_score(y_train, y_train_pred, average='micro')


average参数定义了该指标的计算方法,二分类时average参数默认是binary;多分类时,可选参数有micro、macro、weighted和samples。

None:返回每个班级的分数。否则,这将确定对数据执行的平均类型。

binary:仅报告由指定的类的结果pos_label。仅当targets(y_{true,pred})是二进制时才适用。

micro:通过计算总真阳性,假阴性和误报来全球计算指标。也就是把所有的类放在一起算(具体到precision),然后把所有类的TP加和,再除以所有类的TP和FN的加和。因此micro方法下的precision和recall都等于accuracy。

macro:计算每个标签的指标,找出它们的未加权平均值。这不会考虑标签不平衡。也就是先分别求出每个类的precision再求其算术平均。

weighted:计算每个标签的指标,并找到它们的平均值,按支持加权(每个标签的真实实例数)。这会改变“宏观”以解决标签不平衡问题; 它可能导致F分数不在精确度和召回之间。

samples:计算每个实例的指标,并找出它们的平均值(仅对于不同的多标记分类有意义 accuracy_score)。

参考:https://blog.csdn.net/datongmu_yile/article/details/81750737
 链接:https://blog.csdn.net/weixin_44436677/article/details/105985358

标签:info,no,envs,auto,py,File,home,line,software
From: https://www.cnblogs.com/emanlee/p/17749702.html

相关文章

  • LY1366 [ 20231005 NOIP 模拟赛 T0 ] 加固
    题意设\(T\)是由\(26\)小写英文字母排列得到的字符串。\(T'\)由\(T\)复制若干次得到。给定字符串\(S\)为\(T'\)的子序列,求\(T'\)的最小复制次数。保证出现的不同字母不超过\(20\)种\(1\le|S|\le10^5\)Sol一个巧妙的转化,考虑将\(T\)串作为字典序,那么当......
  • redis-cluster nodes命令信息说明
     集群定义1.1每个字段的含义如下:1.id:节点ID,一个40字节的随机字符串,节点创建时生成,且不会变化(除非使用CLUSTERRESETHARD命令)。2.ip:port:客户端访问的地址。3.flags:逗号分隔的标记位,可能值有:myself,master,slave,fail?,fail,handshake,noaddr,noflags......
  • Mysql 8.0 Navicat连接Mysql报错Authentication plugin ‘caching_sha2_password‘ ca
    1、终端登陆MySQL$mysql-uroot-ppassword#登入mysql2、修改账户密码加密规则并更新用户密码ALTERUSER'root'@'localhost'IDENTIFIEDBY'123456'PASSWORDEXPIRENEVER;#修改加密规则ALTERUSER'root'@'localhost'IDENTIFIEDWITHmysql_nat......
  • LY1374 [ 20231008 NOIP 模拟赛 T2 ] 机房惨案
    题意给定一棵树,每次操作将一个点染成黑色。求询问的点到所有黑点的路径编号最小值。**数据保证第一次为染色操作**Sol注意到保证第一次为染色。考虑钦定根节点为染色的点。那么对于所有染色操作,暴力记录染色的点到根节点的路径上所有点的贡献。每个点只会贡献一次,这部分......
  • Could not resolve all dependencies for configuration ':testCompileClasspath'. Us
    Gradleinit.gradle文件参数错误导致的Gradle加载失败 1allprojects{2repositories{3mavenLocal()4maven{name"Alibaba";url"https://maven.aliyun.com/repository/public"}//将http改为https5maven{name&......
  • mysqldump 导出来的文件,使用 source还原时报错“ASCII '\0' appeared in the stateme
    导出语句:mysqldump-uroot-pword--databasesdb1--tablestable1>./sqldumps/archive-table1-`date+"%Y%m%d_%H%M%S"`.sql导出后,使用source还原报错:ASCII'\0'appearedinthestatement,butthisisnotallowedunlessoption我开始以为是我导出的编码格式有问题,......
  • ORA-12012 Error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_<NN> in 12.2 Dat
    1错误2023-10-08T13:11:12.127171+08:00Errorsinfile/oracle/diag/rdbms/arch/ARCH2/trace/ARCH2_j000_305066.trc:ORA-12012:erroronautoexecuteofjob"SYS"."ORA$AT_OS_OPT_SY_154038"ORA-20001:StatisticsAdvisor:Invalidtasknamefo......
  • (unordered_)set,(unordered_)map,数组(vector)
    set:保证元素的唯一性,并且元素从小到大排序unordered_set:保证元素的唯一性,并且元素的顺序未知,不一定和输入相同map:键从小到大排序unordered_map:键的顺序未知,不一定和输入相同数组(vector):元素的顺序和输入相同......
  • Centos系统安装MySQL数据库时,要以不安全的方式连接至 dev.mysql.com,使用“--no-check-
    解决:要以不安全的方式连接至dev.mysql.com,使用“--no-check-certificate” 问题:[root@192桌面]#wgethttps://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm--2023-10-0812:44:16--https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.......
  • node版本管理和安装
    1.使用nvm进行node版本管理。在window下安装nvm,下载地址:https://github.com/coreybutler/nvm-windows,下载exe包进行安装。2.安装完成后打开cmd,输入nvm-v查看版本。显示:1.1.11具体版本根据你下载的版本。(如果在安装之前已经安装过node,会有询问框是否把已经存在的版本纳入管理,......