7 import matplotlib.pyplot
as plt
8 from sklearn
import linear_model, datasets
10 if __name__ ==
"__main__":
11 csv_files = sys.argv[1:]
15 for csv_file
in csv_files:
16 with open(csv_file)
as f:
17 reader = csv.reader(f)
18 (true_depths, observed_depths) = zip(*[(float(row[0]), float(row[1]))
for row
in reader])
19 errs = [a - b
for (a, b)
in zip(true_depths, observed_depths)]
20 true_mean = np.mean(true_depths)
21 observed_mean = np.mean(observed_depths)
22 err_mean = np.mean(errs, axis=0)
23 err_stddev = np.std(errs, axis=0)
25 ys.append(observed_mean)
30 model_ransac = linear_model.RANSACRegressor(linear_model.LinearRegression(), min_samples=2,
31 residual_threshold=0.1)
32 X = np.array(xs).reshape((len(xs), 1))
34 model_ransac.fit(X, Y)
35 line_y_ransac = model_ransac.predict(X)
36 plt.plot(X, line_y_ransac,
"r--",
37 label=
"{0} x + {1}".format(model_ransac.estimator_.coef_[0][0],
38 model_ransac.estimator_.intercept_[0]))
39 print(
"{0} x + {1}".format(model_ransac.estimator_.coef_[0][0],
40 model_ransac.estimator_.intercept_[0]))
42 plt.xlabel(
"Distance [m]")
43 plt.ylabel(
"Standard Deviation [m]")