Skip to content

Instantly share code, notes, and snippets.

View seenimohamed's full-sized avatar
🎯
Focusing

Seeni Mohamed seenimohamed

🎯
Focusing
View GitHub Profile
@seenimohamed
seenimohamed / live_timer.py
Created March 31, 2023 07:24
Live timer in python
from datetime import datetime
import time
print("Live timer")
while True :
print('\r', '{} '.format(str(datetime.now()).split(".")[0]), end='', flush=True)
time.sleep(1)

Entropy vs Information gain

In decision tree algorithm, these 2 terms play major role and sometimes harder to grasp what it means. Lets decode.

Entropy - uncertainty/impurity

Let's assume we have 3 classes (namely A,B,C) in our dataset. Entropy (E) = (prob. of randomly selecting an example in class A) +(prob. of randomly selecting an example in class B) + (prob. of randomly selecting an example in class C). i.e, sum of all the probabilities. (total uncertainty of data)

What do we get out of this?

Explainable cluster

Ever wonder, is there a way to explain clustered data?

Machine learning practitioners knows that SHAP is the go-to for any ml model explanation. Have you ever thought how can we use the SHAP to explain clustering data?

Here is the way to do it,

@seenimohamed
seenimohamed / bias_variance_tradeoff.md
Last active April 8, 2022 02:37
Bias Variance tradeoff.

Bias Variance tradeoff.

I have read many articles about this, every time i stumble upon what actual it means intuitively.

So, here is my attempt to explain it in layman terms.

Low bias means you have less error with your training data. In other words, your model almost perfectly aligned with your training data. #overfitting

@seenimohamed
seenimohamed / od_error.log
Last active April 8, 2022 02:34
Object detection error log
(tf-object-detection) ➜ research git:(master) ✗ python model_main_tf2.py \
--pipeline_config_path=training/ssd_efficientdet_d0_512x512_coco17_tpu-8.config \
--model_dir=training \
--alsologtostderr
2021-04-05 15:03:33.281642: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-04-05 15:03:33.282121: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
WARNING:tensorflow:There are non-GPU devices in `tf.distribute.Strategy`, not using nccl allreduce.
W0405 15:03:33.283706 4433821120 cross_device_ops.py:1321] There are non-GPU devices in `tf.distribute.Strategy`, not using nccl allreduce.
INFO:tensorflow:Using MirroredStrategy with devices ('/job:localhost/replica:0/task:0/device:CP
@seenimohamed
seenimohamed / move_rename_all.sh
Created June 12, 2019 07:27
Power of find command in terminal
#!/bin/sh
# Usage : move all mp4 files with removing extension
# Command to run :
# ./move_all_files_with_diff_name.sh <source_folder> <destination_folder>
# Command structure
# find . -name "*.mp4"
# normal find command
@seenimohamed
seenimohamed / url_check.py
Created May 25, 2018 10:48
To check whether a given url is up or not
from six.moves import urllib
import requests
def url_is_alive(url):
"""
Checks that a given URL is reachable.
:param url: A URL
:rtype: bool
"""
request = urllib.request.Request(url)
public static CSVRecord convertToCSVRecord(String query, char delimiter) {
try {
Reader in = new StringReader(query);
CSVParser parser = CSVFormat.newFormat(delimiter).parse(in);
List<CSVRecord> recorder = parser.getRecords();
return recorder.get(0); //returning first element
} catch (IOException e) {
e.printStackTrace();
}
return null;
@seenimohamed
seenimohamed / GetHighestValueFromMap.java
Created January 24, 2018 13:56
get the highest value from map in java8
//to get key for single max value from map
Integer max=mapGroup.entrySet().stream().max(Map.Entry.comparingByValue()).get().getKey();
//to get keys for for getting all equivalent maximums
private List<Integer> testStreamMap(Map<Integer, Long> mapGroup) {
if(mapGroup.isEmpty())
return Collections.emptyList();
long max = mapGroup.values().stream().max(Comparator.naturalOrder()).get();
return mapGroup.entrySet().stream()
.filter(e -> e.getValue() == max)
@seenimohamed
seenimohamed / java8_groupbyValue.java
Last active June 18, 2019 10:17
GroupBy functionalities
private String getPredictedModule(List<Result> result) {
Collector<Result, ?, Map<String, Double>> summarizeByModules =
Collectors.groupingBy(Result::getModule, Collectors.summingDouble(Result::getConfidence));
Map<String, Double> finalMap = new LinkedHashMap<>();
result.stream().collect(summarizeByModules)
.entrySet().stream().sorted(Map.Entry.<String, Double>comparingByValue()
.reversed()).forEachOrdered(e -> finalMap.put(e.getKey(), e.getValue()));
return finalMap.keySet().stream().findFirst().get();
}