def add_model_fuz(self, filename, modelname): """ called from: fileOpen adds a new model from filesystem (.fis) with: in: filename incl. path str modelname str out: name of the new model or None model_new str if model_name is already in dict self.d_fuz then: add a 1 to the name to make it unique """ modelname_new = modelname while(modelname_new in self.d_fuzz): modelname_new += "1" self.fx = Pyfuzzy.read_model(filename, DEBUG=1) #~ for i in range(len(self.fx.inputs)): #~ for li in self.fx.inputs[i]: #~ for j in range(len(li)): #~ print "self.fx.inputs:: ", self.fx.inputs[i][j] li_inp = self.fx.get_inputs() for i in range(len(li_inp)): li_memb = self.get_members_of_input(li_inp[i]) self.d_fuzz[modelname_new] = self.fx return modelname_new # fx only for inside of class worker
def add_model_fuz(self, filename, modelname): """ adds a new model from filesystem (.fis) with: in: filename incl. path str modelname str out: name of the new model or None dataset_new str if dataset_name is already in dict self.d_models_fuz then: add a 1 to the name to make it unique result: add the model in self.d_models_fuz an in TREE """ ds_new = modelname #while(ds_new in self.d_models_fuz): while((ds_new in self.d_models_svm) or (ds_new in self.d_models_fuz)): ds_new += "1" fx = Pyfuzzy.read_model(filename) self.d_models_fuz[ds_new] = fx #print self.d_models_fuz.items() return ds_new
#!/usr/bin/env python # reads a one dimensional fuzzy model and a training data set # to train rules # the result will be stored as fuzzy model import sys sys.path.append('../') import Pyfuzzy as fuzz # adapt this for different tests f1=fuzz.read_model('hab_schreiadler.fis',DEBUG=1) x,y=f1.read_training_data('hab_data.csv', header=1) f1.train_rules(x,y,0.75) # check the influence of different alpha f1.store_model('hab')
#!/usr/bin/env python # reads in a fuzzy model and generates a noisy set of data for # training of it import sys sys.path.append('../') import Pyfuzzy as fuzz import numpy as np # change this for different models f1 = fuzz.read_model('nahr_schreiadler.fis', DEBUG=0) datasize = 500 x1min = 0.0 x1max = 1.0 x2min = 0.0 x2max = 300.0 # generate the training data print 'x1,x2,y' for i in range(datasize): x1 = (x1max - x1min) * np.random.rand() + x1min x2 = (x2max - x2min) * np.random.rand() + x2min y = f1.calc2(x1, x2) y = np.random.normal(y, 0.1) # add some noise print x1, x2, y
#!/usr/bin/env python # reads a one dimensional fuzzy model and a training data set # to train rules # the result will be stored as fuzzy model import sys sys.path.append('../') import Pyfuzzy as fuzz # adapt this for different tests f1=fuzz.read_model('nahr_schreiadler.fis',DEBUG=1) x,y=f1.read_training_data('nahr_data.csv', header=1) f1.train_rules(x,y,0.75) # check the influence of different alpha f1.store_model('nahr')
#!/usr/bin/env python # reads a one dimensional fuzzy model and a training data set # to train rules # the result will be stored as fuzzy model import sys sys.path.append('../') import Pyfuzzy as fuzz # adapt this for different tests f1 = fuzz.read_model('hab_schreiadler.fis', DEBUG=1) x, y = f1.read_training_data('hab_data.csv', header=1) f1.train_rules(x, y, 0.75) # check the influence of different alpha f1.store_model('hab')
#!/usr/bin/env python # reads a one dimensional fuzzy model and a training data set # to train rules # the result will be stored as fuzzy model import sys sys.path.append('../') import Pyfuzzy as fuzz # adapt this for different tests f1 = fuzz.read_model('gen_data1.fis', DEBUG=1) x, y = f1.read_training_data('data1.csv', header=1) f1.train_rules(x, y, 0.75) # check the influence of different alpha f1.store_model('data1')
Landscape, Wind, Climate """ import sys import os sys.path.append(os.environ["SAMT2MASTER"] + '/fuzzy/src') import Pyfuzzy as fuzz sys.path.append(os.environ["SAMT2MASTER"] + '/src') import grid as samt2 import time # load fuzzy model # path='/home/kerkow/Aufbau_Fuzzy/Modell/Version3/' # path='/datadisk/pya/culifo_June_2018/culifo_regional/' path = '/datadisk/Mosquito-Modeling/Regional/' f = fuzz.read_model(path + 'LandscapeMosquitoes3.fis') path = '/datadisk/Mosquito-Modeling/Regional/data/' # load the ASCII or HDF-files landscape = samt2.grid() landscape.read_ascii(path + 'Landscape_Version2_MW_7.asc') wind = samt2.grid() wind.read_hdf(path + 'wind100m.hdf', 'wind100m') climate = samt2.grid() climate.read_ascii(path + 'ClimateSuitability_1981_2010_100m.asc') #climate.read_ascii(path+'ClimateModelOutputs_callibrated/ClimateSuitability_2051_2080_100m.asc') # # start the simulation t0 = time.time() modell = f.grid_calc3(landscape, wind, climate) print('calc time:', time.time() - t0)
#!/usr/bin/env python # reads a one dimensional fuzzy model and a training data set # to train rules # the result will be stored as fuzzy model import sys sys.path.append('../') import Pyfuzzy as fuzz # adapt this for different tests f1=fuzz.read_model('gen_data1.fis',DEBUG=1) x,y=f1.read_training_data('data1.csv', header=1) f1.train_rules(x,y,0.75) # check the influence of different alpha f1.store_model('data1')