前提・実現したいこと
エラーを直したい
発生している問題・エラーメッセージ
AttributeError Traceback (most recent call last) <ipython-input-3-8055b91220f9> in <module> 97 x_tes = np.reshape(X_test, (-1,3)) 98 ---> 99 r1.fit(x_tra, Y_train) 100 predicted_labels_bs = r1.predict(x_tes) 101 if r1.best_estimator_.score(x_tra,Y_train) < 0.95: C:\ProgramData\Anaconda3\lib\site-packages\sklearn\model_selection\_search.py in fit(self, X, y, groups, **fit_params) 689 verbose=self.verbose) 690 results_container = [{}] --> 691 with parallel: 692 all_candidate_params = [] 693 all_out = [] C:\ProgramData\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in __enter__(self) 660 def __enter__(self): 661 self._managed_backend = True --> 662 self._initialize_backend() 663 return self 664 C:\ProgramData\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py in _initialize_backend(self) 671 try: 672 n_jobs = self._backend.configure(n_jobs=self.n_jobs, parallel=self, --> 673 **self._backend_args) 674 if self.timeout is not None and not self._backend.supports_timeout: 675 warnings.warn( C:\ProgramData\Anaconda3\lib\site-packages\sklearn\externals\joblib\_parallel_backends.py in configure(self, n_jobs, parallel, prefer, require, idle_worker_timeout, **memmappingexecutor_args) 474 n_jobs, timeout=idle_worker_timeout, 475 initializer=self.limit_clib_threads, --> 476 **memmappingexecutor_args) 477 self.parallel = parallel 478 return n_jobs C:\ProgramData\Anaconda3\lib\site-packages\sklearn\externals\joblib\executor.py in get_memmapping_executor(n_jobs, timeout, initializer, initargs, **backend_args) 29 id_executor = random.randint(0, int(1e10)) 30 job_reducers, result_reducers, temp_folder = get_memmapping_reducers( ---> 31 id_executor, **backend_args) 32 _executor = get_reusable_executor(n_jobs, job_reducers=job_reducers, 33 result_reducers=result_reducers, C:\ProgramData\Anaconda3\lib\site-packages\sklearn\externals\joblib\_memmapping_reducer.py in get_memmapping_reducers(pool_id, forward_reducers, backward_reducers, temp_folder, max_nbytes, mmap_mode, verbose, prewarm, **kwargs) 383 os.getpid(), pool_id) 384 pool_folder, use_shared_mem = _get_temp_dir(pool_folder_name, --> 385 temp_folder) 386 387 # Register the garbage collector at program exit in case caller forgets C:\ProgramData\Anaconda3\lib\site-packages\sklearn\externals\joblib\_memmapping_reducer.py in _get_temp_dir(pool_folder_name, temp_folder) 156 if os.path.exists(SYSTEM_SHARED_MEM_FS): 157 try: --> 158 shm_stats = os.statvfs(SYSTEM_SHARED_MEM_FS) 159 available_nbytes = shm_stats.f_bsize * shm_stats.f_bavail 160 if available_nbytes > SYSTEM_SHARED_MEM_FS_MIN_SIZE: AttributeError: module 'os' has no attribute 'statvfs'
というのが最後の行のr1.fitに出ます.
該当のソースコード
%matplotlib inline import schedule import time from time import sleep from light_progress.commandline import ProgressBar from sshtunnel import SSHTunnelForwarder import MySQLdb import pandas as pd import numpy as np from sklearn.svm import SVC from sklearn.metrics import r2_score from sklearn.ensemble import RandomForestRegressor from sklearn.ensemble import ExtraTreesRegressor import mglearn from sklearn.model_selection import train_test_split, GridSearchCV from sklearn import linear_model import datetime def j(): j = 0 def k(): k = 0 server = SSHTunnelForwarder( ('xxx', xx), ssh_username="xxx", ssh_password="xxx", remote_bind_address=('127.0.0.1', 3306) ) server.start() cnn = MySQLdb.connect(host='127.0.0.1', port = server.local_bind_port, db='xxx', user='root', passwd='xxx', charset='utf8') sql = 'SELECT * FROM xxx ORDER BY xxx DESC LIMIT 30'; sql10 = 'SELECT * FROM xxx'; try: with cnn.cursor() as cursor: cursor.execute(sql) cursor.execute(sql10) cnn.commit() except: pass first = 5000 abc = 1 efg = 31 i = np.array([range(abc,efg,1)]) I = np.array(range(abc,efg,1)) x16 = first-0.3876*i select_sql1 = 'select measured_value_13 from t_trend2 ORDER BY occur_date DESC LIMIT 30'; select_sql2 = 'select measured_value_14 from t_trend2 ORDER BY occur_date DESC LIMIT 30'; select_sql3 = 'select measured_value_27 from t_trend2 ORDER BY occur_date DESC LIMIT 30'; select_sql4 = 'select measured_value_39 from t_trend2 ORDER BY occur_date DESC LIMIT 30'; try: with cnn.cursor() as cursor: cursor.execute(select_sql1) x25 = cursor.fetchmany(30) cursor.execute(select_sql2) x26 = cursor.fetchmany(30) cursor.execute(select_sql3) x18 = cursor.fetchmany(30) cursor.execute(select_sql4) x100 = cursor.fetchmany(30) cnn.commit() except: pass x25= np.array([x25]) x26= np.array([x26]) x18= np.array([x18]) x100= np.array(x100) x13=x25 - x26 XX1=I XX = np.array([[x13],[x18],[XX1]]) Y = x16 X = XX.T X_train, X_test, Y_train, Y_test = train_test_split(X,Y,train_size = 0.7) search_params = { 'n_estimators' : [5, 10, 20, 30, 50, 100, 300, 400, 500,600,1000], 'max_features' : [0.1], 'random_state' : [2525], 'n_jobs' : [2], 'min_samples_split' : [3, 5, 10, 15, 20, 25, 30, 40, 50, 100], 'max_depth' : [3, 5, 10, 15, 20, 25, 30, 40, 50, 100,1000,1500,10000] } r1 = GridSearchCV( RandomForestRegressor(), search_params, cv = 2, n_jobs = 2, verbose=True ) x_tra = np.reshape(X_train, (-1,3)) x_tes = np.reshape(X_test, (-1,3)) r1.fit(x_tra, Y_train)
試したこと
windowsに対応してないことは分かったが何が対応してないかわからない
補足情報(FW/ツールのバージョンなど)
個人情報は伏せてます.
回答2件
あなたの回答
tips
プレビュー