[Should read this in github]
This is a library about AI model. All the model ideas are come from inclass lecture.
You can see the class github here which is created by Aj. Ekapol.
- Install python
- Install library using
pip
pip install -U ppyPatternRecognition
code here
example
from ppyPatternRecognition import Kmeans
df = pd.read_csv(...)
k_means = Kmeans()
# fit the model
labeled_df = k_means.fit(df, k=3)
# print the label
print(labeled_df['label'])
# get the last centroid
print(k_means.last_centroid)
fit
method will return the dataframe with label columnlast_centroid
is the last centroid of the model after fitting
code here
example
from ppyPatternRecognition import LinearRegression
df = pd.read_csv(...)
X_train, y_train = ...
linear_regression = LinearRegression()
# fit the model
linear_regression.fit(X_train, y_train, epochs=1000, lr=0.01)
# predict
y_pred = linear_regression.predict(X_test)
fit
method will return the model itselfpredict
method will return the predicted value
code here
example
from ppyPatternRecognition import LogisticRegression
df = pd.read_csv(...)
X_train, y_train = ...
logistic_regression = LogisticRegression()
# fit the model
logistic_regression.fit(X_train, y_train, epochs=1000, lr=0.01)
# predict
y_pred = logistic_regression.predict(X_test)
fit
method will return the model itselfpredict
method will return the predicted value
code here
example
from ppyPatternRecognition import SimpleBayesClassifier
df = pd.read_csv(...)
X_train, y_train = ...
simple_naive_bayes = SimpleBayesClassifier()
# fit the model
simple_naive_bayes.fit(X_train, y_train)
# predict
y_pred = simple_naive_bayes.predict(X_test)
fit
method will return the model itselffit_gaussian
method will return the model itselfpredict
method will return the predicted valuepredict_gaussian
method will return the predicted value