Code Monkey home page Code Monkey logo

project-sound2face's Introduction

Sound2Face

实例数据

from datasets import load_breast_cancer
from classifiers import train_test_split
bc = load_breast_cancer()
X_train, X_test, y_train, y_test = train_test_split(bc.data, bc.target, test_size=0.25)

项目数据

from datasets import load_features
from classifiers import train_test_split
bc = load_features()
X_train, X_test, y_train, y_test = train_test_split(bc.data, bc.target, test_size=0.25)

数据标准化

from preprocessing import StandardScaler
ss = StandardScaler()
X_train = ss.fit_transform(X_train)
X_test = ss.fit_transform(X_test)

组合特征值

from classifiers import combine_feature
X_train = combine_feature(X_train)
X_test = combine_feature(X_test)

Logistic回归

from classifiers import LogisticClassifier
model = LogisticClassifier()
model.train(X_train, y_train, learning_rate=1e-3, num_iters=10000, batch_size=100)
model.score(X_test, y_test)

knn 使用实例

from classifiers import KNearestNeighbor
model = KNearestNeighbor()
model.train(X_train, y_train)
model.score(X_test, y_test,k=5)

线性回归

from classifiers import LinearClassifier
model = LinearClassifier()
model.train(X_train, y_train, learning_rate=1e-3, num_iters=10000, batch_size=100)
model.score(X_test, y_test)

随机森林

from sklearn.ensemble import RandomForestClassifier
rfr = RandomForestClassifier()
rfr.fit(X_train, y_train)
rfr.score(X_test, y_test)

## 支持向量机
```python
from sklearn.svm import LinearSVC
lsvc = LinearSVC()
lsvc.fit(X_train, y_train)
lsvc.score(X_test, y_test)

保存模型

from externals import saveModel, loadModel
saveModelModel(model)
model = loadModel('model.pkl')

准确度进行评估

from sklearn.metrics import classification_report
y_predict = model.predict(X_test)
print classification_report(y_test,y_predict)

特征筛选

from sklearn import feature_selection
fs = feature_selection.SelectPercentile(feature_selection.chi2, percentile=20)
X_train_fs = fs.fit_transform(X_train, y_train)
X_test_fs = fs.traform(X_test)
lsvc.fit(X_train_fs, y_train)
lsvc.score(X_test_fs, y_test)

project-sound2face's People

Contributors

cookissea avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.