This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Multi-Label classification | |
Typically, a classification task involves predicting a single label. Alternately, | |
it might involve predicting the likelihood across two or more class labels. | |
In these cases, the classes are mutually exclusive, meaning the classification | |
task assumes that the input belongs to one class only. | |
Some classification tasks require predicting more than one class label. | |
This means that class labels or class membership are not mutually exclusive. | |
These tasks are referred to as multiple label classification, or multi-label classification for short. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Bio.Seq import Seq | |
from Bio.SeqRecord import SeqRecord | |
record = SeqRecord( | |
Seq("MKQHKAMIVALIVICITAVVAALVTRKDLCEVHIRTGQTEVAVF"), | |
id="YP_025292.1", | |
name="HokC", | |
description="toxic membrane protein, small", | |
) | |
print(record) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# square of all elements in a vector | |
sapply(1:10, function(i) i ^ 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df <- data.frame( | |
x=rnorm(25), | |
y=rnorm(25), | |
g=rep(factor(LETTERS[1:5]), 5) | |
) | |
X <- split(df, df$g) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple plot example for geom_point | |
data(iris) | |
# where we specify the type of plot with geom_point() | |
# the data to plot with aes | |
IrisPlot <- ggplot(iris, aes(Sepal.Length, Petal.Length, colour=Species))+geom_point() | |
# if we want to change the colour | |
IrisPlot <- ggplot(iris, aes(Sepal.Length, Petal.Length))+geom_point(colour="blue") | |
print(IrisPlot) | |
# Now, let's modify the axes labels and also add title | |
print(IrisPlot + labs(y="Petal length (cm)", x = "Sepal length (cm)")) + ggtitle("Petal and sepal length of iris") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bins numerical data and returns the different counts for each category | |
mport numpy as np | |
a = np.array([22,87,5,43,56,73,55,54,11,20,51,5,79,31,27]) | |
hist,bins = np.histogram(a,bins = [0,20,40,60,80,100]) | |
print(hist) # [3 4 5 2 1] | |
print(bins) # [ 0 20 40 60 80 100] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Excellent for plotting small and really large data points | |
Good article at: | |
https://towardsdev.com/logarithmic-scale-how-to-plot-and-actually-understand-it-c38f00212206 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############### Method 1: | |
# Python3 code to demonstrate | |
# to remove a substring from end of the string | |
# Initialising string | |
ini_string = 'xbzefdgstb' | |
# initializing string | |
sstring = 'stb' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tempfile | |
temp = tempfile.NamedTemporaryFile() | |
try: | |
print 'temp:', temp | |
print 'temp.name:', temp.name | |
finally: | |
# Automatically cleans up the file | |
temp.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# global alignment between 2 sequences | |
from Bio import pairwise2 | |
alignments = pairwise2.align.globalxx("ACCGT", "ACG") # returns a list of alignments | |
# you can format the alignments | |
from Bio.pairwise2 import format_alignment | |
print(format_alignment(*alignments[0])) | |
ACCGT | |
| || | |
A-CG- |