import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2 . imread ( 'messi5.jpg' , 0 ) f = np . fft . fft2 ( img ) fshift = np . fft . fftshift ( f ) magnitude_spectrum = 20 * np . log ( np . abs ( fshift )) plt . subplot ( 121 ), plt . imshow ( img , cmap = 'gray' ) plt . title ( 'Input Image' ), plt . xticks ([]), plt . yticks ([]) plt . subplot ( 122 ), plt . imshow ( magnitude_spectrum , cmap = 'gray' ) plt . title ( 'Magnitude Spectrum' ), plt . xticks ([]), plt . yticks ([]) plt . show () rows , cols = img . shape crow , ccol = rows / 2 , cols / 2 fshift [ crow - 30 : crow + 30 , ccol - 30 : ccol + 30 ] = 0 f_ishift = np . fft . ifftshift ( fshift ) img_back = np . fft . ifft2 ( f_ishift ) img_back = np . abs ( img_back ) plt . subplot ( 131 ), plt . imshow ( img , cmap = 'gray' ) plt . title ( 'Input Image' ), plt . xticks ([]), ...
ROC curve source:
답글삭제X, y = shuffle(X, y, random_state=0)
clasifier = linear_model.LogisticRegression(class_weight = "balanced")
clasifier.fit(X,y)
fig, ax1 = plt.subplots(figsize=(12, 8))
mean_tpr = 0.0
mean_fpr = linspace(0, 1, 100)
skf = StratifiedKFold(n_splits=n_folds, shuffle=True, random_state=999)
for i, (train_index, test_index) in enumerate(skf.split(X,y)):
# calculate the probability of each class assuming it to be positive
probas_ = classifier.fit(X[train_index], y[train_index]).predict_proba(X[test_index])
# Compute ROC curve and area under the curve
fpr, tpr, thresholds = roc_curve(y[test_index], probas_[:, 1], pos_label=1)
mean_tpr += interp(mean_fpr, fpr, tpr)
mean_tpr[0] = 0.0
roc_auc = auc(fpr, tpr)
plt.plot(fpr, tpr, lw=1, label='ROC fold %d (area = %0.2f)' % (i+1, roc_auc))
plt.plot([0, 1], [0, 1], '--', color=(0.6, 0.6, 0.6), label='Random', lw=2)
mean_tpr /= n_folds
mean_tpr[-1] = 1.0
mean_auc = auc(mean_fpr, mean_tpr)
plt.plot(mean_fpr, mean_tpr, 'k--',
label='Mean ROC (area = %0.2f)' % mean_auc, lw=3)
plt.xlim([-0.05, 1.05])
plt.ylim([-0.05, 1.05])
plt.xlabel('False Positive Rate (1- specificity)', fontsize=18)
plt.ylabel('True Positive Rate (sensitivity)', fontsize=18)
ip address to integer
답글삭제def IP2Int(ip):
o = map(int, ip.split('.'))
res = (16777216 * o[0]) + (65536 * o[1]) + (256 * o[2]) + o[3]
return res
def Int2IP(ipnum):
o1 = int(ipnum / 16777216) % 256
o2 = int(ipnum / 65536) % 256
o3 = int(ipnum / 256) % 256
o4 = int(ipnum) % 256
return '%(o1)s.%(o2)s.%(o3)s.%(o4)s' % locals()
# Example
print('192.168.0.1 -> %s' % IP2Int('192.168.0.1'))
print('3232235521 -> %s' % Int2IP(3232235521))
python control for KSP
답글삭제https://mods.curse.com/ksp-mods/kerbal/220219-krpc-control-the-game-using-c-c-java-lua-python
https://www.youtube.com/watch?v=hXyx_Q9kyjg
삭제with open("test.txt", "a") as myfile:
답글삭제myfile.write("appended text")
파일에 어팬드 하기