Skip to content

Instantly share code, notes, and snippets.

View fernandojunior's full-sized avatar

Fernando Felix fernandojunior

  • Brazil
View GitHub Profile
@fernandojunior
fernandojunior / gist:9f4bf868f7f393e30578fd6e8109893c
Last active September 10, 2024 15:11
Simple LangChain translator code to abstract LLM models
! pip install langchain
! pip install langchain-openai
! pip install langchain-google-genai
! pip install langchain-community llama-cpp-python
! wget https://huggingface.co/NousResearch/Hermes-2-Pro-Llama-3-8B-GGUF/resolve/main/Hermes-2-Pro-Llama-3-8B-Q8_0.gguf
from langchain_openai import ChatOpenAI
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_community.chat_models import ChatLlamaCpp
@fernandojunior
fernandojunior / gist:4cd5055fe91a69d80b35108e1b04af53
Created September 8, 2022 05:58
Use OOP and functional programming to create data pipelines with sklearn, classes and pure functions
from typing import Any, Callable
from dataclasses import dataclass
import numpy as np
import pandas as pd
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import FunctionTransformer
@fernandojunior
fernandojunior / gist:1a8868bc651d6d45ffa6fed0c1b9ffb1
Last active August 1, 2022 18:56
Baby steps to use flake8 and black

I suggest you to use some lint tools like flake8 to find some PEP8 warnings. Optionally, you can use flake8-black to automatically find and fix them. This way, you will have a more consistent and unified code style.

  • Add flake8 and flake8-black (optional) as a dependency to requirements.txt and test_requirements.txt
  • Create a .flake8 config file in project's root folder ROOT_FOLDER/.flake8 to setup some global flake8 configurations to customize or ignore some warnings/violations (see more here and here).

Example:

# .flake8 file
[flake8]
ignore = D203, E501, W504, W503, E731, E712
@fernandojunior
fernandojunior / publickey-git-error.markdown
Created May 16, 2021 18:26 — forked from adamjohnson/publickey-git-error.markdown
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "[email protected]". Th
https://www.kaggle.com/dansbecker/data-leakage
https://towardsdatascience.com/data-leakage-in-machine-learning-10bdd3eec742
https://towardsdatascience.com/preventing-data-leakage-in-your-machine-learning-model-9ae54b3cd1fb
https://stats.stackexchange.com/questions/90711/can-independent-variables-with-low-correlation-with-dependent-variable-be-signif
https://medium.com/@rafaelpierre/data-leakage-part-i-think-you-have-a-great-machine-learning-model-think-again-ad44921fbf34
PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Fare Cabin Embarked
1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S
2 1 1 Cumings, Mrs. John Bradley (Florence Briggs Thayer) female 38 1 0 PC 17599 71.2833 C85 C
3 1 3 Heikkinen, Miss. Laina female 26 0 0 STON/O2. 3101282 7.925 S
4 1 1 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35 1 0 113803 53.1 C123 S
5 0 3 Allen, Mr. William Henry male 35 0 0 373450 8.05 S
6 0 3 Moran, Mr. James male 0 0 330877 8.4583 Q
7 0 1 McCarthy, Mr. Timothy J male 54 0 0 17463 51.8625 E46 S
8 0 3 Palsson, Master. Gosta Leonard male 2 3 1 349909 21.075 S
9 1 3 Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg) female 27 0 2 347742 11.1333 S
@fernandojunior
fernandojunior / slack_webhook_post.py
Created July 3, 2020 17:51 — forked from devStepsize/slack_webhook_post.py
POST a JSON payload to a Slack Incoming Webhook using Python requests
'''
This is an example of how to send data to Slack webhooks in Python with the
requests module.
Detailed documentation of Slack Incoming Webhooks:
https://api.slack.com/incoming-webhooks
'''
import json
import requests