Skip to content

Instantly share code, notes, and snippets.

print('start')
import pandas as pd
from sklearn.linear_model import LogisticRegression #导入线性回归库
from sklearn.feature_extraction.text import CountVectorizer #导入特征提取库
#读取文件,并且删除无关东西
df_train = pd.read_csv('/Users/apple/Documents/ST/python/competition/DataCastel/text_intelligence/new_data/train_set.csv')
df_test = pd.read_csv('/Users/apple/Documents/ST/python/competition/DataCastel/text_intelligence/new_data/test_set.csv')
df_train.drop(columns =['article', 'id'], inplace = True ) #问题1: 为什么要删除这两个列,id列没有意义,不需要用article,直接删除
df_test.drop(columns =['article'], inplace = True )
print('start')
import pandas as pd
from sklearn.linear_model import LogisticRegression #导入线性回归库
from sklearn.feature_extraction.text import CountVectorizer #导入特征提取库
#读取文件,并且删除无关东西
df_train = pd.read_csv('/Users/apple/Documents/ST/python/competition/DataCastel/text_intelligence/new_data/train_set.csv')
df_test = pd.read_csv('/Users/apple/Documents/ST/python/competition/DataCastel/text_intelligence/new_data/test_set.csv')
df_train.drop(columns =['article', 'id'], inplace = True ) #问题1: 为什么要删除这两个列,id列没有意义,不需要用article,直接删除
df_test.drop(columns =['article'], inplace = True )
import numpy as np
from sklearn.datasets import make_classification
from slmethod.perceptron import Perceptron
separable = False
while not separable:
samples = make_classification(n_samples=100,
n_features=2,
n_redundant=0,
n_informative=1,
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
pre = 1
post = 1
diff = 2
index = -1
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
import json
import os
from pprint import pprint
upload_url = 'https://upload.qiniup.com/'
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import time
from googletrans import Translator
translator = Translator()
def translate(src):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import collections
def readMd(mdfile):
with open(mdfile) as f:
lines = f.readlines()
lines = list(map(lambda l: l.rstrip(), lines))
@jiaxianhua
jiaxianhua / clean-docker-for-mac.sh
Created October 13, 2018 11:44 — forked from MrTrustor/clean-docker-for-mac.sh
This script cleans the Docker.qcow2 file that takes a lot of disk space with Docker For Mac. You can specify some Docker images that you would like to keep.
#!/bin/bash
# Copyright 2017 Théo Chamley
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
@jiaxianhua
jiaxianhua / UISwiftRestDemo
Created June 17, 2016 07:09 — forked from cmoulton/UISwiftRestDemo
Quick & dirty REST API calls with Swift. See http://grokswift.com/simple-rest-with-swift/
// MARK: Using NSURLSession
// Get first todo item
let todoEndpoint: String = "http://jsonplaceholder.typicode.com/todos/1"
guard let url = NSURL(string: todoEndpoint) else {
print("Error: cannot create URL")
return
}
let urlRequest = NSURLRequest(URL: url)