Skip to content

Commit

Permalink
Sphinx Docstring ml/vertica/decomposition (#771)
Browse files Browse the repository at this point in the history
* Docstring ml/vertica/decomposition

* doc + bug correction

* Update decomposition.py

* added SQL plot

* Update decomposition.py

---------

Co-authored-by: Badr <[email protected]>
  • Loading branch information
mail4umar and oualib authored Oct 25, 2023
1 parent 51ff9d2 commit d323198
Show file tree
Hide file tree
Showing 2 changed files with 551 additions and 7 deletions.
12 changes: 7 additions & 5 deletions verticapy/machine_learning/memmodel/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ def transform_sql(self, X: ArrayLike) -> list[str]:
"of the vector 'mean'."
)
sql = []
for i in range(len(X)):
m, n = self.principal_components_.shape
for i in range(n):
sql_tmp = []
for j in range(len(X)):
for j in range(m):
sql_tmp += [
f"({X[j]} - {self.mean_[j]}) * {self.principal_components_[:, i][j]}"
]
Expand Down Expand Up @@ -232,15 +233,16 @@ def transform_sql(self, X: ArrayLike) -> list[str]:
list
SQL code.
"""
if len(X) != len(self.values_):
if len(X) != len(self.vectors_):
raise ValueError(
"The length of parameter 'X' must be equal to the length "
"of the vector 'values'."
)
sql = []
for i in range(len(X)):
m, n = self.vectors_.shape
for i in range(n):
sql_tmp = []
for j in range(len(X)):
for j in range(m):
sql_tmp += [f"{X[j]} * {self.vectors_[:, i][j]} / {self.values_[i]}"]
sql += [" + ".join(sql_tmp)]
return sql
Loading

0 comments on commit d323198

Please sign in to comment.