Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lepy committed Nov 22, 2018
1 parent 9066f07 commit 0c8c313
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion phuzzy/approx/doe.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def predict(self, name=None):
self.results_prediction = pd.DataFrame({"res": y, "alpha": self.doe_prediction.samples.alpha})
print(1, self.results_training.head())
print(2, self.results_prediction.head())
df_res = pd.concat([self.results_training, self.results_prediction[["res", "alpha"]]])
df_res = pd.concat([self.results_training, self.results_prediction[["res", "alpha"]]], sort=False)

if name is None:
name = "z"
Expand Down
5 changes: 0 additions & 5 deletions phuzzy/data/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,8 @@ def bootstrapping(data, df_boot, show=False):

return fig, axs

<<<<<<< HEAD
def plot_hist(x, ax=None, bins=None, normed=False, color=None, **kwargs):
x = x[~np.isnan(x)]
=======
def plot_hist(x, ax=None, bins=None, normed=True, **kwargs):

>>>>>>> aa69c3564895524ef928f88a5162c36cd9cf871f
if bins is None:
bins = 'auto'
bins, edges = np.histogram(x, bins=bins)
Expand Down
14 changes: 13 additions & 1 deletion phuzzy/shapes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,14 +843,26 @@ def defuzzification_p50(self):
"""defuzzification mean my means of ppf(0.5)"""
return self.ppf(.5)

def defuzzification_centroid(self):
def defuzzification_centroid2(self):
"""defuzzification center of gravity"""
# x = self.df[["l", "r"]].values.flatten()
x = np.linspace(self.min(), self.max(), 100001)
m = self.alpha(x)
cg = np.sum(x * m) / np.sum(m)
return cg

def defuzzification_centroid(self):
"""defuzzification center of gravity"""
df = pd.concat([self.df[["l", "alpha"]].rename(columns={"l":"x"}), self.df[["alpha", "r"]].rename(columns={"r":"x"})]).sort_values(by=["x", "alpha"])
df = df.drop_duplicates(subset="x", keep="last")
d = pd.DataFrame()
d["alpha"] = df.alpha.rolling(2).mean()
d["dx"] = (df.x.rolling(2).max() - df.x.rolling(2).min())
d["x"] = df.x.rolling(2).mean()
d["A"] = d.dx * d.alpha
d["Ax"] = d.x * d.A
return d.Ax.sum()/d.A.sum()

def defuzzification(self, method='centroid'):

# self.zmax_values = np.flip(self.zmax_values, 0)
Expand Down

0 comments on commit 0c8c313

Please sign in to comment.