Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

gen_data.py 496 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  1. import numpy as np
  2. import pandas as pd
  3. import argparse
  4. parser = argparse.ArgumentParser()
  5. parser.add_argument('--data', '-d', help='specify data amount')
  6. args = parser.parse_args()
  7. if args.data:
  8. n = int(args.data)
  9. else:
  10. n = 1000
  11. X = np.random.randn(n,4)
  12. noise = np.random.randn(n)/20
  13. y = np.sum(X * [1,2,3,4], axis=1) + noise
  14. df = pd.DataFrame(X, columns=['x1', 'x2', 'x3', 'x4'])
  15. df['target'] = y
  16. for col in df.columns:
  17. df[col] = "'"+df[col].astype(str)+"'"
  18. df.to_csv('data.csv')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...