Форум сайта python.su
import pandas as pd import xgboost as xgb from sklearn.metrics import confusion_matrix, mean_squared_error from sklearn.metrics import mean_absolute_error,mean_squared_error,median_absolute_error df = pd.read_csv('zab_work2.csv',";",header=None) X_train = df.drop(17,axis=1) Y_train = df[17] T_train_xgb = xgb.DMatrix(X_train, Y_train) params = {"objective": "reg:linear", "booster":"gblinear"} gbm = xgb.train(dtrain=T_train_xgb,params=params) test_data = pd.read_csv('new_work2.csv',";",header=None) print(test_data) X_test = test_data.drop(17,axis=1) Y_test = test_data[17] Y_pred = gbm.predict(xgb.DMatrix(X_test)) test_erorr = mean_squared_error(Y_test,Y_pred); print("Accuracy: %.2f%%" % (test_erorr * 100.0)) accuracy = mean_absolute_error(Y_test,Y_pred) print("Accuracy: %.2f%%" % (accuracy * 100.0)) accuracy2 = median_absolute_error(Y_test, Y_pred) print("Accuracy: %.2f%%" % (accuracy2 * 100.0))
import numpy import sklearn import xgboost as xgb from sklearn.metrics import confusion_matrix, mean_squared_error dataset = numpy.genfromtxt('zab_work2.csv', delimiter=";") dataset2 = numpy.genfromtxt('new_work2.csv', delimiter=";") # split data into X and y X = dataset[:,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]] Y = dataset[:,[17]] T_train_xgb = xgb.DMatrix(X, Y) x_2 = dataset2[:,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]] y_2 = dataset2[:,[17]] params = {"objective": "reg:linear", "booster":"gblinear"} gbm = xgb.train(dtrain=T_train_xgb,params=params) Y_pred = gbm.predict(xgb.DMatrix(x_2)) test_erorr = mean_squared_error(y_2,Y_pred); print("Accuracy: %.2f%%" % (test_erorr * 100.0)) accuracy = mean_absolute_error(y_2,Y_pred) print("Accuracy: %.2f%%" % (accuracy * 100.0)) accuracy2 = median_absolute_error(y_2,Y_pred) print("Accuracy: %.2f%%" % (accuracy2 * 100.0))
GNU nano 2.2.6 Файл: robotina.py """ A simple Telegram bot to get photos from a camera """ import cv2 import telepot import time TOKEN = "*****:********" PHOTO = 'test.png' CAM_PORT = 0 bot = telepot.Bot(TOKEN) #def help_cmd(bot, update): # text = ('/start command activates a motion capture mode.\n' # '/stop command does the opposite.\n' # '/shot is used to get an actual snapshot.') # bot.sendMessage(chat_id=update.message.chat_id, text=text) #$config = { # cv2.CV_CAP_PROP_BRIGHTNESS: 50, # camera.CV_CAP_PROP_CONTRAST: 50, # camera.CV_CAP_PROP_SATURATION: 50, #} #for param, value in config.iteritems(): # cv2.SetCaptureProperty(capture, param, value) # # def take_photo(): camera = cv2.VideoCapture(CAM_PORT) # camera.set(16,90) # Wait some time to get ligth in the camera time.sleep(1) rc, image = camera.read() if rc: cv2.imwrite(PHOTO, image) del(camera) return rc def send_photo(chat_id, photo_path, caption): with open(photo_path, 'rb') as photo: bot.sendPhoto(chat_id, photo, caption) def handle_messages(msg): """ The entry point to the message reception """ content_type, chat_type, chat_id = telepot.glance(msg) print(content_type, chat_type, chat_id) if content_type == 'text': text = msg['text'] if text == '/getphoto': if take_photo(): send_photo(chat_id, PHOTO, 'This is a test caption') else: bot.SendMessage(chat_id, 'A problem occurred taking the photo') else: #error_msg = "No se de que me hablas!" error_msg = "I don't know what are you talking about!" bot.sendMessage(chat_id, error_msg) bot.message_loop(handle_messages) print('Listen messages...') while True: time.sleep(5)
No WSGI daemon process called ‘chat’ has been configured: /var/www/chat/chat/wsgi.pyКонфигурация хоста
12 DocumentRoot /var/www/chatВ какую сторону двигаться чтобы исправить ошибку?
13
14 WSGIDaemonProcess sampleapp python-path=/var/www/chat:/root/django_chat/lib/python3.4/site-packages
15 WSGIProcessGroup chat
16 WSGIScriptAlias / /var/www/chat/chat/wsgi.py
17 # Available loglevels: trace8, …, trace1, debug, info, notice, warn,
18 # error, crit, alert, emerg.
19 # It is also possible to configure the loglevel for particular
20 # modules, e.g.
21 #LogLevel info ssl:warn
22
23 ErrorLog ${APACHE_LOG_DIR}/error.log
24 CustomLog ${APACHE_LOG_DIR}/access.log combined
from selenium import webdriver driver = webdriver.PhantomJS(executable_path='/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs') driver.set_window_size(1120, 550) driver.get("https://duckduckgo.com/") driver.find_element_by_id('search_form_input_homepage').send_keys("realpython") driver.find_element_by_id("search_button_homepage").click() print driver.current_url driver.quit()
File "seltest.py", line 2, in <module> driver = webdriver.PhantomJS(executable_path='/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs') File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__ self.service.start() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 86, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable may have wrong permissions.
Пробовал chmod +x /usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs
Доброго времени суток! Вопрос такой: наконец то для себя открыл такую вещь как ckeditor(очень удобная штука) но не понятно его работа! Есть сайт у которого есть страничка статьи т.е. если посмотреть на view выглядит это примерно так:
def list_article(request): article = Article.objects.all() return render(request, '../templates/article/list_article.html', {'article': article})
def article_detail(request, pk): article = get_object_or_404(Article, pk=pk) return render(request, '../templates/article/article_details.html', {'article': article})
код html: {% for art in article %} {{ art.title }} Дата публикации: {{ art.created }}
{{ art.text_post| truncatechars_html:350}} {% endfor %} самая незадача в том, что когда открывается страничка с html то там прорисовывается следующая картина:
О тренажарах Дата публикации: 23 апреля 2017 г. 16:25
Идейные соображения высшего порядка, а также новая модель организационной деятельности в значительной степени обуславливает создание форм развития. Не следует, однако забывать, что начало повседневной работы по формированию позиции обеспечивает широкому кругу (специалистов) участие в формировании существенных финансовых и административных услови...
т.е. тег
появляется пробовал сделать safe но ни к чему хорошему не привело получилось что изменился шрифт и если сделать больше символов то фото из этой статьи отображается на страничке(чего не надо) как можно это исправить подскажите пожалуйста?