Cannot import module after successfully installing with pip
I'm not an expert, but I think that the package is not configured correctly.
To reproduce:
pip install bartpy
python
>>> import bartpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bartpy'
Note that this works (hence my thought that the package configuration is the problem)
git clone https://github.com/JakeColtman/bartpy ~/bin/bartpy
python
>>> import sys
>>> sys.path.append("<home>/bin/bartpy")
>>> import bartpy
Thanks for raising this issue and sorry for the slow reply, I took a break from working on this over Christmas and it kinda expanded out :)
I just recreated the issue and I'll have a look into configuring it properly.
FYI, I have the exact same problem here.
It was indeed a config issue - should work now :)

Fair warning - it's still quite experimental, so not everything is guaranteed to work. I'd recommend https://cran.r-project.org/web/packages/bartMachine/bartMachine.pdf if you're doing anything serious
Hi Jake
Thanks for creating this - it looks superb. I am trying to run the sklearn API example from the readme, and still failing.
I first got a problem about missing samplers, which disappeared after reinstalling from github (had to add the #egg=bartpy). However, now I get TypeError: Categorical is not ordered for operation min you can use .as_ordered() to change the Categorical to an ordered one . I'll leave the full description here.
$ pip install git+https://github.com/JakeColtman/bartpy.git#egg=bartpy
from bartpy.sklearnmodel import SklearnModel
model = SklearnModel() # Use default parameters
model.fit(X, y) # Fit the model
predictions = model.predict() # Make predictions on the train set
out_of_sample_predictions = model.predict(X_test) # Make predictions on new data
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-16-e5c59b158acd> in <module>
1 from bartpy.sklearnmodel import SklearnModel
2 model = SklearnModel() # Use default parameters
----> 3 model.fit(X, y) # Fit the model
4 predictions = model.predict() # Make predictions on the train set
5 out_of_sample_predictions = model.predict(X_test) # Make predictions on new data
~/anaconda3/lib/python3.7/site-packages/bartpy/sklearnmodel.py in fit(self, X, y)
138 self with trained parameter values
139 """
--> 140 self.model = self._construct_model(X, y)
141 self.extract = Parallel(n_jobs=self.n_jobs)(self.f_delayed_chains(X, y))
142 self.combined_chains = self._combine_chains(self.extract)
~/anaconda3/lib/python3.7/site-packages/bartpy/sklearnmodel.py in _construct_model(self, X, y)
164 if len(X) == 0 or X.shape[1] == 0:
165 raise ValueError("Empty covariate matrix passed")
--> 166 self.data = self._convert_covariates_to_data(X, y)
167 self.sigma = Sigma(self.sigma_a, self.sigma_b, self.data.y.normalizing_scale)
168 self.model = Model(self.data,
~/anaconda3/lib/python3.7/site-packages/bartpy/sklearnmodel.py in _convert_covariates_to_data(X, y)
159 X: pd.DataFrame = X
160 X = X.values
--> 161 return Data(deepcopy(X), deepcopy(y), normalize=True)
162
163 def _construct_model(self, X: np.ndarray, y: np.ndarray) -> Model:
~/anaconda3/lib/python3.7/site-packages/bartpy/data.py in __init__(self, X, y, normalize, cache, unique_columns)
58 return Data(X, y, normalize=normalize)
59
---> 60
61 class CovariateMatrix(object):
62
~/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in stat_func(self, axis, skipna, level, numeric_only, **kwargs)
10944 skipna=skipna)
10945 return self._reduce(f, name, axis=axis, skipna=skipna,
> 10946 numeric_only=numeric_only)
10947
10948 return set_function_name(stat_func, name, cls)
~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in _reduce(self, op, name, axis, skipna, numeric_only, filter_type, **kwds)
3613 # dispatch to ExtensionArray interface
3614 if isinstance(delegate, ExtensionArray):
-> 3615 return delegate._reduce(name, skipna=skipna, **kwds)
3616 elif is_datetime64_dtype(delegate):
3617 # use DatetimeIndex implementation to handle skipna correctly
~/anaconda3/lib/python3.7/site-packages/pandas/core/arrays/categorical.py in _reduce(self, name, axis, skipna, **kwargs)
2179 msg = 'Categorical cannot perform the operation {op}'
2180 raise TypeError(msg.format(op=name))
-> 2181 return func(**kwargs)
2182
2183 def min(self, numeric_only=None, **kwargs):
~/anaconda3/lib/python3.7/site-packages/pandas/core/arrays/categorical.py in min(self, numeric_only, **kwargs)
2196 min : the minimum of this `Categorical`
2197 """
-> 2198 self.check_for_ordered('min')
2199 if numeric_only:
2200 good = self._codes != -1
~/anaconda3/lib/python3.7/site-packages/pandas/core/arrays/categorical.py in check_for_ordered(self, op)
1517 raise TypeError("Categorical is not ordered for operation {op}\n"
1518 "you can use .as_ordered() to change the "
-> 1519 "Categorical to an ordered one\n".format(op=op))
1520
1521 def _values_for_argsort(self):
TypeError: Categorical is not ordered for operation min
you can use .as_ordered() to change the Categorical to an ordered one