GithubHelp home page GithubHelp logo

xyshanren / scikit-learn-for-postgresql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redraiment/scikit-learn-for-polardb

0.0 0.0 0.0 423 KB

在PostgreSQL中使用Scikit-Learn

License: BSD 3-Clause "New" or "Revised" License

Python 54.37% PLpgSQL 45.63%

scikit-learn-for-postgresql's Introduction

Scikit-Learn-for-PostgreSQL

注意:因为代码还在审核,本仓库暂时没有发布完成的代码,按照下文的安装步骤,目前可以正常看到图片。

我会在内部审核通过后及时发布,敬请期待。

PolarDB Logo

Scikit-Learn-for-PostgreSQL是一款基于PolarDB for PostgreSQL的数据分析工具,封装了Scikit Learnmatplotlib的部分函数。目前项目用于PolarDB for PostgreSQL的教学演示,尚未在生产环境中验证,可用于学习用途,请谨慎在生产环境使用。

当前版本:1.0.0-ALPHA

选择终端

为了在psql中可视化地展示数据,需要使用可展示sixel格式图片的终端软件:

  • MacOS环境:推荐使用iTerm2。
  • Linux环境:推荐使用xTerm。
  • Windows环境:推荐使用MinTTY。

安装方法

一、Docker安装(推荐)

docker container run --name 'Scikit' -d redraiment/scikit-learn-for-polardb:latest
docker container exec -it <container-id> psql

二、手工搭建

本节内容基于PolarDB手工搭建数据分析环境。

1. 安装PolarDB for PostgreSQL

执行以下命令,下载预先编译好的PolarDB for PostgreSQL容器:

docker image pull redraiment/polardb-for-postgresql

也可以参考PolarDB for PostgreSQL的文档,编译安装PolarDB for PostgreSQL。

安装完成后,依次执行以下命令,进入Shell:

docker container run --name 'Scikit' -v $PWD:/root/workspaces -d redraiment/polardb-for-postgresql:latest
docker container ls
docker container exec -it <container-id> bash

其中<container-id>替换为Scikit容器的id。

2. 安装libsixel图片格式转换类库

libsixel是一个可以将sixel格式与png、jpg等图片格式互转的类库,支持python、perl、ruby等多种编程语言。

安装方法如下:

cd /home/postgres
git clone https://github.com/saitoha/libsixel.git
cd libsixel
./configure --disable-python
make install # 安装libsixel
cd python
python setup.py install  # 安装libsixel-python模块

3. 安装Scikit Learn等Python类库

PlPython3u使用的是系统原生的python3,所以只要通过pip3安装的所有Python类库,后续都可以在PlPython3u中使用。我们用到以下两个类库:

安装方法如下:

pip3 install -U pip scikit-learn matplotlib

4. 安装PostgreSQL客户端psql

系统默认安装的psql版本是10.17,低于PolarDB for PostgreSQL的版本11.2,但功能也够用,所以可以用以下命令直接安装:

yum install postgresql

5. 安装Scikit Learn for PostgreSQL

cd /home/postgres
git clone https://github.com/redraiment/SciKit-Learn-for-PostgreSQL.git
# 安装Python公共模块
cp -r SciKit-Learn-for-PostgreSQL/python/pgsklearn /usr/local/lib/python3.6/site-packages/
# 安装数据集
cp -r SciKit-Learn-for-PostgreSQL/datasets .
cp -r SciKit-Learn-for-PostgreSQL/images .
chown -R postgres:postgres datasets images
# 安装插件
psql -hlocalhost -p10001 -Upostgres -dpostgres -fSciKit-Learn-for-PostgreSQL/udf/setup.sql

6. 验证安装

执行以下命令:

psql -hlocalhost -p10001 -Upostgres -dpostgres -c 'select show_logo();'

若在终端上能看到PolarDB的logo图片,说明已经安装完成并可正常使用。如下图所示:

show_logo

scikit-learn-for-postgresql's People

Contributors

redraiment 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.