Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the python pyforest Library

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use python pyforest library". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the python pyforest library.

I still remember that when getting started with Python data analysis, we often import several libraries. The following are the four protection methods for getting started, and the tools commonly used for Python data processing and visualization.

I don't know if you have ever encountered such a problem, every time you restart a modeling process or analysis process, you will re-type import or copy the previous import code. Although the knurled knurled has been used very well, it does take unnecessary time.

An example

See, there is no import at the beginning, and you can still use the common library normally.

Installation

A version above Python3.6 needs to be installed, and then the terminal runs:

Pip install pyforest

Usage

Very simple!

It can be solved with one line of code.

From pyforest import *

If you use Jupyter or IPython, you can even skip this line because pyforest adds itself to the automatic startup.

Also, after completing the script, you can export all import statements in the following ways:

Active_imports ()

Through this instruction, we can see all the libraries involved in the script that have been omitted by me.

Well, you might ask, what if the required library is not in pyforest?

First of all, pyforest supports most popular data science libraries, such as pandas,numpy,matplotlib,seaborn,sklearn,tensorflow, etc., as well as commonly used auxiliary libraries such as os,sys,re,pickle.

# Data Wranglingpd = LazyImport ("import pandas as pd")

Np = LazyImport ("import numpy as np")

Dd = LazyImport ("from dask import dataframe as dd") SparkContext = LazyImport ("from pyspark import SparkContext")

Load_workbook = LazyImport ("from openpyxl import load_workbook")

# Data Visualization and Plottingmpl = LazyImport ("import matplotlib as mpl") plt = LazyImport ("import matplotlib.pyplot as plt")

Sns = LazyImport ("import seaborn as sns")

Py = LazyImport ("import plotly as py") go = LazyImport ("import plotly.graph_objs as go") px = LazyImport ("import plotly.express as px")

Dash = LazyImport ("import dash")

Bokeh = LazyImport ("import bokeh")

Alt = LazyImport ("import altair as alt")

Pydot = LazyImport ("import pydot")

# statisticsstatistics = LazyImport ("import statistics")

# Machine Learningsklearn = LazyImport ("import sklearn") OneHotEncoder = LazyImport ("from sklearn.preprocessing import OneHotEncoder") TSNE = LazyImport ("from sklearn.manifold import TSNE") train_test_split = LazyImport ("from sklearn.model_selection import train_test_split") svm = LazyImport ("from sklearn import svm") GradientBoostingClassifier = LazyImport ("from sklearn.ensemble import GradientBoostingClassifier") GradientBoostingRegressor = LazyImport ("from sklearn.ensemble import GradientBoostingRegressor") RandomForestClassifier = LazyImport ("from sklearn.ensemble import RandomForestClassifier") RandomForestRegressor = LazyImport ("from sklearn.ensemble import RandomForestRegressor")

TfidfVectorizer = LazyImport ("from sklearn.feature_extraction.text import TfidfVectorizer")

# TODO: add all the other most important sklearn objects# TODO: add separate sections within machine learning viz. Classification, Regression, Error Functions, Clustering

# Deep Learningtf = LazyImport ("import tensorflow as tf") keras = LazyImport ("import keras")

# NLPnltk = LazyImport ("import nltk") gensim = LazyImport ("import gensim") spacy = LazyImport ("import spacy") re = LazyImport ("import re")

# Helpersys = LazyImport ("import sys") os = LazyImport ("import os") re = LazyImport ("import re") glob = LazyImport ("import glob") Path = LazyImport ("from pathlib import Path")

Pickle = LazyImport ("import pickle")

Dt = LazyImport ("import datetime as dt")

Tqdm = LazyImport ("import tqdm")

Second, it doesn't matter if you don't have it, pyforest supports adding libraries to it. The method of operation is also very simple, find the user_imports.py file of the pyforest library, and then add a statement, such as this:

# # User-specific imports # # You can save your own imports in ~ / .pyforest/user_imports.py# Please note: imports in ~ / .pyforest/user_imports.py take precedence over the# imports above.

At this point, I believe you have a deeper understanding of "how to use the python pyforest library". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report