ppyPatternRecognition

[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.

Table of content

Provided model

How to install

  1. Install python
  2. Install library using pip
    pip install -U ppyPatternRecognition

K-means

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 column
  • last_centroid is the last centroid of the model after fitting

Linear regression

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 itself
  • predict method will return the predicted value

Logistic regression

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 itself
  • predict method will return the predicted value

Simple Naïve Bayes

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 itself
  • fit_gaussian method will return the model itself
  • predict method will return the predicted value
  • predict_gaussian method will return the predicted value