Skip to content

Instantly share code, notes, and snippets.

View Younes-Charfaoui's full-sized avatar
🎨
Focusing

Younes Charfaoui Younes-Charfaoui

🎨
Focusing
View GitHub Profile
# import the libraries
from sklearn.neighbors import LocalOutlierFactor
import pandas as pd
# read your data
data = pd.read_csv("yourData.csv")
# create the isolation forest
outlier_detection = LocalOutlierFactor()
# import the libraries
from sklearn.cluster import DBSCAN
import pandas as pd
# read your data
data = pd.read_csv("yourData.csv")
# create the isolation forest
outlier_detection = DBSCAN(eps = 0.2, metric=”euclidean”, min_samples = 5, n_jobs = -1)
# import the libraries
from sklearn.ensemble import IsolationForest
import pandas as pd
# read your data
data = pd.read_csv("yourData.csv")
# create the isolation forest
outlier_detection = IsolationForest()
# import the KNN imputer
from sklearn.impute import KNNImputer
# create the imputer with specefied number of neighbors (the K)
imputer = KNNImputer(n_neighbors=3)
# fit the imputer to the train set
imputer.fit(train)
# transform the data
# This estimator is still experimental, we need to explicitly require this experimental feature.
from sklearn.experimental import enable_iterative_imputer
from sklearn.impute import IterativeImputer
# create the imputer
imputer = IterativeImputer(random_state=22)
# fit the imputer to the train set
imputer.fit(train)
# import the pandas and James Stein encoders libraries.
import pandas as pd
from category_encoders import JamesSteinEncoder
# get you data.
data = pd.read_csv("yourData.csv")
# create the encoder.
encoder = JamesSteinEncoder(return_df=True)
# import the pandas and Leave One Out encoders libraries.
import pandas as pd
from category_encoders import LeaveOneOutEncoder
# get you data.
data = pd.read_csv("yourData.csv")
# create the encoder.
encoder = LeaveOneOutEncoder(return_df=True)
# import the pandas and catboost encoders libraries.
import pandas as pd
from category_encoders import CatBoostEncoder
# get you data.
data = pd.read_csv("yourData.csv")
# create the encoder.
encoder = CatBoostEncoder(return_df=True)
private fun stopActivityRecogntion() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver)
ActivityRecognition.getClient(this)
.removeActivityTransitionUpdates(pendingIntent)
.addOnSuccessListener {
Log.d("ActivityRecognition", "ActivityTransitions successfully unregistered.")
}
.addOnFailureListener { e ->
// creating the pending intent
val intent = Intent(DetectedActivityReceiver.RECEIVER_ACTION)
pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0)
// creating the receiver
receiver = DetectedActivityReceiver()
// registring the receiver
LocalBroadcastManager.getInstance(this).registerReceiver(
receiver, IntentFilter(DetectedActivityReceiverRECEIVER_ACTION)