def get_lin_reg(x, y): data = Orange.data.Table("newdoc.csv") earth_predictor = earth.EarthLearner(data) tx1, ty1 = data.to_numpy("A/C") # pl.plot(x,y,".r") li = numpy.linspace(min(x), max(x), 20) # predictions = [earth_predictor([s, "?"]) for s in li] # pl.plot(linspace, predictions, "-b") # pl.show() data = Orange.data.Table("dat.tab") earth_predictor = earth.EarthLearner(data) X, Y = data.to_numpy("A/C") # pl.plot(X, Y, ".r") linspace = numpy.linspace(min(X), max(X), 20) predictions = [earth_predictor([s, "?"]) for s in linspace] # pl.plot(linspace, predictions, "-b") # pl.show() f = open("orangetrend.txt", "w+") for i in range(len(linspace)): # print linspace # exit(0) f.write(str(linspace[i]) + "," + str(predictions[i]) + "\n") # f.write(str(predictions[i])+"\n") f.close()
def test_bagged_evimp(self, dataset): from Orange.ensemble.bagging import BaggedLearner bagged_learner = BaggedLearner(earth.EarthLearner(terms=10, degree=2), t=5) bagged_classifier = bagged_learner(dataset) evimp = earth.bagged_evimp(bagged_classifier, used_only=False)
def apply(self): learner = earth.EarthLearner( degree=self.degree, terms=self.terms if self.terms >= 2 else None, penalty=self.penalty, name=self.name) predictor = None basis_matrix = None if self.preprocessor: learner = self.preprocessor.wrapLearner(learner) self.error(0) if self.data is not None: try: predictor = learner(self.data) predictor.name = self.name except Exception, ex: self.error(0, "An error during learning: %r" % ex) if predictor is not None: base_features = predictor.base_features() basis_domain = Orange.data.Domain(base_features, self.data.domain.class_var, self.data.domain.class_vars) basis_domain.add_metas(self.data.domain.get_metas()) basis_matrix = Orange.data.Table(basis_domain, self.data)
def test_multi_target_on_data(self, dataset): self.learner = earth.EarthLearner(degree=2, terms=10) self.predictor = self.multi_target_test(self.learner, dataset) self.assertTrue(bool(self.predictor.multitarget)) s = str(self.predictor) self.assertEqual(s, self.predictor.to_string()) self.assertNotEqual(s, self.predictor.to_string(3, 6))
def apply(self): learner = earth.EarthLearner( degree=self.degree, terms=self.terms if self.terms >= 2 else None, penalty=self.penalty, name=self.name) predictor = None if self.preprocessor: learner = self.preprocessor.wrapLearner(learner) self.error(0) if self.data is not None: try: predictor = learner(self.data) predictor.name = self.name except Exception, ex: self.error(0, "An error during learning: %r" % ex)
os.chdir("C:/Documents and Settings/amcelhinney/My Documents/GitHub/MCS507ProjectTwo/data/") # Remember to add the "class" keyword to the third line, under the target variable. See here: # http://orange.biolab.si/doc/tutorial/load-data/ data = orange.ExampleTable("painted_data_wo_outlier") print data.domain.attributes print data[:4] X, Y = data.to_numpy("A/C") pl.plot(X, Y, ".r") pl.title('Example Data Set') pl.show() earth_predictor = earth.EarthLearner(data) print earth_predictor linspace = numpy.linspace(min(X), max(X), 20) predictions = [earth_predictor([s, "?"]) for s in linspace] pl.plot(X, Y, ".r") pl.plot(linspace, predictions, "-b") pl.title('Example Data Set with Line Fit by MARS') pl.show() x=[]; y=[] for i in range(len(X)): #print i x.append(float(X[i])) y.append(float(Y[i]))
def setUp(self): self.learner = earth.EarthLearner(degree=2, terms=10)
os.chdir( "C:/Documents and Settings/amcelhinney/My Documents/GitHub/MCS507ProjectTwo/data/" ) os.getcwd() # Bring in the data using the C4.5 format, which brings in the .data file and then the .names file data = orange.ExampleTable("auto-mpg") print data.domain.attributes # Divide data into training and validation data sets index = Orange.data.sample.SubsetIndices2(p0=0.70) ind = index(data) data_training = data.select(ind, 0) data_validation = data.select(ind, 1) earth_predictor = earth.EarthLearner(data_training) print earth_predictor estimated = earth_predictor.predict(list(data_validation)) dl = list(data_validation) # Predict all the data estimated = [] for i in range(0, len(dl)): t = earth_predictor.predict(dl[i]) estimated.append(t[0]) X, Y = data.to_numpy("A/C") for i in range(0, len(names)):