I am trying to apply the ACE algorithm outlined here: https://pypi.python.org/pypi/ace/0.3
Here is the code from the sample page, which works:
from ace.samples import wang04
x, y = wang04.build_sample_ace_problem_wang04(N=200)
from ace import model
myace = model.Model()
myace.build_model_from_xy(x, y)
Here is the code that I am trying to run:
import pandas as pd
import numpy as np
from ace import model
filename = 'G_perm.txt'
well = pd.read_csv(filename, sep="\s+", error_bad_lines=False)
well.columns = ["k", "por"]
x = np.zeros(len(well))
y = np.zeros(len(well))
for i in range(len(well)):
x[i] = well.k[i]
y[i] = well.por[i]
myace = model.Model()
myace.build_model_from_xy(x, y)
Here is a sample of the txt file, with 162 lines:
k por
306.0 26.3
61.0 25.4
1059.0 30.9
1120.0 30.0
540.0 29.8
272.0 27.0
430.0 28.3
84.0 25.6
788.0 30.2
490.0 28.7
541.0 28.8
When I try running the code, I get list index out of range
Has anyone implemented ACE successfully with Pandas and Numpy?
The x_values
argument for build_model_from_xy
appears to require an iterator, as if it is iterating through the list of x variables. So, the following replacement for your last line should work:
myace.build_model_from_xy([x], y)
Note that the x from the sample code (wang04.build_sample_ace_problem_wang04(N=200)
) is, in fact, a list of arrays.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With